Lines 492-497
Link Here
|
492 |
return (sip); |
492 |
return (sip); |
493 |
} |
493 |
} |
494 |
|
494 |
|
|
|
495 |
/* This calculates the netmask that we should use for static routes. |
496 |
* This IS different from the calculation used to calculate the netmask |
497 |
* for an interface address. */ |
498 |
static unsigned long route_netmask (unsigned long ip_in) |
499 |
{ |
500 |
unsigned long p = ntohl (ip_in); |
501 |
unsigned long t; |
502 |
|
503 |
if (IN_CLASSA (p)) |
504 |
t = ~IN_CLASSA_NET; |
505 |
else { |
506 |
if (IN_CLASSB (p)) |
507 |
t = ~IN_CLASSB_NET; |
508 |
else { |
509 |
if (IN_CLASSC (p)) |
510 |
t = ~IN_CLASSC_NET; |
511 |
else |
512 |
t = 0; |
513 |
} |
514 |
} |
515 |
|
516 |
while (t & p) |
517 |
t >>= 1; |
518 |
|
519 |
return (htonl (~t)); |
520 |
} |
521 |
|
495 |
int parse_dhcpmessage (dhcp_t *dhcp, const dhcpmessage_t *message) |
522 |
int parse_dhcpmessage (dhcp_t *dhcp, const dhcpmessage_t *message) |
496 |
{ |
523 |
{ |
497 |
const unsigned char *p = message->options; |
524 |
const unsigned char *p = message->options; |
Lines 705-711
Link Here
|
705 |
memcpy (&static_routesp->destination.s_addr, p + i, 4); |
732 |
memcpy (&static_routesp->destination.s_addr, p + i, 4); |
706 |
memcpy (&static_routesp->gateway.s_addr, p + i + 4, 4); |
733 |
memcpy (&static_routesp->gateway.s_addr, p + i + 4, 4); |
707 |
static_routesp->netmask.s_addr = |
734 |
static_routesp->netmask.s_addr = |
708 |
get_netmask (static_routesp->destination.s_addr); |
735 |
route_netmask (static_routesp->destination.s_addr); |
709 |
} |
736 |
} |
710 |
break; |
737 |
break; |
711 |
|
738 |
|