/* Prepare a request as required by RFC1350. This packet can be sent out directly to the TFTP server.  */
static size_t make_request(uint8_t *buf, int request, const char *remote_file, const char *mode)
/* Prepare a request as required by RFC1350. This packet can be sent out directly to the TFTP server.  */
static size_t make_request(uint8_t *buf, int request, const char *remote_file, const char *mode)
{
	char *ptr = (char *)buf;
	const char def_mode[] = "octet";
	sys_put_be16(request, ptr);
	ptr += 2;
	strncpy(ptr, remote_file, TFTP_MAX_FILENAME_SIZE);
	ptr += strlen(remote_file);
	*ptr++ = '\0';
	if (mode == NULL) {
		mode = def_mode;
	}
	strncpy(ptr, mode, TFTP_MAX_MODE_SIZE);
	ptr += strlen(mode);
	*ptr++ = '\0';
	return ptr - (char *)buf;
}