49 |
bootp.secs = htons(time(NULL) - dev->open_time); |
bootp.secs = htons(time(NULL) - dev->open_time); |
50 |
memcpy(bootp.chaddr, dev->hwaddr, 16); |
memcpy(bootp.chaddr, dev->hwaddr, 16); |
51 |
|
|
52 |
DEBUG(("-> bootp xid 0x%08x secs 0x%08x ", |
dprintf("-> bootp xid 0x%08x secs 0x%08x ", |
53 |
bootp.xid, ntohs(bootp.secs))); |
bootp.xid, ntohs(bootp.secs)); |
54 |
|
|
55 |
return packet_send(dev, iov, 2); |
return packet_send(dev, iov, 2); |
56 |
} |
} |
153 |
|
|
154 |
/* |
/* |
155 |
* Receive a bootp reply and parse packet |
* Receive a bootp reply and parse packet |
156 |
|
* Returns: |
157 |
|
*-1 = Error in packet_recv, try again later |
158 |
|
* 0 = Unexpected packet, discarded |
159 |
|
* 1 = Correctly received and parsed packet |
160 |
*/ |
*/ |
161 |
int bootp_recv_reply(struct netdev *dev) |
int bootp_recv_reply(struct netdev *dev) |
162 |
{ |
{ |
171 |
|
|
172 |
ret = packet_recv(iov, 3); |
ret = packet_recv(iov, 3); |
173 |
if (ret <= 0) |
if (ret <= 0) |
174 |
return ret; |
return -1; |
175 |
|
|
176 |
if (ret < sizeof(struct bootp_hdr) || |
if (ret < sizeof(struct bootp_hdr) || |
177 |
bootp.op != BOOTP_REPLY || /* RFC951 7.5 */ |
bootp.op != BOOTP_REPLY || /* RFC951 7.5 */ |