]> git.ipfire.org Git - thirdparty/u-boot.git/blobdiff - net/wget.c
net: wget: Support non-default HTTP port
[thirdparty/u-boot.git] / net / wget.c
index 8bb4d72db1ae4a8a25855994ceb9be03cc72967c..e1e580c835121eb2b43ed715bbd2e428b7bcc792 100644 (file)
@@ -14,6 +14,9 @@
 #include <net/tcp.h>
 #include <net/wget.h>
 
+/* The default, change with environment variable 'httpdstp' */
+#define SERVER_PORT            80
+
 static const char bootfile1[] = "GET ";
 static const char bootfile3[] = " HTTP/1.0\r\n\r\n";
 static const char http_eom[] = "\r\n\r\n";
@@ -91,19 +94,22 @@ static void wget_send_stored(void)
        int len = retry_len;
        unsigned int tcp_ack_num = retry_tcp_seq_num + (len == 0 ? 1 : len);
        unsigned int tcp_seq_num = retry_tcp_ack_num;
+       unsigned int server_port;
        uchar *ptr, *offset;
 
+       server_port = env_get_ulong("httpdstp", 10, SERVER_PORT) & 0xffff;
+
        switch (current_wget_state) {
        case WGET_CLOSED:
                debug_cond(DEBUG_WGET, "wget: send SYN\n");
                current_wget_state = WGET_CONNECTING;
-               net_send_tcp_packet(0, SERVER_PORT, our_port, action,
+               net_send_tcp_packet(0, server_port, our_port, action,
                                    tcp_seq_num, tcp_ack_num);
                packets = 0;
                break;
        case WGET_CONNECTING:
                pkt_q_idx = 0;
-               net_send_tcp_packet(0, SERVER_PORT, our_port, action,
+               net_send_tcp_packet(0, server_port, our_port, action,
                                    tcp_seq_num, tcp_ack_num);
 
                ptr = net_tx_packet + net_eth_hdr_size() +
@@ -118,14 +124,14 @@ static void wget_send_stored(void)
 
                memcpy(offset, &bootfile3, strlen(bootfile3));
                offset += strlen(bootfile3);
-               net_send_tcp_packet((offset - ptr), SERVER_PORT, our_port,
+               net_send_tcp_packet((offset - ptr), server_port, our_port,
                                    TCP_PUSH, tcp_seq_num, tcp_ack_num);
                current_wget_state = WGET_CONNECTED;
                break;
        case WGET_CONNECTED:
        case WGET_TRANSFERRING:
        case WGET_TRANSFERRED:
-               net_send_tcp_packet(0, SERVER_PORT, our_port, action,
+               net_send_tcp_packet(0, server_port, our_port, action,
                                    tcp_seq_num, tcp_ack_num);
                break;
        }