net: cosmetic: Fix checkpatch.pl failures in net.c

Finish eliminating CamelCase from net.c and other failures

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Joe Hershberger 2015-04-08 01:41:21 -05:00 committed by Simon Glass
parent a34f207563
commit bc0571fc10
21 changed files with 182 additions and 185 deletions

6
README
View file

@ -3340,9 +3340,9 @@ Legacy uImage format:
65 net/eth.c Ethernet found. 65 net/eth.c Ethernet found.
-80 common/cmd_net.c usage wrong -80 common/cmd_net.c usage wrong
80 common/cmd_net.c before calling NetLoop() 80 common/cmd_net.c before calling net_loop()
-81 common/cmd_net.c some error in NetLoop() occurred -81 common/cmd_net.c some error in net_loop() occurred
81 common/cmd_net.c NetLoop() back without error 81 common/cmd_net.c net_loop() back without error
-82 common/cmd_net.c size == 0 (File with size 0 loaded) -82 common/cmd_net.c size == 0 (File with size 0 loaded)
82 common/cmd_net.c trying automatic boot 82 common/cmd_net.c trying automatic boot
83 common/cmd_net.c running "source" command 83 common/cmd_net.c running "source" command

View file

@ -170,7 +170,7 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
* Check to see if we need to tftp the image ourselves before starting * Check to see if we need to tftp the image ourselves before starting
*/ */
if ((argc == 2) && (strcmp(argv[1], "tftp") == 0)) { if ((argc == 2) && (strcmp(argv[1], "tftp") == 0)) {
if (NetLoop(TFTPGET) <= 0) if (net_loop(TFTPGET) <= 0)
return 1; return 1;
printf("Automatic boot of VxWorks image at address 0x%08lx ...\n", printf("Automatic boot of VxWorks image at address 0x%08lx ...\n",
addr); addr);

View file

@ -158,8 +158,8 @@ static void netboot_update_env(void)
setenv("domain", net_nis_domain); setenv("domain", net_nis_domain);
#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET) #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET)
if (NetTimeOffset) { if (net_ntp_time_offset) {
sprintf(tmp, "%d", NetTimeOffset); sprintf(tmp, "%d", net_ntp_time_offset);
setenv("timeoffset", tmp); setenv("timeoffset", tmp);
} }
#endif #endif
@ -227,14 +227,14 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
} }
bootstage_mark(BOOTSTAGE_ID_NET_START); bootstage_mark(BOOTSTAGE_ID_NET_START);
size = NetLoop(proto); size = net_loop(proto);
if (size < 0) { if (size < 0) {
bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK); bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK);
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
} }
bootstage_mark(BOOTSTAGE_ID_NET_NETLOOP_OK); bootstage_mark(BOOTSTAGE_ID_NET_NETLOOP_OK);
/* NetLoop ok, update environment */ /* net_loop ok, update environment */
netboot_update_env(); netboot_update_env();
/* done if no file was loaded (no errors though) */ /* done if no file was loaded (no errors though) */
@ -267,7 +267,7 @@ static int do_ping(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (net_ping_ip.s_addr == 0) if (net_ping_ip.s_addr == 0)
return CMD_RET_USAGE; return CMD_RET_USAGE;
if (NetLoop(PING) < 0) { if (net_loop(PING) < 0) {
printf("ping failed; host %s is not alive\n", argv[1]); printf("ping failed; host %s is not alive\n", argv[1]);
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
} }
@ -310,7 +310,7 @@ int do_cdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{ {
int r; int r;
r = NetLoop(CDP); r = net_loop(CDP);
if (r < 0) { if (r < 0) {
printf("cdp failed; perhaps not a CISCO switch?\n"); printf("cdp failed; perhaps not a CISCO switch?\n");
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
@ -349,11 +349,11 @@ int do_sntp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
toff = getenv("timeoffset"); toff = getenv("timeoffset");
if (toff == NULL) if (toff == NULL)
NetTimeOffset = 0; net_ntp_time_offset = 0;
else else
NetTimeOffset = simple_strtol(toff, NULL, 10); net_ntp_time_offset = simple_strtol(toff, NULL, 10);
if (NetLoop(SNTP) < 0) { if (net_loop(SNTP) < 0) {
printf("SNTP failed: host %pI4 not responding\n", printf("SNTP failed: host %pI4 not responding\n",
&net_ntp_server); &net_ntp_server);
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
@ -399,7 +399,7 @@ int do_dns(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
else else
net_dns_env_var = NULL; net_dns_env_var = NULL;
if (NetLoop(DNS) < 0) { if (net_loop(DNS) < 0) {
printf("dns lookup of %s failed, check setup\n", argv[1]); printf("dns lookup of %s failed, check setup\n", argv[1]);
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
} }
@ -421,7 +421,7 @@ static int do_link_local(cmd_tbl_t *cmdtp, int flag, int argc,
{ {
char tmp[22]; char tmp[22];
if (NetLoop(LINKLOCAL) < 0) if (net_loop(LINKLOCAL) < 0)
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
net_gateway.s_addr = 0; net_gateway.s_addr = 0;

View file

@ -28,7 +28,7 @@ void spl_net_load_image(const char *device)
} }
if (device) if (device)
setenv("ethact", device); setenv("ethact", device);
rv = NetLoop(BOOTP); rv = net_loop(BOOTP);
if (rv < 0) { if (rv < 0) {
printf("Problem booting with BOOTP\n"); printf("Problem booting with BOOTP\n");
hang(); hang();

View file

@ -70,7 +70,7 @@ static int update_load(char *filename, ulong msec_max, int cnt_max, ulong addr)
/* download the update file */ /* download the update file */
load_addr = addr; load_addr = addr;
copy_filename(net_boot_file_name, filename, sizeof(net_boot_file_name)); copy_filename(net_boot_file_name, filename, sizeof(net_boot_file_name));
size = NetLoop(TFTPGET); size = net_loop(TFTPGET);
if (size < 0) if (size < 0)
rv = 1; rv = 1;

View file

@ -32,11 +32,11 @@ after successful negotiation to enable network access.
------------- -------------
RFC3927 requires that addresses are continuously checked to RFC3927 requires that addresses are continuously checked to
avoid conflicts, however this can only happen when the NetLoop avoid conflicts, however this can only happen when the net_loop
is getting called. It is possible for a conflict to go undetected is getting called. It is possible for a conflict to go undetected
until a command that accesses the network is executed. until a command that accesses the network is executed.
Using NetConsole is one way to ensure that NetLoop is always Using NetConsole is one way to ensure that net_loop is always
processing packets and monitoring for conflicts. processing packets and monitoring for conflicts.
This is also not a concern if the feature is use to connect This is also not a concern if the feature is use to connect

View file

@ -113,7 +113,7 @@ static int refresh_settings_from_env(void)
} }
/** /**
* Called from NetLoop in net/net.c before each packet * Called from net_loop in net/net.c before each packet
*/ */
void nc_start(void) void nc_start(void)
{ {
@ -121,7 +121,7 @@ void nc_start(void)
if (!output_packet_len || memcmp(nc_ether, net_null_ethaddr, 6)) { if (!output_packet_len || memcmp(nc_ether, net_null_ethaddr, 6)) {
/* going to check for input packet */ /* going to check for input packet */
net_set_udp_handler(nc_handler); net_set_udp_handler(nc_handler);
NetSetTimeout(net_timeout, nc_timeout_handler); net_set_timeout_handler(net_timeout, nc_timeout_handler);
} else { } else {
/* send arp request */ /* send arp request */
uchar *pkt; uchar *pkt;
@ -188,7 +188,7 @@ static void nc_send_packet(const char *buf, int len)
output_packet = buf; output_packet = buf;
output_packet_len = len; output_packet_len = len;
input_recursion = 1; input_recursion = 1;
NetLoop(NETCONS); /* wait for arp reply and send packet */ net_loop(NETCONS); /* wait for arp reply and send packet */
input_recursion = 0; input_recursion = 0;
output_packet_len = 0; output_packet_len = 0;
return; return;
@ -232,7 +232,7 @@ static int nc_stdio_start(struct stdio_dev *dev)
/* /*
* Initialize the static IP settings and buffer pointers * Initialize the static IP settings and buffer pointers
* incase we call net_send_udp_packet before NetLoop * incase we call net_send_udp_packet before net_loop
*/ */
net_init(); net_init();
@ -277,7 +277,7 @@ static int nc_stdio_getc(struct stdio_dev *dev)
net_timeout = 0; /* no timeout */ net_timeout = 0; /* no timeout */
while (!input_size) while (!input_size)
NetLoop(NETCONS); net_loop(NETCONS);
input_recursion = 0; input_recursion = 0;
@ -307,7 +307,7 @@ static int nc_stdio_tstc(struct stdio_dev *dev)
input_recursion = 1; input_recursion = 1;
net_timeout = 1; net_timeout = 1;
NetLoop(NETCONS); /* kind of poll */ net_loop(NETCONS); /* kind of poll */
input_recursion = 0; input_recursion = 0;

View file

@ -485,7 +485,6 @@ extern uchar *net_tx_packet; /* THE transmit packet */
extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */ extern uchar *net_rx_packets[PKTBUFSRX]; /* Receive packets */
extern uchar *net_rx_packet; /* Current receive packet */ extern uchar *net_rx_packet; /* Current receive packet */
extern int net_rx_packet_len; /* Current rx packet length */ extern int net_rx_packet_len; /* Current rx packet length */
extern unsigned NetIPID; /* IP ID (counting) */
extern const u8 net_bcast_ethaddr[6]; /* Ethernet broadcast address */ extern const u8 net_bcast_ethaddr[6]; /* Ethernet broadcast address */
extern const u8 net_null_ethaddr[6]; extern const u8 net_null_ethaddr[6];
@ -494,7 +493,7 @@ extern const u8 net_null_ethaddr[6];
extern ushort net_our_vlan; /* Our VLAN */ extern ushort net_our_vlan; /* Our VLAN */
extern ushort net_native_vlan; /* Our Native VLAN */ extern ushort net_native_vlan; /* Our Native VLAN */
extern int NetRestartWrap; /* Tried all network devices */ extern int net_restart_wrap; /* Tried all network devices */
enum proto_t { enum proto_t {
BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP, BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP,
@ -534,7 +533,7 @@ static inline int is_cdp_packet(const uchar *ethaddr)
#if defined(CONFIG_CMD_SNTP) #if defined(CONFIG_CMD_SNTP)
extern struct in_addr net_ntp_server; /* the ip address to NTP */ extern struct in_addr net_ntp_server; /* the ip address to NTP */
extern int NetTimeOffset; /* offset time from UTC */ extern int net_ntp_time_offset; /* offset time from UTC */
#endif #endif
#if defined(CONFIG_MCAST_TFTP) #if defined(CONFIG_MCAST_TFTP)
@ -543,13 +542,10 @@ extern struct in_addr net_mcast_addr;
/* Initialize the network adapter */ /* Initialize the network adapter */
void net_init(void); void net_init(void);
int NetLoop(enum proto_t); int net_loop(enum proto_t);
/* Shutdown adapters and cleanup */
void NetStop(void);
/* Load failed. Start again. */ /* Load failed. Start again. */
int NetStartAgain(void); int net_start_again(void);
/* Get size of the ethernet header when we send */ /* Get size of the ethernet header when we send */
int net_eth_hdr_size(void); int net_eth_hdr_size(void);
@ -599,7 +595,7 @@ void net_set_udp_handler(rxhand_f *); /* Set UDP RX packet handler */
rxhand_f *net_get_arp_handler(void); /* Get ARP RX packet handler */ rxhand_f *net_get_arp_handler(void); /* Get ARP RX packet handler */
void net_set_arp_handler(rxhand_f *); /* Set ARP RX packet handler */ void net_set_arp_handler(rxhand_f *); /* Set ARP RX packet handler */
void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */ void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */
void NetSetTimeout(ulong, thand_f *);/* Set timeout handler */ void net_set_timeout_handler(ulong, thand_f *);/* Set timeout handler */
/* Network loop state */ /* Network loop state */
enum net_loop_state { enum net_loop_state {
@ -688,7 +684,7 @@ static inline struct in_addr net_read_ip(void *from)
} }
/* return ulong *in network byteorder* */ /* return ulong *in network byteorder* */
static inline ulong NetReadLong(ulong *from) static inline ulong net_read_long(ulong *from)
{ {
ulong l; ulong l;
@ -709,7 +705,7 @@ static inline void net_copy_ip(void *to, void *from)
} }
/* copy ulong */ /* copy ulong */
static inline void NetCopyLong(ulong *to, ulong *from) static inline void net_copy_long(ulong *to, ulong *from)
{ {
memcpy((void *)to, (void *)from, sizeof(ulong)); memcpy((void *)to, (void *)from, sizeof(ulong));
} }

View file

@ -112,7 +112,7 @@ void arp_timeout_check(void)
if (arp_wait_try >= ARP_TIMEOUT_COUNT) { if (arp_wait_try >= ARP_TIMEOUT_COUNT) {
puts("\nARP Retry count exceeded; starting again\n"); puts("\nARP Retry count exceeded; starting again\n");
arp_wait_try = 0; arp_wait_try = 0;
NetStartAgain(); net_start_again();
} else { } else {
arp_wait_timer_start = t; arp_wait_timer_start = t;
arp_request(); arp_request();

View file

@ -128,7 +128,7 @@ static int check_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len)
retval = -4; retval = -4;
else if (bp->bp_hlen != HWL_ETHER) else if (bp->bp_hlen != HWL_ETHER)
retval = -5; retval = -5;
else if (!bootp_match_id(NetReadLong((ulong *)&bp->bp_id))) else if (!bootp_match_id(net_read_long((ulong *)&bp->bp_id)))
retval = -6; retval = -6;
debug("Filtering pkt = %d\n", retval); debug("Filtering pkt = %d\n", retval);
@ -356,10 +356,11 @@ static void bootp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
store_net_params(bp); /* Store net parameters from reply */ store_net_params(bp); /* Store net parameters from reply */
/* Retrieve extended information (we must parse the vendor area) */ /* Retrieve extended information (we must parse the vendor area) */
if (NetReadLong((ulong *)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC)) if (net_read_long((ulong *)&bp->bp_vend[0]) ==
htonl(BOOTP_VENDOR_MAGIC))
bootp_process_vendor((uchar *)&bp->bp_vend[4], len); bootp_process_vendor((uchar *)&bp->bp_vend[4], len);
NetSetTimeout(0, (thand_f *)0); net_set_timeout_handler(0, (thand_f *)0);
bootstage_mark_name(BOOTSTAGE_ID_BOOTP_STOP, "bootp_stop"); bootstage_mark_name(BOOTSTAGE_ID_BOOTP_STOP, "bootp_stop");
debug("Got good BOOTP\n"); debug("Got good BOOTP\n");
@ -381,13 +382,13 @@ static void bootp_timeout_handler(void)
net_set_state(NETLOOP_FAIL); net_set_state(NETLOOP_FAIL);
#else #else
puts("\nRetry time exceeded; starting again\n"); puts("\nRetry time exceeded; starting again\n");
NetStartAgain(); net_start_again();
#endif #endif
} else { } else {
bootp_timeout *= 2; bootp_timeout *= 2;
if (bootp_timeout > 2000) if (bootp_timeout > 2000)
bootp_timeout = 2000; bootp_timeout = 2000;
NetSetTimeout(bootp_timeout, bootp_timeout_handler); net_set_timeout_handler(bootp_timeout, bootp_timeout_handler);
bootp_request(); bootp_request();
} }
} }
@ -740,7 +741,7 @@ void bootp_request(void)
bootp_id += get_timer(0); bootp_id += get_timer(0);
bootp_id = htonl(bootp_id); bootp_id = htonl(bootp_id);
bootp_add_id(bootp_id); bootp_add_id(bootp_id);
NetCopyLong(&bp->bp_id, &bootp_id); net_copy_long(&bp->bp_id, &bootp_id);
/* /*
* Calculate proper packet lengths taking into account the * Calculate proper packet lengths taking into account the
@ -750,7 +751,7 @@ void bootp_request(void)
pktlen = eth_hdr_size + IP_UDP_HDR_SIZE + iplen; pktlen = eth_hdr_size + IP_UDP_HDR_SIZE + iplen;
bcast_ip.s_addr = 0xFFFFFFFFL; bcast_ip.s_addr = 0xFFFFFFFFL;
net_set_udp_header(iphdr, bcast_ip, PORT_BOOTPS, PORT_BOOTPC, iplen); net_set_udp_header(iphdr, bcast_ip, PORT_BOOTPS, PORT_BOOTPC, iplen);
NetSetTimeout(bootp_timeout, bootp_timeout_handler); net_set_timeout_handler(bootp_timeout, bootp_timeout_handler);
#if defined(CONFIG_CMD_DHCP) #if defined(CONFIG_CMD_DHCP)
dhcp_state = SELECTING; dhcp_state = SELECTING;
@ -778,9 +779,9 @@ static void dhcp_process_options(uchar *popt, struct bootp_hdr *bp)
break; break;
#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET) #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET)
case 2: /* Time offset */ case 2: /* Time offset */
to_ptr = &NetTimeOffset; to_ptr = &net_ntp_time_offset;
NetCopyLong((ulong *)to_ptr, (ulong *)(popt + 2)); net_copy_long((ulong *)to_ptr, (ulong *)(popt + 2));
NetTimeOffset = ntohl(NetTimeOffset); net_ntp_time_offset = ntohl(net_ntp_time_offset);
break; break;
#endif #endif
case 3: case 3:
@ -815,7 +816,7 @@ static void dhcp_process_options(uchar *popt, struct bootp_hdr *bp)
break; break;
#endif #endif
case 51: case 51:
NetCopyLong(&dhcp_leasetime, (ulong *) (popt + 2)); net_copy_long(&dhcp_leasetime, (ulong *)(popt + 2));
break; break;
case 53: /* Ignore Message Type Option */ case 53: /* Ignore Message Type Option */
break; break;
@ -869,7 +870,7 @@ static void dhcp_process_options(uchar *popt, struct bootp_hdr *bp)
static int dhcp_message_type(unsigned char *popt) static int dhcp_message_type(unsigned char *popt)
{ {
if (NetReadLong((ulong *)popt) != htonl(BOOTP_VENDOR_MAGIC)) if (net_read_long((ulong *)popt) != htonl(BOOTP_VENDOR_MAGIC))
return -1; return -1;
popt += 4; popt += 4;
@ -923,7 +924,7 @@ static void dhcp_send_request_packet(struct bootp_hdr *bp_offer)
* ID is the id of the OFFER packet * ID is the id of the OFFER packet
*/ */
NetCopyLong(&bp->bp_id, &bp_offer->bp_id); net_copy_long(&bp->bp_id, &bp_offer->bp_id);
/* /*
* Copy options from OFFER packet if present * Copy options from OFFER packet if present
@ -982,11 +983,11 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
debug("TRANSITIONING TO REQUESTING STATE\n"); debug("TRANSITIONING TO REQUESTING STATE\n");
dhcp_state = REQUESTING; dhcp_state = REQUESTING;
if (NetReadLong((ulong *)&bp->bp_vend[0]) == if (net_read_long((ulong *)&bp->bp_vend[0]) ==
htonl(BOOTP_VENDOR_MAGIC)) htonl(BOOTP_VENDOR_MAGIC))
dhcp_process_options((u8 *)&bp->bp_vend[4], bp); dhcp_process_options((u8 *)&bp->bp_vend[4], bp);
NetSetTimeout(5000, bootp_timeout_handler); net_set_timeout_handler(5000, bootp_timeout_handler);
dhcp_send_request_packet(bp); dhcp_send_request_packet(bp);
#ifdef CONFIG_SYS_BOOTFILE_PREFIX #ifdef CONFIG_SYS_BOOTFILE_PREFIX
} }
@ -998,7 +999,7 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
debug("DHCP State: REQUESTING\n"); debug("DHCP State: REQUESTING\n");
if (dhcp_message_type((u8 *)bp->bp_vend) == DHCP_ACK) { if (dhcp_message_type((u8 *)bp->bp_vend) == DHCP_ACK) {
if (NetReadLong((ulong *)&bp->bp_vend[0]) == if (net_read_long((ulong *)&bp->bp_vend[0]) ==
htonl(BOOTP_VENDOR_MAGIC)) htonl(BOOTP_VENDOR_MAGIC))
dhcp_process_options((u8 *)&bp->bp_vend[4], bp); dhcp_process_options((u8 *)&bp->bp_vend[4], bp);
/* Store net params from reply */ /* Store net params from reply */

View file

@ -224,14 +224,14 @@ static void cdp_timeout_handler(void)
cdp_seq++; cdp_seq++;
if (cdp_seq < 3) { if (cdp_seq < 3) {
NetSetTimeout(CDP_TIMEOUT, cdp_timeout_handler); net_set_timeout_handler(CDP_TIMEOUT, cdp_timeout_handler);
cdp_send_trigger(); cdp_send_trigger();
return; return;
} }
/* if not OK try again */ /* if not OK try again */
if (!cdp_ok) if (!cdp_ok)
NetStartAgain(); net_start_again();
else else
net_set_state(NETLOOP_SUCCESS); net_set_state(NETLOOP_SUCCESS);
} }
@ -357,7 +357,7 @@ void cdp_start(void)
cdp_native_vlan = htons(-1); cdp_native_vlan = htons(-1);
cdp_appliance_vlan = htons(-1); cdp_appliance_vlan = htons(-1);
NetSetTimeout(CDP_TIMEOUT, cdp_timeout_handler); net_set_timeout_handler(CDP_TIMEOUT, cdp_timeout_handler);
cdp_send_trigger(); cdp_send_trigger();
} }

View file

@ -197,7 +197,7 @@ void dns_start(void)
{ {
debug("%s\n", __func__); debug("%s\n", __func__);
NetSetTimeout(DNS_TIMEOUT, dns_timeout_handler); net_set_timeout_handler(DNS_TIMEOUT, dns_timeout_handler);
net_set_udp_handler(dns_handler); net_set_udp_handler(dns_handler);
/* Clear a previous MAC address, the server IP might have changed. */ /* Clear a previous MAC address, the server IP might have changed. */

View file

@ -965,7 +965,7 @@ void eth_try_another(int first_restart)
eth_current_changed(); eth_current_changed();
if (first_failed == eth_get_dev()) if (first_failed == eth_get_dev())
NetRestartWrap = 1; net_restart_wrap = 1;
} }
void eth_set_current(void) void eth_set_current(void)

View file

@ -99,7 +99,7 @@ static void configure_wait(void)
debug_cond(DEBUG_DEV_PKT, "...wait %d %s nprobes=%u, nclaims=%u\n", debug_cond(DEBUG_DEV_PKT, "...wait %d %s nprobes=%u, nclaims=%u\n",
timeout_ms, eth_get_name(), nprobes, nclaims); timeout_ms, eth_get_name(), nprobes, nclaims);
NetSetTimeout(timeout_ms, link_local_timeout); net_set_timeout_handler(timeout_ms, link_local_timeout);
} }
void link_local_start(void) void link_local_start(void)
@ -182,7 +182,7 @@ static void link_local_timeout(void)
conflicts = 0; conflicts = 0;
timeout_ms = -1; timeout_ms = -1;
/* Never timeout in the monitor state */ /* Never timeout in the monitor state */
NetSetTimeout(0, NULL); net_set_timeout_handler(0, NULL);
/* NOTE: all other exit paths should deconfig ... */ /* NOTE: all other exit paths should deconfig ... */
net_set_state(NETLOOP_SUCCESS); net_set_state(NETLOOP_SUCCESS);

181
net/net.c
View file

@ -141,21 +141,21 @@ uchar *net_rx_packet;
/* Current rx packet length */ /* Current rx packet length */
int net_rx_packet_len; int net_rx_packet_len;
/* IP packet ID */ /* IP packet ID */
unsigned NetIPID; static unsigned net_ip_id;
/* Ethernet bcast address */ /* Ethernet bcast address */
const u8 net_bcast_ethaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; const u8 net_bcast_ethaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
const u8 net_null_ethaddr[6]; const u8 net_null_ethaddr[6];
#ifdef CONFIG_API #ifdef CONFIG_API
void (*push_packet)(void *, int len) = 0; void (*push_packet)(void *, int len) = 0;
#endif #endif
/* Network loop state */ /* Network loop state */
enum net_loop_state net_state; enum net_loop_state net_state;
/* Tried all network devices */ /* Tried all network devices */
int NetRestartWrap; int net_restart_wrap;
/* Network loop restarted */ /* Network loop restarted */
static int NetRestarted; static int net_restarted;
/* At least one device configured */ /* At least one device configured */
static int NetDevExists; static int net_dev_exists;
/* XXX in both little & big endian machines 0xFFFF == ntohs(-1) */ /* XXX in both little & big endian machines 0xFFFF == ntohs(-1) */
/* default is without VLAN */ /* default is without VLAN */
@ -174,7 +174,7 @@ u32 net_boot_file_expected_size_in_blocks;
/* NTP server IP address */ /* NTP server IP address */
struct in_addr net_ntp_server; struct in_addr net_ntp_server;
/* offset time from UTC */ /* offset time from UTC */
int NetTimeOffset; int net_ntp_time_offset;
#endif #endif
static uchar net_pkt_buf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN]; static uchar net_pkt_buf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];
@ -189,17 +189,17 @@ static rxhand_f *arp_packet_handler;
static rxhand_icmp_f *packet_icmp_handler; static rxhand_icmp_f *packet_icmp_handler;
#endif #endif
/* Current timeout handler */ /* Current timeout handler */
static thand_f *timeHandler; static thand_f *time_handler;
/* Time base value */ /* Time base value */
static ulong timeStart; static ulong time_start;
/* Current timeout value */ /* Current timeout value */
static ulong timeDelta; static ulong time_delta;
/* THE transmit packet */ /* THE transmit packet */
uchar *net_tx_packet; uchar *net_tx_packet;
static int net_check_prereq(enum proto_t protocol); static int net_check_prereq(enum proto_t protocol);
static int NetTryCount; static int net_try_count;
int __maybe_unused net_busy_flag; int __maybe_unused net_busy_flag;
@ -250,7 +250,7 @@ void net_auto_load(void)
tftp_start(TFTPGET); tftp_start(TFTPGET);
} }
static void NetInitLoop(void) static void net_init_loop(void)
{ {
static int env_changed_id; static int env_changed_id;
int env_id = get_env_id(); int env_id = get_env_id();
@ -278,7 +278,7 @@ static void net_clear_handlers(void)
{ {
net_set_udp_handler(NULL); net_set_udp_handler(NULL);
net_set_arp_handler(NULL); net_set_arp_handler(NULL);
NetSetTimeout(0, NULL); net_set_timeout_handler(0, NULL);
} }
static void net_cleanup_loop(void) static void net_cleanup_loop(void)
@ -309,7 +309,7 @@ void net_init(void)
first_call = 0; first_call = 0;
} }
NetInitLoop(); net_init_loop();
} }
/**********************************************************************/ /**********************************************************************/
@ -317,14 +317,14 @@ void net_init(void)
* Main network processing loop. * Main network processing loop.
*/ */
int NetLoop(enum proto_t protocol) int net_loop(enum proto_t protocol)
{ {
int ret = -EINVAL; int ret = -EINVAL;
NetRestarted = 0; net_restarted = 0;
NetDevExists = 0; net_dev_exists = 0;
NetTryCount = 1; net_try_count = 1;
debug_cond(DEBUG_INT_STATE, "--- NetLoop Entry\n"); debug_cond(DEBUG_INT_STATE, "--- net_loop Entry\n");
bootstage_mark_name(BOOTSTAGE_ID_ETH_START, "eth_start"); bootstage_mark_name(BOOTSTAGE_ID_ETH_START, "eth_start");
net_init(); net_init();
@ -336,9 +336,9 @@ int NetLoop(enum proto_t protocol)
eth_halt(); eth_halt();
return ret; return ret;
} }
} else } else {
eth_init_state_only(); eth_init_state_only();
}
restart: restart:
#ifdef CONFIG_USB_KEYBOARD #ifdef CONFIG_USB_KEYBOARD
net_busy_flag = 0; net_busy_flag = 0;
@ -350,8 +350,8 @@ restart:
* here on, this code is a state machine driven by received * here on, this code is a state machine driven by received
* packets and timer events. * packets and timer events.
*/ */
debug_cond(DEBUG_INT_STATE, "--- NetLoop Init\n"); debug_cond(DEBUG_INT_STATE, "--- net_loop Init\n");
NetInitLoop(); net_init_loop();
switch (net_check_prereq(protocol)) { switch (net_check_prereq(protocol)) {
case 1: case 1:
@ -364,7 +364,7 @@ restart:
break; break;
case 0: case 0:
NetDevExists = 1; net_dev_exists = 1;
net_boot_file_size = 0; net_boot_file_size = 0;
switch (protocol) { switch (protocol) {
case TFTPGET: case TFTPGET:
@ -415,7 +415,7 @@ restart:
cdp_start(); cdp_start();
break; break;
#endif #endif
#if defined (CONFIG_NETCONSOLE) && !(CONFIG_SPL_BUILD) #if defined(CONFIG_NETCONSOLE) && !(CONFIG_SPL_BUILD)
case NETCONS: case NETCONS:
nc_start(); nc_start();
break; break;
@ -491,7 +491,7 @@ restart:
puts("\nAbort\n"); puts("\nAbort\n");
/* include a debug print as well incase the debug /* include a debug print as well incase the debug
messages are directed to stderr */ messages are directed to stderr */
debug_cond(DEBUG_INT_STATE, "--- NetLoop Abort!\n"); debug_cond(DEBUG_INT_STATE, "--- net_loop Abort!\n");
goto done; goto done;
} }
@ -501,7 +501,8 @@ restart:
* Check for a timeout, and run the timeout handler * Check for a timeout, and run the timeout handler
* if we have one. * if we have one.
*/ */
if (timeHandler && ((get_timer(0) - timeStart) > timeDelta)) { if (time_handler &&
((get_timer(0) - time_start) > time_delta)) {
thand_f *x; thand_f *x;
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
@ -512,26 +513,24 @@ restart:
* Echo the inverted link state to the fault LED. * Echo the inverted link state to the fault LED.
*/ */
if (miiphy_link(eth_get_dev()->name, if (miiphy_link(eth_get_dev()->name,
CONFIG_SYS_FAULT_MII_ADDR)) { CONFIG_SYS_FAULT_MII_ADDR))
status_led_set(STATUS_LED_RED, STATUS_LED_OFF); status_led_set(STATUS_LED_RED, STATUS_LED_OFF);
} else { else
status_led_set(STATUS_LED_RED, STATUS_LED_ON); status_led_set(STATUS_LED_RED, STATUS_LED_ON);
}
#endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */ #endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */
#endif /* CONFIG_MII, ... */ #endif /* CONFIG_MII, ... */
debug_cond(DEBUG_INT_STATE, "--- NetLoop timeout\n"); debug_cond(DEBUG_INT_STATE, "--- net_loop timeout\n");
x = timeHandler; x = time_handler;
timeHandler = (thand_f *)0; time_handler = (thand_f *)0;
(*x)(); (*x)();
} }
if (net_state == NETLOOP_FAIL) if (net_state == NETLOOP_FAIL)
ret = NetStartAgain(); ret = net_start_again();
switch (net_state) { switch (net_state) {
case NETLOOP_RESTART: case NETLOOP_RESTART:
NetRestarted = 1; net_restarted = 1;
goto restart; goto restart;
case NETLOOP_SUCCESS: case NETLOOP_SUCCESS:
@ -550,14 +549,14 @@ restart:
eth_set_last_protocol(protocol); eth_set_last_protocol(protocol);
ret = net_boot_file_size; ret = net_boot_file_size;
debug_cond(DEBUG_INT_STATE, "--- NetLoop Success!\n"); debug_cond(DEBUG_INT_STATE, "--- net_loop Success!\n");
goto done; goto done;
case NETLOOP_FAIL: case NETLOOP_FAIL:
net_cleanup_loop(); net_cleanup_loop();
/* Invalidate the last protocol */ /* Invalidate the last protocol */
eth_set_last_protocol(BOOTP); eth_set_last_protocol(BOOTP);
debug_cond(DEBUG_INT_STATE, "--- NetLoop Fail!\n"); debug_cond(DEBUG_INT_STATE, "--- net_loop Fail!\n");
goto done; goto done;
case NETLOOP_CONTINUE: case NETLOOP_CONTINUE:
@ -579,13 +578,12 @@ done:
/**********************************************************************/ /**********************************************************************/
static void static void start_again_timeout_handler(void)
startAgainTimeout(void)
{ {
net_set_state(NETLOOP_RESTART); net_set_state(NETLOOP_RESTART);
} }
int NetStartAgain(void) int net_start_again(void)
{ {
char *nretry; char *nretry;
int retry_forever = 0; int retry_forever = 0;
@ -607,7 +605,7 @@ int NetStartAgain(void)
retry_forever = 0; retry_forever = 0;
} }
if ((!retry_forever) && (NetTryCount >= retrycnt)) { if ((!retry_forever) && (net_try_count >= retrycnt)) {
eth_halt(); eth_halt();
net_set_state(NETLOOP_FAIL); net_set_state(NETLOOP_FAIL);
/* /*
@ -617,17 +615,18 @@ int NetStartAgain(void)
return -ETIMEDOUT; return -ETIMEDOUT;
} }
NetTryCount++; net_try_count++;
eth_halt(); eth_halt();
#if !defined(CONFIG_NET_DO_NOT_TRY_ANOTHER) #if !defined(CONFIG_NET_DO_NOT_TRY_ANOTHER)
eth_try_another(!NetRestarted); eth_try_another(!net_restarted);
#endif #endif
ret = eth_init(); ret = eth_init();
if (NetRestartWrap) { if (net_restart_wrap) {
NetRestartWrap = 0; net_restart_wrap = 0;
if (NetDevExists) { if (net_dev_exists) {
NetSetTimeout(10000UL, startAgainTimeout); net_set_timeout_handler(10000UL,
start_again_timeout_handler);
net_set_udp_handler(NULL); net_set_udp_handler(NULL);
} else { } else {
net_set_state(NETLOOP_FAIL); net_set_state(NETLOOP_FAIL);
@ -656,7 +655,7 @@ rxhand_f *net_get_udp_handler(void)
void net_set_udp_handler(rxhand_f *f) void net_set_udp_handler(rxhand_f *f)
{ {
debug_cond(DEBUG_INT_STATE, "--- NetLoop UDP handler set (%p)\n", f); debug_cond(DEBUG_INT_STATE, "--- net_loop UDP handler set (%p)\n", f);
if (f == NULL) if (f == NULL)
udp_packet_handler = dummy_handler; udp_packet_handler = dummy_handler;
else else
@ -670,7 +669,7 @@ rxhand_f *net_get_arp_handler(void)
void net_set_arp_handler(rxhand_f *f) void net_set_arp_handler(rxhand_f *f)
{ {
debug_cond(DEBUG_INT_STATE, "--- NetLoop ARP handler set (%p)\n", f); debug_cond(DEBUG_INT_STATE, "--- net_loop ARP handler set (%p)\n", f);
if (f == NULL) if (f == NULL)
arp_packet_handler = dummy_handler; arp_packet_handler = dummy_handler;
else else
@ -684,19 +683,18 @@ void net_set_icmp_handler(rxhand_icmp_f *f)
} }
#endif #endif
void void net_set_timeout_handler(ulong iv, thand_f *f)
NetSetTimeout(ulong iv, thand_f *f)
{ {
if (iv == 0) { if (iv == 0) {
debug_cond(DEBUG_INT_STATE, debug_cond(DEBUG_INT_STATE,
"--- NetLoop timeout handler cancelled\n"); "--- net_loop timeout handler cancelled\n");
timeHandler = (thand_f *)0; time_handler = (thand_f *)0;
} else { } else {
debug_cond(DEBUG_INT_STATE, debug_cond(DEBUG_INT_STATE,
"--- NetLoop timeout handler set (%p)\n", f); "--- net_loop timeout handler set (%p)\n", f);
timeHandler = f; time_handler = f;
timeStart = get_timer(0); time_start = get_timer(0);
timeDelta = iv * CONFIG_SYS_HZ / 1000; time_delta = iv * CONFIG_SYS_HZ / 1000;
} }
} }
@ -707,7 +705,7 @@ int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport, int sport,
int eth_hdr_size; int eth_hdr_size;
int pkt_hdr_size; int pkt_hdr_size;
/* make sure the net_tx_packet is initialized (NetInit() was called) */ /* make sure the net_tx_packet is initialized (net_init() was called) */
assert(net_tx_packet != NULL); assert(net_tx_packet != NULL);
if (net_tx_packet == NULL) if (net_tx_packet == NULL)
return -1; return -1;
@ -745,7 +743,7 @@ int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport, int sport,
return 1; /* waiting */ return 1; /* waiting */
} else { } else {
debug_cond(DEBUG_DEV_PKT, "sending UDP to %pI4/%pM\n", debug_cond(DEBUG_DEV_PKT, "sending UDP to %pI4/%pM\n",
&dest, ether); &dest, ether);
net_send_packet(net_tx_packet, pkt_hdr_size + payload_len); net_send_packet(net_tx_packet, pkt_hdr_size + payload_len);
return 0; /* transmitted */ return 0; /* transmitted */
} }
@ -784,7 +782,7 @@ struct hole {
u16 unused; u16 unused;
}; };
static struct ip_udp_hdr *__NetDefragment(struct ip_udp_hdr *ip, int *lenp) static struct ip_udp_hdr *__net_defragment(struct ip_udp_hdr *ip, int *lenp)
{ {
static uchar pkt_buff[IP_PKTSIZE] __aligned(PKTALIGN); static uchar pkt_buff[IP_PKTSIZE] __aligned(PKTALIGN);
static u16 first_hole, total_len; static u16 first_hole, total_len;
@ -904,17 +902,19 @@ static struct ip_udp_hdr *__NetDefragment(struct ip_udp_hdr *ip, int *lenp)
return localip; return localip;
} }
static inline struct ip_udp_hdr *NetDefragment(struct ip_udp_hdr *ip, int *lenp) static inline struct ip_udp_hdr *net_defragment(struct ip_udp_hdr *ip,
int *lenp)
{ {
u16 ip_off = ntohs(ip->ip_off); u16 ip_off = ntohs(ip->ip_off);
if (!(ip_off & (IP_OFFS | IP_FLAGS_MFRAG))) if (!(ip_off & (IP_OFFS | IP_FLAGS_MFRAG)))
return ip; /* not a fragment */ return ip; /* not a fragment */
return __NetDefragment(ip, lenp); return __net_defragment(ip, lenp);
} }
#else /* !CONFIG_IP_DEFRAG */ #else /* !CONFIG_IP_DEFRAG */
static inline struct ip_udp_hdr *NetDefragment(struct ip_udp_hdr *ip, int *lenp) static inline struct ip_udp_hdr *net_defragment(struct ip_udp_hdr *ip,
int *lenp)
{ {
u16 ip_off = ntohs(ip->ip_off); u16 ip_off = ntohs(ip->ip_off);
if (!(ip_off & (IP_OFFS | IP_FLAGS_MFRAG))) if (!(ip_off & (IP_OFFS | IP_FLAGS_MFRAG)))
@ -939,7 +939,7 @@ static void receive_icmp(struct ip_udp_hdr *ip, int len,
if (icmph->code != ICMP_REDIR_HOST) if (icmph->code != ICMP_REDIR_HOST)
return; return;
printf(" ICMP Host Redirect to %pI4 ", printf(" ICMP Host Redirect to %pI4 ",
&icmph->un.gateway); &icmph->un.gateway);
break; break;
default: default:
#if defined(CONFIG_CMD_PING) #if defined(CONFIG_CMD_PING)
@ -948,8 +948,9 @@ static void receive_icmp(struct ip_udp_hdr *ip, int len,
#ifdef CONFIG_CMD_TFTPPUT #ifdef CONFIG_CMD_TFTPPUT
if (packet_icmp_handler) if (packet_icmp_handler)
packet_icmp_handler(icmph->type, icmph->code, packet_icmp_handler(icmph->type, icmph->code,
ntohs(ip->udp_dst), src_ip, ntohs(ip->udp_src), ntohs(ip->udp_dst), src_ip,
icmph->un.data, ntohs(ip->udp_len)); ntohs(ip->udp_src), icmph->un.data,
ntohs(ip->udp_len));
#endif #endif
break; break;
} }
@ -1057,7 +1058,6 @@ void net_process_received_packet(uchar *in_packet, int len)
} }
switch (eth_proto) { switch (eth_proto) {
case PROT_ARP: case PROT_ARP:
arp_receive(et, ip, len); arp_receive(et, ip, len);
break; break;
@ -1072,7 +1072,7 @@ void net_process_received_packet(uchar *in_packet, int len)
/* Before we start poking the header, make sure it is there */ /* Before we start poking the header, make sure it is there */
if (len < IP_UDP_HDR_SIZE) { if (len < IP_UDP_HDR_SIZE) {
debug("len bad %d < %lu\n", len, debug("len bad %d < %lu\n", len,
(ulong)IP_UDP_HDR_SIZE); (ulong)IP_UDP_HDR_SIZE);
return; return;
} }
/* Check the packet length */ /* Check the packet length */
@ -1082,7 +1082,7 @@ void net_process_received_packet(uchar *in_packet, int len)
} }
len = ntohs(ip->ip_len); len = ntohs(ip->ip_len);
debug_cond(DEBUG_NET_PKT, "len=%d, v=%02x\n", debug_cond(DEBUG_NET_PKT, "len=%d, v=%02x\n",
len, ip->ip_hl_v & 0xff); len, ip->ip_hl_v & 0xff);
/* Can't deal with anything except IPv4 */ /* Can't deal with anything except IPv4 */
if ((ip->ip_hl_v & 0xf0) != 0x40) if ((ip->ip_hl_v & 0xf0) != 0x40)
@ -1111,7 +1111,7 @@ void net_process_received_packet(uchar *in_packet, int len)
* a fragment, and either the complete packet or NULL if * a fragment, and either the complete packet or NULL if
* it is a fragment (if !CONFIG_IP_DEFRAG, it returns NULL) * it is a fragment (if !CONFIG_IP_DEFRAG, it returns NULL)
*/ */
ip = NetDefragment(ip, &len); ip = net_defragment(ip, &len);
if (!ip) if (!ip)
return; return;
/* /*
@ -1143,8 +1143,8 @@ void net_process_received_packet(uchar *in_packet, int len)
} }
debug_cond(DEBUG_DEV_PKT, debug_cond(DEBUG_DEV_PKT,
"received UDP (to=%pI4, from=%pI4, len=%d)\n", "received UDP (to=%pI4, from=%pI4, len=%d)\n",
&dst_ip, &src_ip, len); &dst_ip, &src_ip, len);
#ifdef CONFIG_UDP_CHECKSUM #ifdef CONFIG_UDP_CHECKSUM
if (ip->udp_xsum != 0) { if (ip->udp_xsum != 0) {
@ -1160,7 +1160,7 @@ void net_process_received_packet(uchar *in_packet, int len)
xsum += (ntohl(ip->ip_dst.s_addr) >> 0) & 0x0000ffff; xsum += (ntohl(ip->ip_dst.s_addr) >> 0) & 0x0000ffff;
sumlen = ntohs(ip->udp_len); sumlen = ntohs(ip->udp_len);
sumptr = (ushort *) &(ip->udp_src); sumptr = (ushort *)&(ip->udp_src);
while (sumlen > 1) { while (sumlen > 1) {
ushort sumdata; ushort sumdata;
@ -1172,7 +1172,7 @@ void net_process_received_packet(uchar *in_packet, int len)
if (sumlen > 0) { if (sumlen > 0) {
ushort sumdata; ushort sumdata;
sumdata = *(unsigned char *) sumptr; sumdata = *(unsigned char *)sumptr;
sumdata = (sumdata << 8) & 0xff00; sumdata = (sumdata << 8) & 0xff00;
xsum += sumdata; xsum += sumdata;
} }
@ -1182,33 +1182,31 @@ void net_process_received_packet(uchar *in_packet, int len)
} }
if ((xsum != 0x00000000) && (xsum != 0x0000ffff)) { if ((xsum != 0x00000000) && (xsum != 0x0000ffff)) {
printf(" UDP wrong checksum %08lx %08x\n", printf(" UDP wrong checksum %08lx %08x\n",
xsum, ntohs(ip->udp_xsum)); xsum, ntohs(ip->udp_xsum));
return; return;
} }
} }
#endif #endif
#if defined(CONFIG_NETCONSOLE) && !(CONFIG_SPL_BUILD)
#if defined (CONFIG_NETCONSOLE) && !(CONFIG_SPL_BUILD)
nc_input_packet((uchar *)ip + IP_UDP_HDR_SIZE, nc_input_packet((uchar *)ip + IP_UDP_HDR_SIZE,
src_ip,
ntohs(ip->udp_dst),
ntohs(ip->udp_src),
ntohs(ip->udp_len) - UDP_HDR_SIZE);
#endif
/*
* IP header OK. Pass the packet to the current handler.
*/
(*udp_packet_handler)((uchar *)ip + IP_UDP_HDR_SIZE,
ntohs(ip->udp_dst),
src_ip, src_ip,
ntohs(ip->udp_dst),
ntohs(ip->udp_src), ntohs(ip->udp_src),
ntohs(ip->udp_len) - UDP_HDR_SIZE); ntohs(ip->udp_len) - UDP_HDR_SIZE);
#endif
/*
* IP header OK. Pass the packet to the current handler.
*/
(*udp_packet_handler)((uchar *)ip + IP_UDP_HDR_SIZE,
ntohs(ip->udp_dst),
src_ip,
ntohs(ip->udp_src),
ntohs(ip->udp_len) - UDP_HDR_SIZE);
break; break;
} }
} }
/**********************************************************************/ /**********************************************************************/
static int net_check_prereq(enum proto_t protocol) static int net_check_prereq(enum proto_t protocol)
@ -1242,6 +1240,7 @@ static int net_check_prereq(enum proto_t protocol)
#if defined(CONFIG_CMD_NFS) #if defined(CONFIG_CMD_NFS)
case NFS: case NFS:
#endif #endif
/* Fall through */
case TFTPGET: case TFTPGET:
case TFTPPUT: case TFTPPUT:
if (net_server_ip.s_addr == 0) { if (net_server_ip.s_addr == 0) {
@ -1281,11 +1280,11 @@ common:
break; break;
default: default:
printf("*** ERROR: `eth%daddr' not set\n", printf("*** ERROR: `eth%daddr' not set\n",
num); num);
break; break;
} }
NetStartAgain(); net_start_again();
return 2; return 2;
} }
/* Fall through */ /* Fall through */
@ -1368,7 +1367,7 @@ void net_set_ip_header(uchar *pkt, struct in_addr dest, struct in_addr source)
ip->ip_hl_v = 0x45; ip->ip_hl_v = 0x45;
ip->ip_tos = 0; ip->ip_tos = 0;
ip->ip_len = htons(IP_HDR_SIZE); ip->ip_len = htons(IP_HDR_SIZE);
ip->ip_id = htons(NetIPID++); 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_ttl = 255;
ip->ip_sum = 0; ip->ip_sum = 0;

View file

@ -571,11 +571,12 @@ static void nfs_timeout_handler(void)
{ {
if (++nfs_timeout_count > NFS_RETRY_COUNT) { if (++nfs_timeout_count > NFS_RETRY_COUNT) {
puts("\nRetry count exceeded; starting again\n"); puts("\nRetry count exceeded; starting again\n");
NetStartAgain(); net_start_again();
} else { } else {
puts("T "); puts("T ");
NetSetTimeout(nfs_timeout + NFS_TIMEOUT * nfs_timeout_count, net_set_timeout_handler(nfs_timeout +
nfs_timeout_handler); NFS_TIMEOUT * nfs_timeout_count,
nfs_timeout_handler);
nfs_send(); nfs_send();
} }
} }
@ -670,7 +671,7 @@ static void nfs_handler(uchar *pkt, unsigned dest, struct in_addr sip,
case STATE_READ_REQ: case STATE_READ_REQ:
rlen = nfs_read_reply(pkt, len); rlen = nfs_read_reply(pkt, len);
NetSetTimeout(nfs_timeout, nfs_timeout_handler); net_set_timeout_handler(nfs_timeout, nfs_timeout_handler);
if (rlen > 0) { if (rlen > 0) {
nfs_offset += rlen; nfs_offset += rlen;
nfs_send(); nfs_send();
@ -756,7 +757,7 @@ void nfs_start(void)
printf("\nLoad address: 0x%lx\n" printf("\nLoad address: 0x%lx\n"
"Loading: *\b", load_addr); "Loading: *\b", load_addr);
NetSetTimeout(nfs_timeout, nfs_timeout_handler); net_set_timeout_handler(nfs_timeout, nfs_timeout_handler);
net_set_udp_handler(nfs_handler); net_set_udp_handler(nfs_handler);
nfs_timeout_count = 0; nfs_timeout_count = 0;

View file

@ -74,7 +74,7 @@ static void ping_timeout_handler(void)
void ping_start(void) void ping_start(void)
{ {
printf("Using %s device\n", eth_get_name()); printf("Using %s device\n", eth_get_name());
NetSetTimeout(10000UL, ping_timeout_handler); net_set_timeout_handler(10000UL, ping_timeout_handler);
ping_send(); ping_send();
} }

View file

@ -59,9 +59,9 @@ static void rarp_timeout_handler(void)
{ {
if (rarp_try >= TIMEOUT_COUNT) { if (rarp_try >= TIMEOUT_COUNT) {
puts("\nRetry count exceeded; starting again\n"); puts("\nRetry count exceeded; starting again\n");
NetStartAgain(); net_start_again();
} else { } else {
NetSetTimeout(TIMEOUT, rarp_timeout_handler); net_set_timeout_handler(TIMEOUT, rarp_timeout_handler);
rarp_request(); rarp_request();
} }
} }
@ -95,5 +95,5 @@ void rarp_request(void)
net_send_packet(net_tx_packet, eth_hdr_size + ARP_HDR_SIZE); net_send_packet(net_tx_packet, eth_hdr_size + ARP_HDR_SIZE);
NetSetTimeout(TIMEOUT, rarp_timeout_handler); net_set_timeout_handler(TIMEOUT, rarp_timeout_handler);
} }

View file

@ -65,7 +65,7 @@ static void sntp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
*/ */
memcpy(&seconds, &rpktp->transmit_timestamp, sizeof(ulong)); memcpy(&seconds, &rpktp->transmit_timestamp, sizeof(ulong));
to_tm(ntohl(seconds) - 2208988800UL + NetTimeOffset, &tm); to_tm(ntohl(seconds) - 2208988800UL + net_ntp_time_offset, &tm);
#if defined(CONFIG_CMD_DATE) #if defined(CONFIG_CMD_DATE)
rtc_set(&tm); rtc_set(&tm);
#endif #endif
@ -80,7 +80,7 @@ void sntp_start(void)
{ {
debug("%s\n", __func__); debug("%s\n", __func__);
NetSetTimeout(SNTP_TIMEOUT, sntp_timeout_handler); net_set_timeout_handler(SNTP_TIMEOUT, sntp_timeout_handler);
net_set_udp_handler(sntp_handler); net_set_udp_handler(sntp_handler);
memset(net_server_ethaddr, 0, sizeof(net_server_ethaddr)); memset(net_server_ethaddr, 0, sizeof(net_server_ethaddr));

View file

@ -275,7 +275,7 @@ static void restart(const char *msg)
#ifdef CONFIG_MCAST_TFTP #ifdef CONFIG_MCAST_TFTP
mcast_cleanup(); mcast_cleanup();
#endif #endif
NetStartAgain(); net_start_again();
} }
/* /*
@ -589,7 +589,7 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
printf("First block is not block 1 (%ld)\n", printf("First block is not block 1 (%ld)\n",
tftp_cur_block); tftp_cur_block);
puts("Starting again\n\n"); puts("Starting again\n\n");
NetStartAgain(); net_start_again();
break; break;
} }
} }
@ -601,7 +601,7 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
tftp_prev_block = tftp_cur_block; tftp_prev_block = tftp_cur_block;
timeout_count_max = TIMEOUT_COUNT; timeout_count_max = TIMEOUT_COUNT;
NetSetTimeout(timeout_ms, tftp_timeout_handler); net_set_timeout_handler(timeout_ms, tftp_timeout_handler);
store_block(tftp_cur_block - 1, pkt + 2, len); store_block(tftp_cur_block - 1, pkt + 2, len);
@ -628,7 +628,7 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
/* try to double it and retry */ /* try to double it and retry */
tftp_mcast_bitmap_size <<= 1; tftp_mcast_bitmap_size <<= 1;
mcast_cleanup(); mcast_cleanup();
NetStartAgain(); net_start_again();
return; return;
} }
tftp_prev_block = tftp_cur_block; tftp_prev_block = tftp_cur_block;
@ -672,7 +672,7 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
#ifdef CONFIG_MCAST_TFTP #ifdef CONFIG_MCAST_TFTP
mcast_cleanup(); mcast_cleanup();
#endif #endif
NetStartAgain(); net_start_again();
break; break;
} }
break; break;
@ -686,7 +686,7 @@ static void tftp_timeout_handler(void)
restart("Retry count exceeded"); restart("Retry count exceeded");
} else { } else {
puts("T "); puts("T ");
NetSetTimeout(timeout_ms, tftp_timeout_handler); net_set_timeout_handler(timeout_ms, tftp_timeout_handler);
if (tftp_state != STATE_RECV_WRQ) if (tftp_state != STATE_RECV_WRQ)
tftp_send(); tftp_send();
} }
@ -794,7 +794,7 @@ void tftp_start(enum proto_t protocol)
time_start = get_timer(0); time_start = get_timer(0);
timeout_count_max = tftp_timeout_count_max; timeout_count_max = tftp_timeout_count_max;
NetSetTimeout(timeout_ms, tftp_timeout_handler); net_set_timeout_handler(timeout_ms, tftp_timeout_handler);
net_set_udp_handler(tftp_handler); net_set_udp_handler(tftp_handler);
#ifdef CONFIG_CMD_TFTPPUT #ifdef CONFIG_CMD_TFTPPUT
net_set_icmp_handler(icmp_handler); net_set_icmp_handler(icmp_handler);
@ -843,7 +843,7 @@ void tftp_start_server(void)
timeout_count_max = TIMEOUT_COUNT; timeout_count_max = TIMEOUT_COUNT;
timeout_count = 0; timeout_count = 0;
timeout_ms = TIMEOUT; timeout_ms = TIMEOUT;
NetSetTimeout(timeout_ms, tftp_timeout_handler); net_set_timeout_handler(timeout_ms, tftp_timeout_handler);
/* Revert tftp_block_size to dflt */ /* Revert tftp_block_size to dflt */
tftp_block_size = TFTP_BLOCK_SIZE; tftp_block_size = TFTP_BLOCK_SIZE;
@ -951,7 +951,7 @@ static void parse_multicast_oack(char *pkt, int len)
printf("Fail to set mcast, revert to TFTP\n"); printf("Fail to set mcast, revert to TFTP\n");
tftp_mcast_disabled = 1; tftp_mcast_disabled = 1;
mcast_cleanup(); mcast_cleanup();
NetStartAgain(); net_start_again();
} }
} }
tftp_mcast_master_client = simple_strtoul((char *)mc, NULL, 10); tftp_mcast_master_client = simple_strtoul((char *)mc, NULL, 10);

View file

@ -23,15 +23,15 @@ static int dm_test_eth(struct dm_test_state *dms)
net_ping_ip = string_to_ip("1.1.2.2"); net_ping_ip = string_to_ip("1.1.2.2");
setenv("ethact", "eth@10002000"); setenv("ethact", "eth@10002000");
ut_assertok(NetLoop(PING)); ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10002000", getenv("ethact")); ut_asserteq_str("eth@10002000", getenv("ethact"));
setenv("ethact", "eth@10003000"); setenv("ethact", "eth@10003000");
ut_assertok(NetLoop(PING)); ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10003000", getenv("ethact")); ut_asserteq_str("eth@10003000", getenv("ethact"));
setenv("ethact", "eth@10004000"); setenv("ethact", "eth@10004000");
ut_assertok(NetLoop(PING)); ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10004000", getenv("ethact")); ut_asserteq_str("eth@10004000", getenv("ethact"));
return 0; return 0;
@ -42,20 +42,20 @@ static int dm_test_eth_alias(struct dm_test_state *dms)
{ {
net_ping_ip = string_to_ip("1.1.2.2"); net_ping_ip = string_to_ip("1.1.2.2");
setenv("ethact", "eth0"); setenv("ethact", "eth0");
ut_assertok(NetLoop(PING)); ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10002000", getenv("ethact")); ut_asserteq_str("eth@10002000", getenv("ethact"));
setenv("ethact", "eth1"); setenv("ethact", "eth1");
ut_assertok(NetLoop(PING)); ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10004000", getenv("ethact")); ut_asserteq_str("eth@10004000", getenv("ethact"));
/* Expected to fail since eth2 is not defined in the device tree */ /* Expected to fail since eth2 is not defined in the device tree */
setenv("ethact", "eth2"); setenv("ethact", "eth2");
ut_assertok(NetLoop(PING)); ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10002000", getenv("ethact")); ut_asserteq_str("eth@10002000", getenv("ethact"));
setenv("ethact", "eth5"); setenv("ethact", "eth5");
ut_assertok(NetLoop(PING)); ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10003000", getenv("ethact")); ut_asserteq_str("eth@10003000", getenv("ethact"));
return 0; return 0;
@ -69,13 +69,13 @@ static int dm_test_eth_prime(struct dm_test_state *dms)
/* Expected to be "eth@10003000" because of ethprime variable */ /* Expected to be "eth@10003000" because of ethprime variable */
setenv("ethact", NULL); setenv("ethact", NULL);
setenv("ethprime", "eth5"); setenv("ethprime", "eth5");
ut_assertok(NetLoop(PING)); ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10003000", getenv("ethact")); ut_asserteq_str("eth@10003000", getenv("ethact"));
/* Expected to be "eth@10002000" because it is first */ /* Expected to be "eth@10002000" because it is first */
setenv("ethact", NULL); setenv("ethact", NULL);
setenv("ethprime", NULL); setenv("ethprime", NULL);
ut_assertok(NetLoop(PING)); ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10002000", getenv("ethact")); ut_asserteq_str("eth@10002000", getenv("ethact"));
return 0; return 0;
@ -93,13 +93,13 @@ static int dm_test_eth_rotate(struct dm_test_state *dms)
/* Make sure that the default is to rotate to the next interface */ /* Make sure that the default is to rotate to the next interface */
setenv("ethact", "eth@10004000"); setenv("ethact", "eth@10004000");
ut_assertok(NetLoop(PING)); ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10002000", getenv("ethact")); ut_asserteq_str("eth@10002000", getenv("ethact"));
/* If ethrotate is no, then we should fail on a bad MAC */ /* If ethrotate is no, then we should fail on a bad MAC */
setenv("ethact", "eth@10004000"); setenv("ethact", "eth@10004000");
setenv("ethrotate", "no"); setenv("ethrotate", "no");
ut_asserteq(-EINVAL, NetLoop(PING)); ut_asserteq(-EINVAL, net_loop(PING));
ut_asserteq_str("eth@10004000", getenv("ethact")); ut_asserteq_str("eth@10004000", getenv("ethact"));
/* Restore the env */ /* Restore the env */
@ -113,7 +113,7 @@ static int dm_test_eth_rotate(struct dm_test_state *dms)
/* Make sure we can skip invalid devices */ /* Make sure we can skip invalid devices */
setenv("ethact", "eth@10004000"); setenv("ethact", "eth@10004000");
ut_assertok(NetLoop(PING)); ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10004000", getenv("ethact")); ut_asserteq_str("eth@10004000", getenv("ethact"));
/* Restore the env */ /* Restore the env */
@ -135,7 +135,7 @@ static int dm_test_net_retry(struct dm_test_state *dms)
sandbox_eth_disable_response(1, true); sandbox_eth_disable_response(1, true);
setenv("ethact", "eth@10004000"); setenv("ethact", "eth@10004000");
setenv("netretry", "yes"); setenv("netretry", "yes");
ut_assertok(NetLoop(PING)); ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10002000", getenv("ethact")); ut_asserteq_str("eth@10002000", getenv("ethact"));
/* /*
@ -144,7 +144,7 @@ static int dm_test_net_retry(struct dm_test_state *dms)
*/ */
setenv("ethact", "eth@10004000"); setenv("ethact", "eth@10004000");
setenv("netretry", "no"); setenv("netretry", "no");
ut_asserteq(-ETIMEDOUT, NetLoop(PING)); ut_asserteq(-ETIMEDOUT, net_loop(PING));
ut_asserteq_str("eth@10004000", getenv("ethact")); ut_asserteq_str("eth@10004000", getenv("ethact"));
/* Restore the env */ /* Restore the env */