Adding TCP and wget into u-boot
Subsystems (2)
PATCH v9 1/3 Adding TCP and wget into u-boot
From: Duncan Hare <[email protected]>
cover-letter:
Why netboot:
Central management, including logs and change control, coupled with with enhanced security and unauthorized change detection and remediation by exposing a small attack surface.
Why TCP:
Currently file transfer are done using tftp or NFS both over udp. This requires a request to be sent from client (u-boot) to the boot server.
For a 4 Mbyte kernel, with a 1k block size this requires 4,000 request for a block.
Using a large block size, one greater than the Ethernet maximum frame size limitation, would require fragmentation, which u-boot supports. However missing fragment recovery requires timeout detection and re-transmission requests for missing fragments.
UDP is ideally suited to fast single packet exchanges, inquiry/response, for example dns, becuse of the lack of connection overhead.
UDP as a file transport mechanism is slow, even in low latency networks, because file transfer with udp requires poll/response mechanism to provide transfer integrity.
In networks with large latency, for example: the internet, UDP is even slower. What is a 30 second transfer on a local boot server and LAN increase to over 3 minutes, because of all the requests/response traffic.
This was anticipated in the evolution of the IP protocols and TCP was developed and then enhanced for high latency high bandwidth networks.
The current standard is TCP with selective acknowledgment.
In our testing we have reduce kernel transmission time to around 0.4 seconds for a 4Mbyte kernel, with a 100 Mbps downlink.
Why http and wget:
HTTP is the most efficient file retrieval protocol in common use. The client send a single request, after TCP connection, to receive a file of any length.
WGET is the application which implements http file transfer outside browsers as a file transfer protocol. Versions of wget exists on many operating systems.
END
---
Added a protocol parameter to ip packet sending in net.c Added UDP protocol for current applications to minimize code changes to existing net apps.
All the code is new, and not copied from any source.
Changes in v9:
Initial changes for adding TCP
include/net.h | 25 +++++++++++++++++++------ net/net.c | 52 ++++++++++++++++++++++++++++++++++------------------ net/ping.c | 9 ++------- 3 files changed, 55 insertions(+), 31 deletions(-)
include/net.h +19 -6
@@ -15,17 +15,26 @@#include <asm/cache.h> #include <asm/byteorder.h> /* for nton* / ntoh* stuff */ -#define DEBUG_LL_STATE 0/* Link local state machine changes */ -#define DEBUG_DEV_PKT 0/* Packets or info directed to the device */ -#define DEBUG_NET_PKT 0/* Packets on info on the network at large */ +#define DEBUG_LL_STATE 0/* Link local state machine changes */ +#define DEBUG_DEV_PKT 0/* Packets or info directed to the device */ +#define DEBUG_NET_PKT 0/* Packets on info on the network at large */ #define DEBUG_INT_STATE 0/* Internal network state changes */ /* * The number of receive packet buffers, and the required packet buffer * alignment in memory. * +* The number of buffers for TCP is used to calculate a static TCP window +* size, becuse TCP window size is a promise to the sending TCP to be able +* to buffer up to the window size of data. +* When the sending TCP has a window size of outstanding unacknowledged +* data, the sending TCP will stop sending. */ +#if defined(CONFIG_TCP ) +#define CONFIG_SYS_RX_ETH_BUFFER 12/* For TCP */ +#endif +#ifdef CONFIG_SYS_RX_ETH_BUFFER # define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER#else
@@ -354,6 +363,7 @@ struct vlan_ethernet_hdr {#define IPPROTO_ICMP 1/* Internet Control Message Protocol */ #define IPPROTO_UDP 17/* User Datagram Protocol */ +#define IPPROTO_TCP 6/* Transmission Control Protocol */ /* * Internet Protocol (IP) header.
@@ -596,10 +606,10 @@ int net_set_ether(uchar *xet, const uchar *dest_ethaddr, uint prot);int net_update_ether (struct ethernet_hdr *et,uchar *addr,uint prot);/* Set IP header */ -void net_set_ip_header (uchar *pkt,struct in_addr dest,struct in_addr source); +void net_set_ip_header (uchar *pkt,struct in_addr dest,struct in_addr source, +u16 pkt_len,u8 prot);void net_set_udp_header (uchar *pkt,struct in_addr dest,int dport, -int sport,int len); - +int sport,int len);/** * compute_ip_checksum() - Compute IP checksum *
@@ -670,6 +680,9 @@ static inline void net_send_packet(uchar *pkt, int len)* @param sport Source UDP port * @param payload_len Length of data after the UDP header */ +int net_send_ip_packet (uchar *ether,struct in_addr dest,int dport,int sport, +int payload_len,int proto); +int net_send_udp_packet (uchar *ether,struct in_addr dest,int dport,int sport,int payload_len);
net/net.c +34 -18
119 lines not on this page · raw message
net/ping.c +2 -7
@@ -20,16 +20,11 @@ struct in_addr net_ping_ip;static void set_icmp_header (uchar *pkt,struct in_addr dest) {/* -* Construct an IP and ICMP header. +* Construct an ICMP header. */ -struct ip_hdr *ip = (struct ip_hdr *)pkt;struct icmp_hdr *icmp = (struct icmp_hdr *)(pkt +IP_HDR_SIZE ); -net_set_ip_header (pkt, dest, net_ip); - - ip->ip_len =htons (IP_ICMP_HDR_SIZE ); - ip->ip_p =IPPROTO_ICMP ; - ip->ip_sum =compute_ip_checksum (ip,IP_HDR_SIZE ); +net_set_ip_header (pkt, dest, net_ip,IP_ICMP_HDR_SIZE ,IPPROTO_ICMP ); icmp->type =ICMP_ECHO_REQUEST ; icmp->code =0 ;
Signature · 1 line
2.11.0
PATCH v9 2/3 Adding TCP
From: Duncan Hare <[email protected]>
All the code is new, and not copied from any source.
Series-changes
The previous patch was using an old version of net/Kconfig, which prevented requesting options for a bootp/dhcp request.
A similar issue fixed with a cmd/Kconfig.
Items in include/net.h fixed.
---
Why TCP:
Currently file transfer are done using tftp or NFS both over udp. This requires a request to be sent from client (u-boot) to the boot server.
For a 4 Mbyte kernel, with a 1k block size this requires 4,000 request for a block.
Using a large block size, one greater than the Ethernet maximum frame size limitation, would require fragmentation, which u-boot supports. However missing fragment recovery requires timeout detection and re-transmission requests for missing fragments.
In networks with large latency, for example: the internet, UDP is vwey slow. What is a 30 second transfer on a local boot server and LAN increase to over 3 minutes, because of all the requests/response traffic.
This was anticipated in the evolution of the IP protocols and TCP was developed and then enhanced for high latency high bandwidth networks.
The current standard is TCP with selective acknowledgment.
Routine tcp_print_buffer() is used to print portions of non zero terminated buffers. If there is an existing routine please let me know. I'm from the world of length fields not zero terminated strings (zOS).
Changes in v9: None
include/net.h | 8 +- include/net/tcp.h | 218 ++++++++++++++++ net/Kconfig | 5 + net/Makefile | 2 +- net/net.c | 51 +++- net/tcp.c | 749 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 1023 insertions(+), 10 deletions(-) create mode 100644 include/net/tcp.h create mode 100644 net/tcp.c
include/net.h +6 -2
@@ -548,7 +548,7 @@ extern int net_restart_wrap; /* Tried all network devices */enum proto_t {BOOTP ,RARP ,ARP ,TFTPGET ,DHCP ,PING ,DNS ,NFS ,CDP ,NETCONS ,SNTP , -TFTPSRV ,TFTPPUT ,LINKLOCAL +TFTPSRV ,TFTPPUT ,LINKLOCAL ,WGET };extern char net_boot_file_name[1024 ];/* Boot File name */
@@ -681,11 +681,15 @@ static inline void net_send_packet(uchar *pkt, int len)* @param payload_len Length of data after the UDP header */ int net_send_ip_packet (uchar *ether,struct in_addr dest,int dport,int sport, -int payload_len,int proto); +int payload_len,int proto,u8 action,u32 tcp_seq_num, +u32 tcp_ack_num);int net_send_udp_packet (uchar *ether,struct in_addr dest,int dport,int sport,int payload_len); +int net_send_tcp_packet (int payload_len,int dport,int sport,u8 action, +u32 tcp_seq_num,u32 tcp_ack_num); +/* Processes a received packet */ void net_process_received_packet (uchar *in_packet,int len);
include/net/tcp.h new file +218 -0
218 lines not on this page · raw message
net/Kconfig +5 -0
@@ -33,6 +33,11 @@ config NET_TFTP_VARS If unset, timeout and maximum are hard-defined as 1 second and 10 timouts per TFTP transfer. +config TCP + bool "Include Subset TCP stack for wget" + help + TCP protocol support for wget. + config BOOTP_BOOTPATH bool "Enable BOOTP BOOTPATH" depends on CMD_NET
net/Makefile +1 -1
@@ -25,7 +25,7 @@ obj-$(CONFIG_CMD_PING) += ping.o obj-$(CONFIG_CMD_RARP) += rarp.o obj-$(CONFIG_CMD_SNTP) += sntp.o obj-$(CONFIG_CMD_NET) += tftp.o - +obj-$(CONFIG_TCP) += tcp.o # Disable this warning as it is triggered by: # sprintf(buf, index ? "foo%d" : "foo", index) # and this is intentional usage.
net/net.c +44 -7
94 lines not on this page · raw message
net/tcp.c new file +749 -0
749 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v9 3/3 Adding wget
In reply to DH at synoia.comFrom: Duncan Hare <[email protected]>
Why http and wget:
HTTP is the most efficient file retrieval protocol in common use. The client send a single request, after TCP connection, to receive a file of any length.
WGET is the application which implements http file transfer outside browsers as a file transfer protocol. Versions of wget exists on many operating systems.
END
---
Changes in v9: None
cmd/Kconfig | 5 + cmd/net.c | 13 ++ include/net.h | 16 +- include/net/wget.h | 17 +++ net/Kconfig | 7 +- net/Makefile | 1 + net/wget.c | 420 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 470 insertions(+), 9 deletions(-) create mode 100644 include/net/wget.h create mode 100644 net/wget.c
cmd/Kconfig +5 -0
@@ -1094,6 +1094,11 @@ config CMD_ETHSW operations such as enabling / disabling a port and viewing/maintaining the filtering database (FDB) +config CMD_WGET + bool "wget" + select TCP + help + Download a kernel, or other files, from a web server over TCP. endif endmenu
cmd/net.c +13 -0
@@ -110,6 +110,19 @@ U_BOOT_CMD( );#endif +#if defined(CONFIG_CMD_WGET ) +static int do_wget (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +return netboot_common (WGET , cmdtp, argc, argv); +} + +U_BOOT_CMD ( + wget,3 ,1 , do_wget, +"boot image via network using HTTP protocol" , +"[loadAddress] [[hostIPaddr:]path and image name]" +); +#endif +static void netboot_update_env (void ) {char tmp[22 ];
include/net.h +8 -8
@@ -15,10 +15,14 @@#include <asm/cache.h> #include <asm/byteorder.h> /* for nton* / ntoh* stuff */ -#define DEBUG_LL_STATE 0/* Link local state machine changes */ -#define DEBUG_DEV_PKT 0/* Packets or info directed to the device */ +#define DEBUG_LL_STATE 0/* Link local state machine changes */ +#define DEBUG_DEV_PKT 0/* Packets or info directed to the device */ #define DEBUG_NET_PKT 0/* Packets on info on the network at large */ -#define DEBUG_INT_STATE 0/* Internal network state changes */ +#define DEBUG_INT_STATE 0/* Internal network state change */ + +#if defined(CONFIG_TCP ) +#define CONFIG_SYS_RX_ETH_BUFFER 12/* For TCP */ +#endif /* * The number of receive packet buffers, and the required packet buffer
@@ -31,10 +35,6 @@* data, the sending TCP will stop sending. */ -#if defined(CONFIG_TCP ) -#define CONFIG_SYS_RX_ETH_BUFFER 12/* For TCP */ -#endif -#ifdef CONFIG_SYS_RX_ETH_BUFFER # define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER#else
@@ -362,8 +362,8 @@ struct vlan_ethernet_hdr {#define PROT_PPP_SES 0x8864/* PPPoE session messages */ #define IPPROTO_ICMP 1/* Internet Control Message Protocol */ +#define IPPROTO_TCP 6/* Transmission Control Protocol */ #define IPPROTO_UDP 17/* User Datagram Protocol */ -#define IPPROTO_TCP 6/* Transmission Control Protocol */ /* * Internet Protocol (IP) header.
include/net/wget.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* Duncan Hare Copyright 2017 +*/ + +void wget_start (void );/* Begin wget */ + +enum WGET_STATE { +WGET_CLOSED , +WGET_CONNECTING , +WGET_CONNECTED , +WGET_TRANSFERRING , +WGET_TRANSFERRED }; + +#define DEBUG_WGET 0/* Set to 1 for debug messges */ +#define SERVER_PORT 80 +#define WGET_RETRY_COUNT 30 +#define WGET_TIMEOUT 2000UL
net/Kconfig +6 -1
@@ -36,7 +36,12 @@ config NET_TFTP_VARS config TCP bool "Include Subset TCP stack for wget" help - TCP protocol support for wget. + Selecting TCP protocol support adds TCP for receiving + streams of data. The TCP packets are presented + as received (possibly out of order). The application + receiving the TCP stream places the date by sequence number + as an offset from the kernel address. TCP transmission is + not supported. config BOOTP_BOOTPATH bool "Enable BOOTP BOOTPATH"
net/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_CMD_RARP) += rarp.o obj-$(CONFIG_CMD_SNTP) += sntp.o obj-$(CONFIG_CMD_NET) += tftp.o obj-$(CONFIG_TCP) += tcp.o +obj-$(CONFIG_CMD_WGET) += wget.o # Disable this warning as it is triggered by: # sprintf(buf, index ? "foo%d" : "foo", index) # and this is intentional usage.
net/wget.c new file +420 -0
420 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v9 1/3 Adding TCP and wget into u-boot
In reply to DH at synoia.comThe subject for the cover letter (what you currently have as the first line of text in this commit's message) should be moved to the first line inside of the 'Cover-letter:' tag.
Quoted 3 lines · On Sun, Mar 25, 2018 at 1:06 PM, <[email protected]> wrote:
From: Duncan Hare <[email protected]>
cover-letter:
I mentioned this last time, but you still didn't change it. You need a Capitol letter 'C' in Cover-letter:
The cover letter will get sent as a separate email.
Quoted 55 lines
Why netboot:
Central management, including logs and change control, coupled with with enhanced security and unauthorized change detection and remediation by exposing a small attack surface.Why TCP:
Currently file transfer are done using tftp or NFS both over udp. This requires a request to be sent from client (u-boot) to the boot server.
For a 4 Mbyte kernel, with a 1k block size this requires 4,000 request for a block.
Using a large block size, one greater than the Ethernet maximum frame size limitation, would require fragmentation, which u-boot supports. However missing fragment recovery requires timeout detection and re-transmission requests for missing fragments.
UDP is ideally suited to fast single packet exchanges, inquiry/response, for example dns, becuse of the lack of connection overhead.
UDP as a file transport mechanism is slow, even in low latency networks, because file transfer with udp requires poll/response mechanism to provide transfer integrity.
In networks with large latency, for example: the internet, UDP is even slower. What is a 30 second transfer on a local boot server and LAN increase to over 3 minutes, because of all the requests/response traffic.
This was anticipated in the evolution of the IP protocols and TCP was developed and then enhanced for high latency high bandwidth networks.
The current standard is TCP with selective acknowledgment.
In our testing we have reduce kernel transmission time to around 0.4 seconds for a 4Mbyte kernel, with a 100 Mbps downlink.
Why http and wget:
HTTP is the most efficient file retrieval protocol in common use. The client send a single request, after TCP connection, to receive a file of any length.
WGET is the application which implements http file transfer outside browsers as a file transfer protocol. Versions of wget exists on many operating systems.
END
Quoted 9 lines
Signed-off-by Duncan Hare <[email protected]>---
Added a protocol parameter to ip packet sending in
net.cAdded UDP protocol for current applications to minimize code changes to existing net apps.All the code is new, and not copied from any source.
This commentary should not be tagged for patman at all. Please remove the 'Series-notes:' tag.
Quoted 3 lines
Changes in v9:
Initial changes for adding TCP
This should be the first line of the patch, not listed under Series-changes:
Quoted 233 lines
include/net.h | 25 +++++++++++++++++++------ net/net.c | 52 ++++++++++++++++++++++++++++++++++------------------ net/ping.c | 9 ++------- 3 files changed, 55 insertions(+), 31 deletions(-)include/net.h +19
-6@@ -15,17 +15,26 @@#include <asm/cache.h> #include <asm/byteorder.h> /* for nton* / ntoh* stuff */ -#define DEBUG_LL_STATE 0/* Link local state machine changes */ -#define DEBUG_DEV_PKT 0/* Packets or info directed to the device */ -#define DEBUG_NET_PKT 0/* Packets on info on the network at large */ +#define DEBUG_LL_STATE 0/* Link local state machine changes */ +#define DEBUG_DEV_PKT 0/* Packets or info directed to the device */ +#define DEBUG_NET_PKT 0/* Packets on info on the network at large */ #define DEBUG_INT_STATE 0/* Internal network state changes */ /* * The number of receive packet buffers, and the required packet buffer * alignment in memory. * +* The number of buffers for TCP is used to calculate a static TCP window +* size, becuse TCP window size is a promise to the sending TCP to be able +* to buffer up to the window size of data. +* When the sending TCP has a window size of outstanding unacknowledged +* data, the sending TCP will stop sending. */ +#if defined(CONFIG_TCP ) +#define CONFIG_SYS_RX_ETH_BUFFER 12/* For TCP */ +#endif +#ifdef CONFIG_SYS_RX_ETH_BUFFER # define PKTBUFSRX CONFIG_SYS_RX_ETH_BUFFER#else @@ -354,6 +363,7 @@ struct vlan_ethernet_hdr {#define IPPROTO_ICMP 1/* Internet Control Message Protocol */ #define IPPROTO_UDP 17/* User Datagram Protocol */ +#define IPPROTO_TCP 6/* Transmission Control Protocol */ /* * Internet Protocol (IP) header. @@ -596,10 +606,10 @@ int net_set_ether(uchar *xet, const uchar *dest_ethaddr, uint prot);int net_update_ether (struct ethernet_hdr *et,uchar *addr,uint prot);/* Set IP header */ -void net_set_ip_header (uchar *pkt,struct in_addr dest,struct in_addr source); +void net_set_ip_header (uchar *pkt,struct in_addr dest,struct in_addr source, +u16 pkt_len,u8 prot);void net_set_udp_header (uchar *pkt,struct in_addr dest,int dport, -int sport,int len); - +int sport,int len);/** * compute_ip_checksum() - Compute IP checksum * @@ -670,6 +680,9 @@ static inline void net_send_packet(uchar *pkt, int len)* @param sport Source UDP port * @param payload_len Length of data after the UDP header */ +int net_send_ip_packet (uchar *ether,struct in_addr dest,int dport,int sport, +int payload_len,int proto); +int net_send_udp_packet (uchar *ether,struct in_addr dest,int dport,int sport,int payload_len);net/net.c +34
-18@@ -181,6 +181,7 @@ int net_ntp_time_offset;static uchar net_pkt_buf[(PKTBUFSRX +1 ) *PKTSIZE_ALIGN +PKTALIGN ];/* Receive packets */ uchar *net_rx_packets[PKTBUFSRX ]; +/* Current UDP RX packet handler */ static rxhand_f *udp_packet_handler;/* Current ARP RX packet handler */ @@ -777,11 +778,23 @@ void net_set_timeout_handler(ulong iv, thand_f *f) }int net_send_udp_packet (uchar *ether,struct in_addr dest,int dport,int sport, -int payload_len) +int payload_len) +{ +return net_send_ip_packet (ether, dest, dport, sport, payload_len, +IPPROTO_UDP ); +} + +int net_send_ip_packet (uchar *ether,struct in_addr dest,int dport,int sport, +int payload_len,int proto) {uchar *pkt;int eth_hdr_size;int pkt_hdr_size; +if (proto ==IPPROTO_UDP ) { +debug_cond (DEBUG_DEV_PKT , +"UDP Send (to=%pI4, from=%pI4, len=%d)\n" , + &dest, &net_ip, payload_len); + }/* make sure the net_tx_packet is initialized (net_init() was called) */ assert (net_tx_packet !=NULL );@@ -799,9 +812,15 @@ int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport, int sport, pkt = (uchar *)net_tx_packet; eth_hdr_size =net_set_ether (pkt, ether,PROT_IP ); - pkt += eth_hdr_size; -net_set_udp_header (pkt, dest, dport, sport, payload_len); - pkt_hdr_size = eth_hdr_size +IP_UDP_HDR_SIZE ; +switch (proto) { +case IPPROTO_UDP : +net_set_udp_header (pkt + eth_hdr_size, dest, + dport, sport, payload_len); + pkt_hdr_size = eth_hdr_size +IP_UDP_HDR_SIZE ; +break ; +default : +return -1 ; + }/* if MAC address was not discovered yet, do an ARP request */ if (memcmp (ether, net_null_ethaddr,6 ) ==0 ) {@@ -1157,9 +1176,6 @@ void net_process_received_packet(uchar *in_packet, int len)/* Can't deal with anything except IPv4 */ if ((ip->ip_hl_v &0xf0 ) !=0x40 )return ; -/* Can't deal with IP options (headers != 20 bytes) */ -if ((ip->ip_hl_v &0x0f ) >0x05 ) -return ;/* Check the Checksum of the header */ if (!ip_checksum_ok ((uchar *)ip,IP_HDR_SIZE )) {debug ("checksum bad\n" );@@ -1205,6 +1221,7 @@ void net_process_received_packet(uchar *in_packet, int len)* we send a tftp packet to a dead connection, or when * there is no server at the other end. */ +if (ip->ip_p ==IPPROTO_ICMP ) {receive_icmp (ip, len, src_ip, et);return ;@@ -1365,8 +1382,7 @@ common: }/**********************************************************************/ -int -net_eth_hdr_size (void ) +int net_eth_hdr_size (void ) {ushort myvlanid;@@ -1426,25 +1442,28 @@ int net_update_ether(struct ethernet_hdr *et, uchar *addr, uint prot) } } -void net_set_ip_header (uchar *pkt,struct in_addr dest,struct in_addr source) +void net_set_ip_header (uchar *pkt,struct in_addr dest,struct in_addr source, +u16 pkt_len,u8 prot) {struct ip_udp_hdr *ip = (struct ip_udp_hdr *)pkt;/* -* Construct an IP header. +* Construct an IP header. */ /* IP_HDR_SIZE / 4 (not including UDP) */ ip->ip_hl_v =0x45 ; ip->ip_tos =0 ; - ip->ip_len =htons (IP_HDR_SIZE ); + ip->ip_len =htons (pkt_len); ip->ip_id =htons (net_ip_id++); - ip->ip_off =htons (IP_FLAGS_DFRAG );/* Don't fragment */ + ip->ip_off =htons (IP_FLAGS_DFRAG );/* Don't fragment */ ip->ip_ttl =255 ; + ip->ip_p = prot; ip->ip_sum =0 ;/* already in network byte order */ net_copy_ip ((void *)&ip->ip_src, &source);/* already in network byte order */ net_copy_ip ((void *)&ip->ip_dst, &dest); + ip->ip_sum =compute_ip_checksum (ip,IP_HDR_SIZE ); } void net_set_udp_header(uchar *pkt, struct in_addr dest, int dport, int sport,@@ -1460,11 +1479,8 @@ void net_set_udp_header(uchar *pkt, struct in_addr dest, int dport, int sport,if (len &1 ) pkt[IP_UDP_HDR_SIZE + len] =0 ; -net_set_ip_header (pkt, dest, net_ip); - ip->ip_len =htons (IP_UDP_HDR_SIZE + len); - ip->ip_p =IPPROTO_UDP ; - ip->ip_sum =compute_ip_checksum (ip,IP_HDR_SIZE ); - +net_set_ip_header (pkt, dest, net_ip,IP_UDP_HDR_SIZE + len, +IPPROTO_UDP ); ip->udp_src =htons (sport); ip->udp_dst =htons (dport); ip->udp_len =htons (UDP_HDR_SIZE + len);net/ping.c +2
-8@@ -20,16 +20,11 @@ struct in_addr net_ping_ip;static void set_icmp_header (uchar *pkt,struct in_addr dest) {/* -* Construct an IP and ICMP header. +* Construct an ICMP header. */ -struct ip_hdr *ip = (struct ip_hdr *)pkt;struct icmp_hdr *icmp = (struct icmp_hdr *)(pkt +IP_HDR_SIZE ); -net_set_ip_header (pkt, dest, net_ip); - - ip->ip_len =htons (IP_ICMP_HDR_SIZE ); - ip->ip_p =IPPROTO_ICMP ; - ip->ip_sum =compute_ip_checksum (ip,IP_HDR_SIZE ); +net_set_ip_header (pkt, dest, net_ip,IP_ICMP_HDR_SIZE ,IPPROTO_ICMP ); icmp->type =ICMP_ECHO_REQUEST ; icmp->code =0 ; --2.11.0
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot