Lines Matching refs:msg
166 int decode_dhcp_msg(dhcp_msg *msg, int len, dhcp_info *info) in decode_dhcp_msg() argument
177 if (msg->options[0] != OPT_COOKIE1) return -1; in decode_dhcp_msg()
178 if (msg->options[1] != OPT_COOKIE2) return -1; in decode_dhcp_msg()
179 if (msg->options[2] != OPT_COOKIE3) return -1; in decode_dhcp_msg()
180 if (msg->options[3] != OPT_COOKIE4) return -1; in decode_dhcp_msg()
182 x = msg->options + 4; in decode_dhcp_msg()
232 info->ipaddr = msg->yiaddr; in decode_dhcp_msg()
249 void dump_dhcp_msg(dhcp_msg *msg, int len) in dump_dhcp_msg() argument
265 if (msg->op == OP_BOOTREQUEST) in dump_dhcp_msg()
267 else if (msg->op == OP_BOOTREPLY) in dump_dhcp_msg()
272 name, msg->op, msg->htype, msg->hlen, msg->hops); in dump_dhcp_msg()
274 ntohl(msg->xid), ntohs(msg->secs), ntohs(msg->flags), len); in dump_dhcp_msg()
275 ALOGD("ciaddr = %s", ipaddr(msg->ciaddr)); in dump_dhcp_msg()
276 ALOGD("yiaddr = %s", ipaddr(msg->yiaddr)); in dump_dhcp_msg()
277 ALOGD("siaddr = %s", ipaddr(msg->siaddr)); in dump_dhcp_msg()
278 ALOGD("giaddr = %s", ipaddr(msg->giaddr)); in dump_dhcp_msg()
280 c = msg->hlen > 16 ? 16 : msg->hlen; in dump_dhcp_msg()
281 hex2str(buf, sizeof(buf), msg->chaddr, c); in dump_dhcp_msg()
285 unsigned char x = msg->sname[n]; in dump_dhcp_msg()
288 msg->sname[n] = '.'; in dump_dhcp_msg()
291 msg->sname[63] = 0; in dump_dhcp_msg()
294 unsigned char x = msg->file[n]; in dump_dhcp_msg()
297 msg->file[n] = '.'; in dump_dhcp_msg()
300 msg->file[127] = 0; in dump_dhcp_msg()
302 ALOGD("sname = '%s'", msg->sname); in dump_dhcp_msg()
303 ALOGD("file = '%s'", msg->file); in dump_dhcp_msg()
307 x = msg->options + 4; in dump_dhcp_msg()
344 static int send_message(int sock, int if_index, dhcp_msg *msg, int size) in send_message() argument
347 dump_dhcp_msg(msg, size); in send_message()
349 return send_packet(sock, if_index, msg, size, INADDR_ANY, INADDR_BROADCAST, in send_message()
353 static int is_valid_reply(dhcp_msg *msg, dhcp_msg *reply, int sz) in is_valid_reply() argument
363 if (reply->xid != msg->xid) { in is_valid_reply()
365 ntohl(msg->xid)); in is_valid_reply()
368 if (reply->htype != msg->htype) { in is_valid_reply()
369 if (verbose) ALOGD("Wrong Htype %d != %d\n", reply->htype, msg->htype); in is_valid_reply()
372 if (reply->hlen != msg->hlen) { in is_valid_reply()
373 if (verbose) ALOGD("Wrong Hlen %d != %d\n", reply->hlen, msg->hlen); in is_valid_reply()
376 if (memcmp(msg->chaddr, reply->chaddr, msg->hlen)) { in is_valid_reply()
377 if (verbose) ALOGD("Wrong chaddr %x != %x\n", *(reply->chaddr),*(msg->chaddr)); in is_valid_reply()
394 dhcp_msg *msg; in dhcp_init_ifc() local
445 msg = NULL; in dhcp_init_ifc()
448 msg = &discover_msg; in dhcp_init_ifc()
449 size = init_dhcp_discover_msg(msg, hwaddr, xid); in dhcp_init_ifc()
452 msg = &request_msg; in dhcp_init_ifc()
453 size = init_dhcp_request_msg(msg, hwaddr, xid, info.ipaddr, info.serveraddr); in dhcp_init_ifc()
459 r = send_message(s, if_index, msg, size); in dhcp_init_ifc()