mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-11 05:02:26 -04:00
net/net.c: cosmetic: fix whitespace issues
This removes the following checkpatch issues: - ERROR: space prohibited after that open parenthesis '(' - ERROR: space prohibited before that close parenthesis ')' - ERROR: space prohibited after that open square bracket '[' - ERROR: space prohibited after that '&' (ctx:WxW) - ERROR: spaces required around that '=' (ctx:VxW) - ERROR: space required before the open parenthesis '(' - ERROR: space required after that ',' (ctx:VxV) - ERROR: need consistent spacing around '+' (ctx:WxV) - WARNING: unnecessary whitespace before a quoted newline - WARNING: please, no spaces at the start of a line - WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it> Cc: Wolfgang Denk <wd@denx.de> Cc: Ben Warren <biggerbadderben@gmail.com> Cc: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
parent
c586ce6e01
commit
4f63acd062
186
net/net.c
186
net/net.c
@ -226,7 +226,7 @@ static ulong timeDelta;
|
|||||||
/* THE transmit packet */
|
/* THE transmit packet */
|
||||||
volatile uchar *NetTxPacket;
|
volatile uchar *NetTxPacket;
|
||||||
|
|
||||||
static int net_check_prereq (proto_t protocol);
|
static int net_check_prereq(proto_t protocol);
|
||||||
|
|
||||||
static int NetTryCount;
|
static int NetTryCount;
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN + PKTALIGN];
|
|||||||
ulong NetArpWaitTimerStart;
|
ulong NetArpWaitTimerStart;
|
||||||
int NetArpWaitTry;
|
int NetArpWaitTry;
|
||||||
|
|
||||||
void ArpRequest (void)
|
void ArpRequest(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
volatile uchar *pkt;
|
volatile uchar *pkt;
|
||||||
@ -253,20 +253,20 @@ void ArpRequest (void)
|
|||||||
|
|
||||||
pkt = NetTxPacket;
|
pkt = NetTxPacket;
|
||||||
|
|
||||||
pkt += NetSetEther (pkt, NetBcastAddr, PROT_ARP);
|
pkt += NetSetEther(pkt, NetBcastAddr, PROT_ARP);
|
||||||
|
|
||||||
arp = (ARP_t *) pkt;
|
arp = (ARP_t *) pkt;
|
||||||
|
|
||||||
arp->ar_hrd = htons (ARP_ETHER);
|
arp->ar_hrd = htons(ARP_ETHER);
|
||||||
arp->ar_pro = htons (PROT_IP);
|
arp->ar_pro = htons(PROT_IP);
|
||||||
arp->ar_hln = 6;
|
arp->ar_hln = 6;
|
||||||
arp->ar_pln = 4;
|
arp->ar_pln = 4;
|
||||||
arp->ar_op = htons (ARPOP_REQUEST);
|
arp->ar_op = htons(ARPOP_REQUEST);
|
||||||
|
|
||||||
/* source ET addr */
|
/* source ET addr */
|
||||||
memcpy (&arp->ar_data[0], NetOurEther, 6);
|
memcpy(&arp->ar_data[0], NetOurEther, 6);
|
||||||
/* source IP addr */
|
/* source IP addr */
|
||||||
NetWriteIP ((uchar *) & arp->ar_data[6], NetOurIP);
|
NetWriteIP((uchar *) &arp->ar_data[6], NetOurIP);
|
||||||
for (i = 10; i < 16; ++i) {
|
for (i = 10; i < 16; ++i) {
|
||||||
/* dest ET addr = 0 */
|
/* dest ET addr = 0 */
|
||||||
arp->ar_data[i] = 0;
|
arp->ar_data[i] = 0;
|
||||||
@ -275,7 +275,7 @@ void ArpRequest (void)
|
|||||||
if ((NetArpWaitPacketIP & NetOurSubnetMask) !=
|
if ((NetArpWaitPacketIP & NetOurSubnetMask) !=
|
||||||
(NetOurIP & NetOurSubnetMask)) {
|
(NetOurIP & NetOurSubnetMask)) {
|
||||||
if (NetOurGatewayIP == 0) {
|
if (NetOurGatewayIP == 0) {
|
||||||
puts ("## Warning: gatewayip needed but not set\n");
|
puts("## Warning: gatewayip needed but not set\n");
|
||||||
NetArpWaitReplyIP = NetArpWaitPacketIP;
|
NetArpWaitReplyIP = NetArpWaitPacketIP;
|
||||||
} else {
|
} else {
|
||||||
NetArpWaitReplyIP = NetOurGatewayIP;
|
NetArpWaitReplyIP = NetOurGatewayIP;
|
||||||
@ -284,8 +284,8 @@ void ArpRequest (void)
|
|||||||
NetArpWaitReplyIP = NetArpWaitPacketIP;
|
NetArpWaitReplyIP = NetArpWaitPacketIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetWriteIP ((uchar *) & arp->ar_data[16], NetArpWaitReplyIP);
|
NetWriteIP((uchar *) &arp->ar_data[16], NetArpWaitReplyIP);
|
||||||
(void) eth_send (NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
|
(void) eth_send(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArpTimeoutCheck(void)
|
void ArpTimeoutCheck(void)
|
||||||
@ -302,7 +302,7 @@ void ArpTimeoutCheck(void)
|
|||||||
NetArpWaitTry++;
|
NetArpWaitTry++;
|
||||||
|
|
||||||
if (NetArpWaitTry >= ARP_TIMEOUT_COUNT) {
|
if (NetArpWaitTry >= ARP_TIMEOUT_COUNT) {
|
||||||
puts ("\nARP Retry count exceeded; starting again\n");
|
puts("\nARP Retry count exceeded; starting again\n");
|
||||||
NetArpWaitTry = 0;
|
NetArpWaitTry = 0;
|
||||||
NetStartAgain();
|
NetStartAgain();
|
||||||
} else {
|
} else {
|
||||||
@ -317,14 +317,14 @@ NetInitLoop(proto_t protocol)
|
|||||||
{
|
{
|
||||||
static int env_changed_id;
|
static int env_changed_id;
|
||||||
bd_t *bd = gd->bd;
|
bd_t *bd = gd->bd;
|
||||||
int env_id = get_env_id ();
|
int env_id = get_env_id();
|
||||||
|
|
||||||
/* update only when the environment has changed */
|
/* update only when the environment has changed */
|
||||||
if (env_changed_id != env_id) {
|
if (env_changed_id != env_id) {
|
||||||
NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
|
NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
|
||||||
NetOurGatewayIP = getenv_IPaddr ("gatewayip");
|
NetOurGatewayIP = getenv_IPaddr("gatewayip");
|
||||||
NetOurSubnetMask= getenv_IPaddr ("netmask");
|
NetOurSubnetMask = getenv_IPaddr("netmask");
|
||||||
NetServerIP = getenv_IPaddr ("serverip");
|
NetServerIP = getenv_IPaddr("serverip");
|
||||||
NetOurNativeVLAN = getenv_VLAN("nvlan");
|
NetOurNativeVLAN = getenv_VLAN("nvlan");
|
||||||
NetOurVLAN = getenv_VLAN("vlan");
|
NetOurVLAN = getenv_VLAN("vlan");
|
||||||
#if defined(CONFIG_CMD_DNS)
|
#if defined(CONFIG_CMD_DNS)
|
||||||
@ -389,7 +389,7 @@ NetLoop(proto_t protocol)
|
|||||||
|
|
||||||
restart:
|
restart:
|
||||||
#ifdef CONFIG_NET_MULTI
|
#ifdef CONFIG_NET_MULTI
|
||||||
memcpy (NetOurEther, eth_get_dev()->enetaddr, 6);
|
memcpy(NetOurEther, eth_get_dev()->enetaddr, 6);
|
||||||
#else
|
#else
|
||||||
eth_getenv_enetaddr("ethaddr", NetOurEther);
|
eth_getenv_enetaddr("ethaddr", NetOurEther);
|
||||||
#endif
|
#endif
|
||||||
@ -403,7 +403,7 @@ restart:
|
|||||||
*/
|
*/
|
||||||
NetInitLoop(protocol);
|
NetInitLoop(protocol);
|
||||||
|
|
||||||
switch (net_check_prereq (protocol)) {
|
switch (net_check_prereq(protocol)) {
|
||||||
case 1:
|
case 1:
|
||||||
/* network not configured */
|
/* network not configured */
|
||||||
eth_halt();
|
eth_halt();
|
||||||
@ -436,14 +436,14 @@ restart:
|
|||||||
case BOOTP:
|
case BOOTP:
|
||||||
BootpTry = 0;
|
BootpTry = 0;
|
||||||
NetOurIP = 0;
|
NetOurIP = 0;
|
||||||
BootpRequest ();
|
BootpRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined(CONFIG_CMD_RARP)
|
#if defined(CONFIG_CMD_RARP)
|
||||||
case RARP:
|
case RARP:
|
||||||
RarpTry = 0;
|
RarpTry = 0;
|
||||||
NetOurIP = 0;
|
NetOurIP = 0;
|
||||||
RarpRequest ();
|
RarpRequest();
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_CMD_PING)
|
#if defined(CONFIG_CMD_PING)
|
||||||
@ -491,10 +491,10 @@ 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, CONFIG_SYS_FAULT_MII_ADDR)) {
|
if (miiphy_link(eth_get_dev()->name, 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, ... */
|
||||||
@ -522,7 +522,7 @@ restart:
|
|||||||
*/
|
*/
|
||||||
if (ctrlc()) {
|
if (ctrlc()) {
|
||||||
eth_halt();
|
eth_halt();
|
||||||
puts ("\nAbort\n");
|
puts("\nAbort\n");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,19 +536,19 @@ restart:
|
|||||||
thand_f *x;
|
thand_f *x;
|
||||||
|
|
||||||
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
|
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
|
||||||
# if defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) && \
|
#if defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) && \
|
||||||
defined(CONFIG_STATUS_LED) && \
|
defined(CONFIG_STATUS_LED) && \
|
||||||
defined(STATUS_LED_RED)
|
defined(STATUS_LED_RED)
|
||||||
/*
|
/*
|
||||||
* 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, ... */
|
||||||
x = timeHandler;
|
x = timeHandler;
|
||||||
timeHandler = (thand_f *)0;
|
timeHandler = (thand_f *)0;
|
||||||
@ -600,7 +600,7 @@ startAgainHandler(uchar *pkt, unsigned dest, IPaddr_t sip,
|
|||||||
/* Totally ignore the packet */
|
/* Totally ignore the packet */
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetStartAgain (void)
|
void NetStartAgain(void)
|
||||||
{
|
{
|
||||||
char *nretry;
|
char *nretry;
|
||||||
int retry_forever = 0;
|
int retry_forever = 0;
|
||||||
@ -628,19 +628,19 @@ void NetStartAgain (void)
|
|||||||
NetTryCount++;
|
NetTryCount++;
|
||||||
|
|
||||||
#ifndef CONFIG_NET_MULTI
|
#ifndef CONFIG_NET_MULTI
|
||||||
NetSetTimeout (10000UL, startAgainTimeout);
|
NetSetTimeout(10000UL, startAgainTimeout);
|
||||||
NetSetHandler (startAgainHandler);
|
NetSetHandler(startAgainHandler);
|
||||||
#else /* !CONFIG_NET_MULTI*/
|
#else /* !CONFIG_NET_MULTI*/
|
||||||
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(!NetRestarted);
|
||||||
#endif
|
#endif
|
||||||
eth_init (gd->bd);
|
eth_init(gd->bd);
|
||||||
if (NetRestartWrap) {
|
if (NetRestartWrap) {
|
||||||
NetRestartWrap = 0;
|
NetRestartWrap = 0;
|
||||||
if (NetDevExists) {
|
if (NetDevExists) {
|
||||||
NetSetTimeout (10000UL, startAgainTimeout);
|
NetSetTimeout(10000UL, startAgainTimeout);
|
||||||
NetSetHandler (startAgainHandler);
|
NetSetHandler(startAgainHandler);
|
||||||
} else {
|
} else {
|
||||||
NetState = NETLOOP_FAIL;
|
NetState = NETLOOP_FAIL;
|
||||||
}
|
}
|
||||||
@ -706,9 +706,9 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
|
|||||||
NetArpWaitPacketMAC = ether;
|
NetArpWaitPacketMAC = ether;
|
||||||
|
|
||||||
pkt = NetArpWaitTxPacket;
|
pkt = NetArpWaitTxPacket;
|
||||||
pkt += NetSetEther (pkt, NetArpWaitPacketMAC, PROT_IP);
|
pkt += NetSetEther(pkt, NetArpWaitPacketMAC, PROT_IP);
|
||||||
|
|
||||||
NetSetIP (pkt, dest, dport, sport, len);
|
NetSetIP(pkt, dest, dport, sport, len);
|
||||||
memcpy(pkt + IP_HDR_SIZE, (uchar *)NetTxPacket +
|
memcpy(pkt + IP_HDR_SIZE, (uchar *)NetTxPacket +
|
||||||
(pkt - (uchar *)NetArpWaitTxPacket) + IP_HDR_SIZE, len);
|
(pkt - (uchar *)NetArpWaitTxPacket) + IP_HDR_SIZE, len);
|
||||||
|
|
||||||
@ -726,8 +726,8 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
|
|||||||
debug("sending UDP to %08lx/%pM\n", dest, ether);
|
debug("sending UDP to %08lx/%pM\n", dest, ether);
|
||||||
|
|
||||||
pkt = (uchar *)NetTxPacket;
|
pkt = (uchar *)NetTxPacket;
|
||||||
pkt += NetSetEther (pkt, ether, PROT_IP);
|
pkt += NetSetEther(pkt, ether, PROT_IP);
|
||||||
NetSetIP (pkt, dest, dport, sport, len);
|
NetSetIP(pkt, dest, dport, sport, len);
|
||||||
(void) eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_HDR_SIZE + len);
|
(void) eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_HDR_SIZE + len);
|
||||||
|
|
||||||
return 0; /* transmitted */
|
return 0; /* transmitted */
|
||||||
@ -795,7 +795,7 @@ int PingSend(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
PingTimeout (void)
|
PingTimeout(void)
|
||||||
{
|
{
|
||||||
eth_halt();
|
eth_halt();
|
||||||
NetState = NETLOOP_FAIL; /* we did not get the reply */
|
NetState = NETLOOP_FAIL; /* we did not get the reply */
|
||||||
@ -814,10 +814,10 @@ PingHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
|
|||||||
static void PingStart(void)
|
static void PingStart(void)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_NET_MULTI)
|
#if defined(CONFIG_NET_MULTI)
|
||||||
printf ("Using %s device\n", eth_get_name());
|
printf("Using %s device\n", eth_get_name());
|
||||||
#endif /* CONFIG_NET_MULTI */
|
#endif /* CONFIG_NET_MULTI */
|
||||||
NetSetTimeout (10000UL, PingTimeout);
|
NetSetTimeout(10000UL, PingTimeout);
|
||||||
NetSetHandler (PingHandler);
|
NetSetHandler(PingHandler);
|
||||||
|
|
||||||
PingSend();
|
PingSend();
|
||||||
}
|
}
|
||||||
@ -915,8 +915,8 @@ int CDPSendTrigger(void)
|
|||||||
Ethernet_t *et;
|
Ethernet_t *et;
|
||||||
int len;
|
int len;
|
||||||
ushort chksum;
|
ushort chksum;
|
||||||
#if defined(CONFIG_CDP_DEVICE_ID) || defined(CONFIG_CDP_PORT_ID) || \
|
#if defined(CONFIG_CDP_DEVICE_ID) || defined(CONFIG_CDP_PORT_ID) || \
|
||||||
defined(CONFIG_CDP_VERSION) || defined(CONFIG_CDP_PLATFORM)
|
defined(CONFIG_CDP_VERSION) || defined(CONFIG_CDP_PLATFORM)
|
||||||
char buf[32];
|
char buf[32];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1024,12 +1024,12 @@ int CDPSendTrigger(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CDPTimeout (void)
|
CDPTimeout(void)
|
||||||
{
|
{
|
||||||
CDPSeq++;
|
CDPSeq++;
|
||||||
|
|
||||||
if (CDPSeq < 3) {
|
if (CDPSeq < 3) {
|
||||||
NetSetTimeout (CDP_TIMEOUT, CDPTimeout);
|
NetSetTimeout(CDP_TIMEOUT, CDPTimeout);
|
||||||
CDPSendTrigger();
|
CDPSendTrigger();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1168,7 +1168,7 @@ CDPHandler(const uchar * pkt, unsigned len)
|
|||||||
static void CDPStart(void)
|
static void CDPStart(void)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_NET_MULTI)
|
#if defined(CONFIG_NET_MULTI)
|
||||||
printf ("Using %s device\n", eth_get_name());
|
printf("Using %s device\n", eth_get_name());
|
||||||
#endif
|
#endif
|
||||||
CDPSeq = 0;
|
CDPSeq = 0;
|
||||||
CDPOK = 0;
|
CDPOK = 0;
|
||||||
@ -1176,8 +1176,8 @@ static void CDPStart(void)
|
|||||||
CDPNativeVLAN = htons(-1);
|
CDPNativeVLAN = htons(-1);
|
||||||
CDPApplianceVLAN = htons(-1);
|
CDPApplianceVLAN = htons(-1);
|
||||||
|
|
||||||
NetSetTimeout (CDP_TIMEOUT, CDPTimeout);
|
NetSetTimeout(CDP_TIMEOUT, CDPTimeout);
|
||||||
NetSetHandler (CDPDummyHandler);
|
NetSetHandler(CDPDummyHandler);
|
||||||
|
|
||||||
CDPSendTrigger();
|
CDPSendTrigger();
|
||||||
}
|
}
|
||||||
@ -1281,7 +1281,7 @@ static IP_t *__NetDefragment(IP_t *ip, int *lenp)
|
|||||||
* (thus being a superset of a previously-received fragment).
|
* (thus being a superset of a previously-received fragment).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( (h >= thisfrag) && (h->last_byte <= start + len) ) {
|
if ((h >= thisfrag) && (h->last_byte <= start + len)) {
|
||||||
/* complete overlap with hole: remove hole */
|
/* complete overlap with hole: remove hole */
|
||||||
if (!h->prev_hole && !h->next_hole) {
|
if (!h->prev_hole && !h->next_hole) {
|
||||||
/* last remaining hole */
|
/* last remaining hole */
|
||||||
@ -1505,10 +1505,10 @@ NetReceive(volatile uchar * inpkt, int len)
|
|||||||
pkt = (uchar *)et;
|
pkt = (uchar *)et;
|
||||||
pkt += NetSetEther(pkt, et->et_src, PROT_ARP);
|
pkt += NetSetEther(pkt, et->et_src, PROT_ARP);
|
||||||
arp->ar_op = htons(ARPOP_REPLY);
|
arp->ar_op = htons(ARPOP_REPLY);
|
||||||
memcpy (&arp->ar_data[10], &arp->ar_data[0], 6);
|
memcpy(&arp->ar_data[10], &arp->ar_data[0], 6);
|
||||||
NetCopyIP(&arp->ar_data[16], &arp->ar_data[6]);
|
NetCopyIP(&arp->ar_data[16], &arp->ar_data[6]);
|
||||||
memcpy (&arp->ar_data[ 0], NetOurEther, 6);
|
memcpy(&arp->ar_data[0], NetOurEther, 6);
|
||||||
NetCopyIP(&arp->ar_data[ 6], &NetOurIP);
|
NetCopyIP(&arp->ar_data[6], &NetOurIP);
|
||||||
(void) eth_send((uchar *)et,
|
(void) eth_send((uchar *)et,
|
||||||
(pkt - (uchar *)et) + ARP_HDR_SIZE);
|
(pkt - (uchar *)et) + ARP_HDR_SIZE);
|
||||||
return;
|
return;
|
||||||
@ -1574,12 +1574,12 @@ NetReceive(volatile uchar * inpkt, int len)
|
|||||||
(ntohs(arp->ar_pro) != PROT_IP) ||
|
(ntohs(arp->ar_pro) != PROT_IP) ||
|
||||||
(arp->ar_hln != 6) || (arp->ar_pln != 4)) {
|
(arp->ar_hln != 6) || (arp->ar_pln != 4)) {
|
||||||
|
|
||||||
puts ("invalid RARP header\n");
|
puts("invalid RARP header\n");
|
||||||
} else {
|
} else {
|
||||||
NetCopyIP(&NetOurIP, &arp->ar_data[16]);
|
NetCopyIP(&NetOurIP, &arp->ar_data[16]);
|
||||||
if (NetServerIP == 0)
|
if (NetServerIP == 0)
|
||||||
NetCopyIP(&NetServerIP, &arp->ar_data[ 6]);
|
NetCopyIP(&NetServerIP, &arp->ar_data[6]);
|
||||||
memcpy (NetServerEther, &arp->ar_data[ 0], 6);
|
memcpy(NetServerEther, &arp->ar_data[0], 6);
|
||||||
|
|
||||||
(*packetHandler)(0, 0, 0, 0, 0);
|
(*packetHandler)(0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
@ -1610,7 +1610,7 @@ NetReceive(volatile uchar * inpkt, int len)
|
|||||||
}
|
}
|
||||||
/* Check the Checksum of the header */
|
/* Check the Checksum of the header */
|
||||||
if (!NetCksumOk((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2)) {
|
if (!NetCksumOk((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2)) {
|
||||||
puts ("checksum bad\n");
|
puts("checksum bad\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* If it is not for us, ignore it */
|
/* If it is not for us, ignore it */
|
||||||
@ -1654,7 +1654,7 @@ NetReceive(volatile uchar * inpkt, int len)
|
|||||||
case ICMP_REDIRECT:
|
case ICMP_REDIRECT:
|
||||||
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);
|
||||||
return;
|
return;
|
||||||
#if defined(CONFIG_CMD_PING)
|
#if defined(CONFIG_CMD_PING)
|
||||||
@ -1670,8 +1670,8 @@ NetReceive(volatile uchar * inpkt, int len)
|
|||||||
debug("Got ICMP ECHO REQUEST, return %d bytes\n",
|
debug("Got ICMP ECHO REQUEST, return %d bytes\n",
|
||||||
ETHER_HDR_SIZE + len);
|
ETHER_HDR_SIZE + len);
|
||||||
|
|
||||||
memcpy (&et->et_dest[0], &et->et_src[0], 6);
|
memcpy(&et->et_dest[0], &et->et_src[0], 6);
|
||||||
memcpy (&et->et_src[ 0], NetOurEther, 6);
|
memcpy(&et->et_src[0], NetOurEther, 6);
|
||||||
|
|
||||||
ip->ip_sum = 0;
|
ip->ip_sum = 0;
|
||||||
ip->ip_off = 0;
|
ip->ip_off = 0;
|
||||||
@ -1739,7 +1739,7 @@ NetReceive(volatile uchar * inpkt, int len)
|
|||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_NETCONSOLE
|
#ifdef CONFIG_NETCONSOLE
|
||||||
nc_input_packet((uchar *)ip +IP_HDR_SIZE,
|
nc_input_packet((uchar *)ip + IP_HDR_SIZE,
|
||||||
ntohs(ip->udp_dst),
|
ntohs(ip->udp_dst),
|
||||||
ntohs(ip->udp_src),
|
ntohs(ip->udp_src),
|
||||||
ntohs(ip->udp_len) - 8);
|
ntohs(ip->udp_len) - 8);
|
||||||
@ -1747,7 +1747,7 @@ NetReceive(volatile uchar * inpkt, int len)
|
|||||||
/*
|
/*
|
||||||
* IP header OK. Pass the packet to the current handler.
|
* IP header OK. Pass the packet to the current handler.
|
||||||
*/
|
*/
|
||||||
(*packetHandler)((uchar *)ip +IP_HDR_SIZE,
|
(*packetHandler)((uchar *)ip + IP_HDR_SIZE,
|
||||||
ntohs(ip->udp_dst),
|
ntohs(ip->udp_dst),
|
||||||
src_ip,
|
src_ip,
|
||||||
ntohs(ip->udp_src),
|
ntohs(ip->udp_src),
|
||||||
@ -1759,14 +1759,14 @@ NetReceive(volatile uchar * inpkt, int len)
|
|||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
static int net_check_prereq (proto_t protocol)
|
static int net_check_prereq(proto_t protocol)
|
||||||
{
|
{
|
||||||
switch (protocol) {
|
switch (protocol) {
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
#if defined(CONFIG_CMD_PING)
|
#if defined(CONFIG_CMD_PING)
|
||||||
case PING:
|
case PING:
|
||||||
if (NetPingIP == 0) {
|
if (NetPingIP == 0) {
|
||||||
puts ("*** ERROR: ping address not given\n");
|
puts("*** ERROR: ping address not given\n");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
goto common;
|
goto common;
|
||||||
@ -1774,7 +1774,7 @@ static int net_check_prereq (proto_t protocol)
|
|||||||
#if defined(CONFIG_CMD_SNTP)
|
#if defined(CONFIG_CMD_SNTP)
|
||||||
case SNTP:
|
case SNTP:
|
||||||
if (NetNtpServerIP == 0) {
|
if (NetNtpServerIP == 0) {
|
||||||
puts ("*** ERROR: NTP server address not given\n");
|
puts("*** ERROR: NTP server address not given\n");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
goto common;
|
goto common;
|
||||||
@ -1792,18 +1792,18 @@ static int net_check_prereq (proto_t protocol)
|
|||||||
#endif
|
#endif
|
||||||
case TFTP:
|
case TFTP:
|
||||||
if (NetServerIP == 0) {
|
if (NetServerIP == 0) {
|
||||||
puts ("*** ERROR: `serverip' not set\n");
|
puts("*** ERROR: `serverip' not set\n");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
#if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
|
#if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
|
||||||
defined(CONFIG_CMD_DNS)
|
defined(CONFIG_CMD_DNS)
|
||||||
common:
|
common:
|
||||||
#endif
|
#endif
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
|
|
||||||
case NETCONS:
|
case NETCONS:
|
||||||
if (NetOurIP == 0) {
|
if (NetOurIP == 0) {
|
||||||
puts ("*** ERROR: `ipaddr' not set\n");
|
puts("*** ERROR: `ipaddr' not set\n");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
@ -1814,28 +1814,28 @@ static int net_check_prereq (proto_t protocol)
|
|||||||
case BOOTP:
|
case BOOTP:
|
||||||
case CDP:
|
case CDP:
|
||||||
case DHCP:
|
case DHCP:
|
||||||
if (memcmp (NetOurEther, "\0\0\0\0\0\0", 6) == 0) {
|
if (memcmp(NetOurEther, "\0\0\0\0\0\0", 6) == 0) {
|
||||||
#ifdef CONFIG_NET_MULTI
|
#ifdef CONFIG_NET_MULTI
|
||||||
extern int eth_get_dev_index (void);
|
extern int eth_get_dev_index(void);
|
||||||
int num = eth_get_dev_index ();
|
int num = eth_get_dev_index();
|
||||||
|
|
||||||
switch (num) {
|
switch (num) {
|
||||||
case -1:
|
case -1:
|
||||||
puts ("*** ERROR: No ethernet found.\n");
|
puts("*** ERROR: No ethernet found.\n");
|
||||||
return (1);
|
return (1);
|
||||||
case 0:
|
case 0:
|
||||||
puts ("*** ERROR: `ethaddr' not set\n");
|
puts("*** ERROR: `ethaddr' not set\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf ("*** ERROR: `eth%daddr' not set\n",
|
printf("*** ERROR: `eth%daddr' not set\n",
|
||||||
num);
|
num);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetStartAgain ();
|
NetStartAgain();
|
||||||
return (2);
|
return (2);
|
||||||
#else
|
#else
|
||||||
puts ("*** ERROR: `ethaddr' not set\n");
|
puts("*** ERROR: `ethaddr' not set\n");
|
||||||
return (1);
|
return (1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -1891,8 +1891,8 @@ NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
|
|||||||
if (myvlanid == (ushort)-1)
|
if (myvlanid == (ushort)-1)
|
||||||
myvlanid = VLAN_NONE;
|
myvlanid = VLAN_NONE;
|
||||||
|
|
||||||
memcpy (et->et_dest, addr, 6);
|
memcpy(et->et_dest, addr, 6);
|
||||||
memcpy (et->et_src, NetOurEther, 6);
|
memcpy(et->et_src, NetOurEther, 6);
|
||||||
if ((myvlanid & VLAN_IDMASK) == VLAN_NONE) {
|
if ((myvlanid & VLAN_IDMASK) == VLAN_NONE) {
|
||||||
et->et_protlen = htons(prot);
|
et->et_protlen = htons(prot);
|
||||||
return ETHER_HDR_SIZE;
|
return ETHER_HDR_SIZE;
|
||||||
@ -1943,7 +1943,7 @@ NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
|
|||||||
ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
|
ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void copy_filename (char *dst, const char *src, int size)
|
void copy_filename(char *dst, const char *src, int size)
|
||||||
{
|
{
|
||||||
if (*src && (*src == '"')) {
|
if (*src && (*src == '"')) {
|
||||||
++src;
|
++src;
|
||||||
@ -1970,13 +1970,13 @@ unsigned int random_port(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ip_to_string (IPaddr_t x, char *s)
|
void ip_to_string(IPaddr_t x, char *s)
|
||||||
{
|
{
|
||||||
x = ntohl (x);
|
x = ntohl(x);
|
||||||
sprintf (s, "%d.%d.%d.%d",
|
sprintf(s, "%d.%d.%d.%d",
|
||||||
(int) ((x >> 24) & 0xff),
|
(int) ((x >> 24) & 0xff),
|
||||||
(int) ((x >> 16) & 0xff),
|
(int) ((x >> 16) & 0xff),
|
||||||
(int) ((x >> 8) & 0xff), (int) ((x >> 0) & 0xff)
|
(int) ((x >> 8) & 0xff), (int) ((x >> 0) & 0xff)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user