Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions drivers/net/qcom/nss-switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,7 @@ void ipq_ppe_provision_init(struct ppe_info *info)
/* Dropping all the UDP packets */
ipq_ppe_acl_set(&acl_set);

if (IS_ENABLED(CONFIG_TFTP_PORT)) {
if (IS_ENABLED(CONFIG_CMD_TFTPBOOT)) {
tftp_acl_our_port = 1024 + (get_timer(0) % 3072);

UPDATE_ACL_SET(acl_set, reg_base, 3, 0x4, 0x1,
Expand Down Expand Up @@ -5946,7 +5946,7 @@ static int ipq_eth_start(struct udevice *dev)
if (priv->ppe.bridge_mode)
priv->ppe.nbport = 0;

if (IS_ENABLED(CONFIG_TFTP_PORT))
if (IS_ENABLED(CONFIG_CMD_TFTPBOOT))
env_set_ulong("tftpsrcp", tftp_acl_our_port);

/* HTTP recovery sets eth_allow_no_link and does not need link chatter. */
Expand Down
13 changes: 13 additions & 0 deletions lib/lwip/lwip/src/apps/tftp/tftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,19 @@ tftp_init_client(const struct tftp_context *ctx)
return tftp_init_common(LWIP_TFTP_MODE_CLIENT, ctx);
}

/** @ingroup tftp
* Bind the TFTP client to a specific local UDP port.
* @param port Local UDP port in host byte order
*/
err_t
tftp_client_bind(u16_t port)
{
LWIP_ERROR("TFTP client is not enabled (tftp_init)", (tftp_state.tftp_mode & LWIP_TFTP_MODE_CLIENT) != 0, return ERR_VAL);
LWIP_ERROR("TFTP client PCB is not initialized", tftp_state.upcb, return ERR_VAL);

return udp_bind(tftp_state.upcb, IP_ANY_TYPE, port);
}

/** @ingroup tftp
* Get the transfer size used by the TFTP client. The server may
* report zero in case this is unsupported.
Expand Down
1 change: 1 addition & 0 deletions lib/lwip/lwip/src/include/lwip/apps/tftp_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum tftp_transfer_mode {
};

err_t tftp_init_client(const struct tftp_context* ctx);
err_t tftp_client_bind(u16_t port);
void tftp_client_set_blksize(u16_t blksize);
u32_t tftp_client_get_tsize(void);
err_t tftp_get(void* handle, const ip_addr_t *addr, u16_t port, const char* fname, enum tftp_transfer_mode mode);
Expand Down
14 changes: 14 additions & 0 deletions net/lwip/tftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ static int tftp_loop(struct udevice *udev, ulong addr, char *fname,
ip_addr_t srvip, uint16_t srvport)
{
int blksize = CONFIG_TFTP_BLOCKSIZE;
u16_t local_port;
struct netif *netif;
struct tftp_ctx ctx;
const char *ep;
Expand Down Expand Up @@ -216,6 +217,19 @@ static int tftp_loop(struct udevice *udev, ulong addr, char *fname,
if (!(err == ERR_OK || err == ERR_USE))
log_err("tftp_init_client err: %d\n", err);

ep = env_get("tftpsrcp");
if (ep) {
local_port = dectoul(ep, NULL);
err = tftp_client_bind(local_port);
if (err != ERR_OK) {
log_err("tftp_client_bind(%u) err: %d\n", local_port,
err);
tftp_cleanup();
net_lwip_remove_netif(netif);
return -1;
}
}

ep = env_get("tftpblocksize");
if (ep)
blksize = simple_strtol(ep, NULL, 10);
Expand Down