mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 21:21:37 +00:00
net: cosmetic: Clean up DHCP variables and functions
Make a thorough pass through all variables and function names contained within bootp.c and remove CamelCase and improve naming. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
85d25e0e76
commit
7044c6bb69
3 changed files with 69 additions and 72 deletions
119
net/bootp.c
119
net/bootp.c
|
@ -53,7 +53,7 @@
|
||||||
|
|
||||||
ulong bootp_ids[CONFIG_BOOTP_ID_CACHE_SIZE];
|
ulong bootp_ids[CONFIG_BOOTP_ID_CACHE_SIZE];
|
||||||
unsigned int bootp_num_ids;
|
unsigned int bootp_num_ids;
|
||||||
int BootpTry;
|
int bootp_try;
|
||||||
ulong bootp_start;
|
ulong bootp_start;
|
||||||
ulong bootp_timeout;
|
ulong bootp_timeout;
|
||||||
char net_nis_domain[32] = {0,}; /* Our NIS domain */
|
char net_nis_domain[32] = {0,}; /* Our NIS domain */
|
||||||
|
@ -109,14 +109,14 @@ static bool bootp_match_id(ulong id)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
|
static int check_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len)
|
||||||
{
|
{
|
||||||
struct Bootp_t *bp = (struct Bootp_t *) pkt;
|
struct bootp_hdr *bp = (struct bootp_hdr *)pkt;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
if (dest != PORT_BOOTPC || src != PORT_BOOTPS)
|
if (dest != PORT_BOOTPC || src != PORT_BOOTPS)
|
||||||
retval = -1;
|
retval = -1;
|
||||||
else if (len < sizeof(struct Bootp_t) - OPT_FIELD_SIZE)
|
else if (len < sizeof(struct bootp_hdr) - OPT_FIELD_SIZE)
|
||||||
retval = -2;
|
retval = -2;
|
||||||
else if (bp->bp_op != OP_BOOTREQUEST &&
|
else if (bp->bp_op != OP_BOOTREQUEST &&
|
||||||
bp->bp_op != OP_BOOTREPLY &&
|
bp->bp_op != OP_BOOTREPLY &&
|
||||||
|
@ -139,7 +139,7 @@ static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
|
||||||
/*
|
/*
|
||||||
* Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet
|
* Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet
|
||||||
*/
|
*/
|
||||||
static void BootpCopyNetParams(struct Bootp_t *bp)
|
static void store_net_params(struct bootp_hdr *bp)
|
||||||
{
|
{
|
||||||
#if !defined(CONFIG_BOOTP_SERVERIP)
|
#if !defined(CONFIG_BOOTP_SERVERIP)
|
||||||
struct in_addr tmp_ip;
|
struct in_addr tmp_ip;
|
||||||
|
@ -177,12 +177,12 @@ static int truncate_sz(const char *name, int maxlen, int curlen)
|
||||||
|
|
||||||
#if !defined(CONFIG_CMD_DHCP)
|
#if !defined(CONFIG_CMD_DHCP)
|
||||||
|
|
||||||
static void BootpVendorFieldProcess(u8 *ext)
|
static void bootp_process_vendor_field(u8 *ext)
|
||||||
{
|
{
|
||||||
int size = *(ext + 1);
|
int size = *(ext + 1);
|
||||||
|
|
||||||
debug("[BOOTP] Processing extension %d... (%d bytes)\n", *ext,
|
debug("[BOOTP] Processing extension %d... (%d bytes)\n", *ext,
|
||||||
*(ext + 1));
|
*(ext + 1));
|
||||||
|
|
||||||
net_boot_file_expected_size_in_blocks = 0;
|
net_boot_file_expected_size_in_blocks = 0;
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ static void BootpVendorFieldProcess(u8 *ext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BootpVendorProcess(u8 *ext, int size)
|
static void bootp_process_vendor(u8 *ext, int size)
|
||||||
{
|
{
|
||||||
u8 *end = ext + size;
|
u8 *end = ext + size;
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ static void BootpVendorProcess(u8 *ext, int size)
|
||||||
|
|
||||||
ext += ext[1] + 2;
|
ext += ext[1] + 2;
|
||||||
if (ext <= end)
|
if (ext <= end)
|
||||||
BootpVendorFieldProcess(opt);
|
bootp_process_vendor_field(opt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,15 +335,15 @@ static void BootpVendorProcess(u8 *ext, int size)
|
||||||
static void bootp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
|
static void bootp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
|
||||||
unsigned src, unsigned len)
|
unsigned src, unsigned len)
|
||||||
{
|
{
|
||||||
struct Bootp_t *bp;
|
struct bootp_hdr *bp;
|
||||||
|
|
||||||
debug("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%zu)\n",
|
debug("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%zu)\n",
|
||||||
src, dest, len, sizeof(struct Bootp_t));
|
src, dest, len, sizeof(struct bootp_hdr));
|
||||||
|
|
||||||
bp = (struct Bootp_t *)pkt;
|
bp = (struct bootp_hdr *)pkt;
|
||||||
|
|
||||||
/* Filter out pkts we don't want */
|
/* Filter out pkts we don't want */
|
||||||
if (BootpCheckPkt(pkt, dest, src, len))
|
if (check_packet(pkt, dest, src, len))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -353,11 +353,11 @@ static void bootp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
|
||||||
status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
|
status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BootpCopyNetParams(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 (NetReadLong((ulong *)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
|
||||||
BootpVendorProcess((uchar *)&bp->bp_vend[4], len);
|
bootp_process_vendor((uchar *)&bp->bp_vend[4], len);
|
||||||
|
|
||||||
NetSetTimeout(0, (thand_f *)0);
|
NetSetTimeout(0, (thand_f *)0);
|
||||||
bootstage_mark_name(BOOTSTAGE_ID_BOOTP_STOP, "bootp_stop");
|
bootstage_mark_name(BOOTSTAGE_ID_BOOTP_STOP, "bootp_stop");
|
||||||
|
@ -371,8 +371,7 @@ static void bootp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
|
||||||
/*
|
/*
|
||||||
* Timeout on BOOTP/DHCP request.
|
* Timeout on BOOTP/DHCP request.
|
||||||
*/
|
*/
|
||||||
static void
|
static void bootp_timeout_handler(void)
|
||||||
BootpTimeout(void)
|
|
||||||
{
|
{
|
||||||
ulong time_taken = get_timer(bootp_start);
|
ulong time_taken = get_timer(bootp_start);
|
||||||
|
|
||||||
|
@ -388,8 +387,8 @@ BootpTimeout(void)
|
||||||
bootp_timeout *= 2;
|
bootp_timeout *= 2;
|
||||||
if (bootp_timeout > 2000)
|
if (bootp_timeout > 2000)
|
||||||
bootp_timeout = 2000;
|
bootp_timeout = 2000;
|
||||||
NetSetTimeout(bootp_timeout, BootpTimeout);
|
NetSetTimeout(bootp_timeout, bootp_timeout_handler);
|
||||||
BootpRequest();
|
bootp_request();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,25 +648,24 @@ static int bootp_extended(u8 *e)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void BootpReset(void)
|
void bootp_reset(void)
|
||||||
{
|
{
|
||||||
bootp_num_ids = 0;
|
bootp_num_ids = 0;
|
||||||
BootpTry = 0;
|
bootp_try = 0;
|
||||||
bootp_start = get_timer(0);
|
bootp_start = get_timer(0);
|
||||||
bootp_timeout = 250;
|
bootp_timeout = 250;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void bootp_request(void)
|
||||||
BootpRequest(void)
|
|
||||||
{
|
{
|
||||||
uchar *pkt, *iphdr;
|
uchar *pkt, *iphdr;
|
||||||
struct Bootp_t *bp;
|
struct bootp_hdr *bp;
|
||||||
int extlen, pktlen, iplen;
|
int extlen, pktlen, iplen;
|
||||||
int eth_hdr_size;
|
int eth_hdr_size;
|
||||||
#ifdef CONFIG_BOOTP_RANDOM_DELAY
|
#ifdef CONFIG_BOOTP_RANDOM_DELAY
|
||||||
ulong rand_ms;
|
ulong rand_ms;
|
||||||
#endif
|
#endif
|
||||||
ulong BootpID;
|
ulong bootp_id;
|
||||||
struct in_addr zero_ip;
|
struct in_addr zero_ip;
|
||||||
struct in_addr bcast_ip;
|
struct in_addr bcast_ip;
|
||||||
|
|
||||||
|
@ -677,11 +675,11 @@ BootpRequest(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */
|
#ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */
|
||||||
if (BootpTry == 0)
|
if (bootp_try == 0)
|
||||||
srand_mac();
|
srand_mac();
|
||||||
|
|
||||||
if (BootpTry <= 2) /* Start with max 1024 * 1ms */
|
if (bootp_try <= 2) /* Start with max 1024 * 1ms */
|
||||||
rand_ms = rand() >> (22 - BootpTry);
|
rand_ms = rand() >> (22 - bootp_try);
|
||||||
else /* After 3rd BOOTP request max 8192 * 1ms */
|
else /* After 3rd BOOTP request max 8192 * 1ms */
|
||||||
rand_ms = rand() >> 19;
|
rand_ms = rand() >> 19;
|
||||||
|
|
||||||
|
@ -690,7 +688,7 @@ BootpRequest(void)
|
||||||
|
|
||||||
#endif /* CONFIG_BOOTP_RANDOM_DELAY */
|
#endif /* CONFIG_BOOTP_RANDOM_DELAY */
|
||||||
|
|
||||||
printf("BOOTP broadcast %d\n", ++BootpTry);
|
printf("BOOTP broadcast %d\n", ++bootp_try);
|
||||||
pkt = net_tx_packet;
|
pkt = net_tx_packet;
|
||||||
memset((void *)pkt, 0, PKTSIZE);
|
memset((void *)pkt, 0, PKTSIZE);
|
||||||
|
|
||||||
|
@ -705,11 +703,11 @@ BootpRequest(void)
|
||||||
* C. Hallinan, DS4.COM, Inc.
|
* C. Hallinan, DS4.COM, Inc.
|
||||||
*/
|
*/
|
||||||
/* net_set_udp_header(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC,
|
/* net_set_udp_header(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC,
|
||||||
sizeof (struct Bootp_t)); */
|
sizeof (struct bootp_hdr)); */
|
||||||
iphdr = pkt; /* We need this later for net_set_udp_header() */
|
iphdr = pkt; /* We need this later for net_set_udp_header() */
|
||||||
pkt += IP_UDP_HDR_SIZE;
|
pkt += IP_UDP_HDR_SIZE;
|
||||||
|
|
||||||
bp = (struct Bootp_t *)pkt;
|
bp = (struct bootp_hdr *)pkt;
|
||||||
bp->bp_op = OP_BOOTREQUEST;
|
bp->bp_op = OP_BOOTREQUEST;
|
||||||
bp->bp_htype = HWT_ETHER;
|
bp->bp_htype = HWT_ETHER;
|
||||||
bp->bp_hlen = HWL_ETHER;
|
bp->bp_hlen = HWL_ETHER;
|
||||||
|
@ -735,14 +733,14 @@ BootpRequest(void)
|
||||||
* Bootp ID is the lower 4 bytes of our ethernet address
|
* Bootp ID is the lower 4 bytes of our ethernet address
|
||||||
* plus the current time in ms.
|
* plus the current time in ms.
|
||||||
*/
|
*/
|
||||||
BootpID = ((ulong)net_ethaddr[2] << 24)
|
bootp_id = ((ulong)net_ethaddr[2] << 24)
|
||||||
| ((ulong)net_ethaddr[3] << 16)
|
| ((ulong)net_ethaddr[3] << 16)
|
||||||
| ((ulong)net_ethaddr[4] << 8)
|
| ((ulong)net_ethaddr[4] << 8)
|
||||||
| (ulong)net_ethaddr[5];
|
| (ulong)net_ethaddr[5];
|
||||||
BootpID += get_timer(0);
|
bootp_id += get_timer(0);
|
||||||
BootpID = htonl(BootpID);
|
bootp_id = htonl(bootp_id);
|
||||||
bootp_add_id(BootpID);
|
bootp_add_id(bootp_id);
|
||||||
NetCopyLong(&bp->bp_id, &BootpID);
|
NetCopyLong(&bp->bp_id, &bootp_id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate proper packet lengths taking into account the
|
* Calculate proper packet lengths taking into account the
|
||||||
|
@ -752,7 +750,7 @@ BootpRequest(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, BootpTimeout);
|
NetSetTimeout(bootp_timeout, bootp_timeout_handler);
|
||||||
|
|
||||||
#if defined(CONFIG_CMD_DHCP)
|
#if defined(CONFIG_CMD_DHCP)
|
||||||
dhcp_state = SELECTING;
|
dhcp_state = SELECTING;
|
||||||
|
@ -764,7 +762,7 @@ BootpRequest(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_CMD_DHCP)
|
#if defined(CONFIG_CMD_DHCP)
|
||||||
static void DhcpOptionsProcess(uchar *popt, struct Bootp_t *bp)
|
static void dhcp_process_options(uchar *popt, struct bootp_hdr *bp)
|
||||||
{
|
{
|
||||||
uchar *end = popt + BOOTP_HDR_SIZE;
|
uchar *end = popt + BOOTP_HDR_SIZE;
|
||||||
int oplen, size;
|
int oplen, size;
|
||||||
|
@ -851,7 +849,7 @@ static void DhcpOptionsProcess(uchar *popt, struct Bootp_t *bp)
|
||||||
* to me
|
* to me
|
||||||
*/
|
*/
|
||||||
printf("*** WARNING: using vendor "
|
printf("*** WARNING: using vendor "
|
||||||
"optional boot file\n");
|
"optional boot file\n");
|
||||||
memcpy(bp->bp_file, popt + 2, size);
|
memcpy(bp->bp_file, popt + 2, size);
|
||||||
bp->bp_file[size] = '\0';
|
bp->bp_file[size] = '\0';
|
||||||
}
|
}
|
||||||
|
@ -862,14 +860,14 @@ static void DhcpOptionsProcess(uchar *popt, struct Bootp_t *bp)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
printf("*** Unhandled DHCP Option in OFFER/ACK:"
|
printf("*** Unhandled DHCP Option in OFFER/ACK:"
|
||||||
" %d\n", *popt);
|
" %d\n", *popt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
popt += oplen + 2; /* Process next option */
|
popt += oplen + 2; /* Process next option */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DhcpMessageType(unsigned char *popt)
|
static int dhcp_message_type(unsigned char *popt)
|
||||||
{
|
{
|
||||||
if (NetReadLong((ulong *)popt) != htonl(BOOTP_VENDOR_MAGIC))
|
if (NetReadLong((ulong *)popt) != htonl(BOOTP_VENDOR_MAGIC))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -883,17 +881,17 @@ static int DhcpMessageType(unsigned char *popt)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DhcpSendRequestPkt(struct Bootp_t *bp_offer)
|
static void dhcp_send_request_packet(struct bootp_hdr *bp_offer)
|
||||||
{
|
{
|
||||||
uchar *pkt, *iphdr;
|
uchar *pkt, *iphdr;
|
||||||
struct Bootp_t *bp;
|
struct bootp_hdr *bp;
|
||||||
int pktlen, iplen, extlen;
|
int pktlen, iplen, extlen;
|
||||||
int eth_hdr_size;
|
int eth_hdr_size;
|
||||||
struct in_addr offered_ip;
|
struct in_addr offered_ip;
|
||||||
struct in_addr zero_ip;
|
struct in_addr zero_ip;
|
||||||
struct in_addr bcast_ip;
|
struct in_addr bcast_ip;
|
||||||
|
|
||||||
debug("DhcpSendRequestPkt: Sending DHCPREQUEST\n");
|
debug("dhcp_send_request_packet: Sending DHCPREQUEST\n");
|
||||||
pkt = net_tx_packet;
|
pkt = net_tx_packet;
|
||||||
memset((void *)pkt, 0, PKTSIZE);
|
memset((void *)pkt, 0, PKTSIZE);
|
||||||
|
|
||||||
|
@ -903,7 +901,7 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer)
|
||||||
iphdr = pkt; /* We'll need this later to set proper pkt size */
|
iphdr = pkt; /* We'll need this later to set proper pkt size */
|
||||||
pkt += IP_UDP_HDR_SIZE;
|
pkt += IP_UDP_HDR_SIZE;
|
||||||
|
|
||||||
bp = (struct Bootp_t *)pkt;
|
bp = (struct bootp_hdr *)pkt;
|
||||||
bp->bp_op = OP_BOOTREQUEST;
|
bp->bp_op = OP_BOOTREQUEST;
|
||||||
bp->bp_htype = HWT_ETHER;
|
bp->bp_htype = HWT_ETHER;
|
||||||
bp->bp_hlen = HWL_ETHER;
|
bp->bp_hlen = HWL_ETHER;
|
||||||
|
@ -954,17 +952,17 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer)
|
||||||
static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
|
static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
|
||||||
unsigned src, unsigned len)
|
unsigned src, unsigned len)
|
||||||
{
|
{
|
||||||
struct Bootp_t *bp = (struct Bootp_t *)pkt;
|
struct bootp_hdr *bp = (struct bootp_hdr *)pkt;
|
||||||
|
|
||||||
debug("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n",
|
debug("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n",
|
||||||
src, dest, len, dhcp_state);
|
src, dest, len, dhcp_state);
|
||||||
|
|
||||||
/* Filter out pkts we don't want */
|
/* Filter out pkts we don't want */
|
||||||
if (BootpCheckPkt(pkt, dest, src, len))
|
if (check_packet(pkt, dest, src, len))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
debug("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state:"
|
debug("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: "
|
||||||
" %d\n", src, dest, len, dhcp_state);
|
"%d\n", src, dest, len, dhcp_state);
|
||||||
|
|
||||||
switch (dhcp_state) {
|
switch (dhcp_state) {
|
||||||
case SELECTING:
|
case SELECTING:
|
||||||
|
@ -986,10 +984,10 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
|
||||||
|
|
||||||
if (NetReadLong((ulong *)&bp->bp_vend[0]) ==
|
if (NetReadLong((ulong *)&bp->bp_vend[0]) ==
|
||||||
htonl(BOOTP_VENDOR_MAGIC))
|
htonl(BOOTP_VENDOR_MAGIC))
|
||||||
DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp);
|
dhcp_process_options((u8 *)&bp->bp_vend[4], bp);
|
||||||
|
|
||||||
NetSetTimeout(5000, BootpTimeout);
|
NetSetTimeout(5000, bootp_timeout_handler);
|
||||||
DhcpSendRequestPkt(bp);
|
dhcp_send_request_packet(bp);
|
||||||
#ifdef CONFIG_SYS_BOOTFILE_PREFIX
|
#ifdef CONFIG_SYS_BOOTFILE_PREFIX
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SYS_BOOTFILE_PREFIX */
|
#endif /* CONFIG_SYS_BOOTFILE_PREFIX */
|
||||||
|
@ -999,17 +997,17 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
|
||||||
case REQUESTING:
|
case REQUESTING:
|
||||||
debug("DHCP State: REQUESTING\n");
|
debug("DHCP State: REQUESTING\n");
|
||||||
|
|
||||||
if (DhcpMessageType((u8 *)bp->bp_vend) == DHCP_ACK) {
|
if (dhcp_message_type((u8 *)bp->bp_vend) == DHCP_ACK) {
|
||||||
if (NetReadLong((ulong *)&bp->bp_vend[0]) ==
|
if (NetReadLong((ulong *)&bp->bp_vend[0]) ==
|
||||||
htonl(BOOTP_VENDOR_MAGIC))
|
htonl(BOOTP_VENDOR_MAGIC))
|
||||||
DhcpOptionsProcess((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 */
|
||||||
BootpCopyNetParams(bp);
|
store_net_params(bp);
|
||||||
dhcp_state = BOUND;
|
dhcp_state = BOUND;
|
||||||
printf("DHCP client bound to address %pI4 (%lu ms)\n",
|
printf("DHCP client bound to address %pI4 (%lu ms)\n",
|
||||||
&net_ip, get_timer(bootp_start));
|
&net_ip, get_timer(bootp_start));
|
||||||
bootstage_mark_name(BOOTSTAGE_ID_BOOTP_STOP,
|
bootstage_mark_name(BOOTSTAGE_ID_BOOTP_STOP,
|
||||||
"bootp_stop");
|
"bootp_stop");
|
||||||
|
|
||||||
net_auto_load();
|
net_auto_load();
|
||||||
return;
|
return;
|
||||||
|
@ -1022,11 +1020,10 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
|
||||||
puts("DHCP: INVALID STATE\n");
|
puts("DHCP: INVALID STATE\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DhcpRequest(void)
|
void dhcp_request(void)
|
||||||
{
|
{
|
||||||
BootpRequest();
|
bootp_request();
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_CMD_DHCP */
|
#endif /* CONFIG_CMD_DHCP */
|
||||||
|
|
14
net/bootp.h
14
net/bootp.h
|
@ -29,7 +29,7 @@ extern u8 *dhcp_vendorex_proc(u8 *e); /*rtn next e if mine,else NULL */
|
||||||
#define OPT_FIELD_SIZE 64
|
#define OPT_FIELD_SIZE 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct Bootp_t {
|
struct bootp_hdr {
|
||||||
uchar bp_op; /* Operation */
|
uchar bp_op; /* Operation */
|
||||||
# define OP_BOOTREQUEST 1
|
# define OP_BOOTREQUEST 1
|
||||||
# define OP_BOOTREPLY 2
|
# define OP_BOOTREPLY 2
|
||||||
|
@ -51,7 +51,7 @@ struct Bootp_t {
|
||||||
char bp_vend[OPT_FIELD_SIZE]; /* Vendor information */
|
char bp_vend[OPT_FIELD_SIZE]; /* Vendor information */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BOOTP_HDR_SIZE sizeof(struct Bootp_t)
|
#define BOOTP_HDR_SIZE sizeof(struct bootp_hdr)
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/*
|
/*
|
||||||
|
@ -59,16 +59,16 @@ struct Bootp_t {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* bootp.c */
|
/* bootp.c */
|
||||||
extern ulong BootpID; /* ID of cur BOOTP request */
|
extern ulong bootp_id; /* ID of cur BOOTP request */
|
||||||
extern int BootpTry;
|
extern int bootp_try;
|
||||||
|
|
||||||
|
|
||||||
/* Send a BOOTP request */
|
/* Send a BOOTP request */
|
||||||
extern void BootpReset(void);
|
void bootp_reset(void);
|
||||||
extern void BootpRequest(void);
|
void bootp_request(void);
|
||||||
|
|
||||||
/****************** DHCP Support *********************/
|
/****************** DHCP Support *********************/
|
||||||
extern void DhcpRequest(void);
|
void dhcp_request(void);
|
||||||
|
|
||||||
/* DHCP States */
|
/* DHCP States */
|
||||||
typedef enum { INIT,
|
typedef enum { INIT,
|
||||||
|
|
|
@ -381,16 +381,16 @@ restart:
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_CMD_DHCP)
|
#if defined(CONFIG_CMD_DHCP)
|
||||||
case DHCP:
|
case DHCP:
|
||||||
BootpReset();
|
bootp_reset();
|
||||||
net_ip.s_addr = 0;
|
net_ip.s_addr = 0;
|
||||||
DhcpRequest(); /* Basically same as BOOTP */
|
dhcp_request(); /* Basically same as BOOTP */
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case BOOTP:
|
case BOOTP:
|
||||||
BootpReset();
|
bootp_reset();
|
||||||
net_ip.s_addr = 0;
|
net_ip.s_addr = 0;
|
||||||
BootpRequest();
|
bootp_request();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined(CONFIG_CMD_RARP)
|
#if defined(CONFIG_CMD_RARP)
|
||||||
|
|
Loading…
Add table
Reference in a new issue