Lines Matching refs:msg
48 void dump_dhcp_msg(dhcp_msg *msg, int len);
164 int decode_dhcp_msg(dhcp_msg *msg, int len, dhcp_info *info) in decode_dhcp_msg() argument
175 if (msg->options[0] != OPT_COOKIE1) return -1; in decode_dhcp_msg()
176 if (msg->options[1] != OPT_COOKIE2) return -1; in decode_dhcp_msg()
177 if (msg->options[2] != OPT_COOKIE3) return -1; in decode_dhcp_msg()
178 if (msg->options[3] != OPT_COOKIE4) return -1; in decode_dhcp_msg()
180 x = msg->options + 4; in decode_dhcp_msg()
230 info->ipaddr = msg->yiaddr; in decode_dhcp_msg()
247 void dump_dhcp_msg(dhcp_msg *msg, int len) in dump_dhcp_msg() argument
263 if (msg->op == OP_BOOTREQUEST) in dump_dhcp_msg()
265 else if (msg->op == OP_BOOTREPLY) in dump_dhcp_msg()
270 name, msg->op, msg->htype, msg->hlen, msg->hops); in dump_dhcp_msg()
272 ntohl(msg->xid), ntohs(msg->secs), ntohs(msg->flags), len); in dump_dhcp_msg()
273 ALOGD("ciaddr = %s", ipaddr(msg->ciaddr)); in dump_dhcp_msg()
274 ALOGD("yiaddr = %s", ipaddr(msg->yiaddr)); in dump_dhcp_msg()
275 ALOGD("siaddr = %s", ipaddr(msg->siaddr)); in dump_dhcp_msg()
276 ALOGD("giaddr = %s", ipaddr(msg->giaddr)); in dump_dhcp_msg()
278 c = msg->hlen > 16 ? 16 : msg->hlen; in dump_dhcp_msg()
279 hex2str(buf, sizeof(buf), msg->chaddr, c); in dump_dhcp_msg()
283 unsigned char x = msg->sname[n]; in dump_dhcp_msg()
286 msg->sname[n] = '.'; in dump_dhcp_msg()
289 msg->sname[63] = 0; in dump_dhcp_msg()
292 unsigned char x = msg->file[n]; in dump_dhcp_msg()
295 msg->file[n] = '.'; in dump_dhcp_msg()
298 msg->file[127] = 0; in dump_dhcp_msg()
300 ALOGD("sname = '%s'", msg->sname); in dump_dhcp_msg()
301 ALOGD("file = '%s'", msg->file); in dump_dhcp_msg()
305 x = msg->options + 4; in dump_dhcp_msg()
342 static int send_message(int sock, int if_index, dhcp_msg *msg, int size) in send_message() argument
345 dump_dhcp_msg(msg, size); in send_message()
347 return send_packet(sock, if_index, msg, size, INADDR_ANY, INADDR_BROADCAST, in send_message()
351 static int is_valid_reply(dhcp_msg *msg, dhcp_msg *reply, int sz) in is_valid_reply() argument
361 if (reply->xid != msg->xid) { in is_valid_reply()
363 ntohl(msg->xid)); in is_valid_reply()
366 if (reply->htype != msg->htype) { in is_valid_reply()
367 if (verbose) ALOGD("Wrong Htype %d != %d\n", reply->htype, msg->htype); in is_valid_reply()
370 if (reply->hlen != msg->hlen) { in is_valid_reply()
371 if (verbose) ALOGD("Wrong Hlen %d != %d\n", reply->hlen, msg->hlen); in is_valid_reply()
374 if (memcmp(msg->chaddr, reply->chaddr, msg->hlen)) { in is_valid_reply()
375 if (verbose) ALOGD("Wrong chaddr %x != %x\n", *(reply->chaddr),*(msg->chaddr)); in is_valid_reply()
392 dhcp_msg *msg; in dhcp_init_ifc() local
443 msg = NULL; in dhcp_init_ifc()
446 msg = &discover_msg; in dhcp_init_ifc()
447 size = init_dhcp_discover_msg(msg, hwaddr, xid); in dhcp_init_ifc()
450 msg = &request_msg; in dhcp_init_ifc()
451 size = init_dhcp_request_msg(msg, hwaddr, xid, info.ipaddr, info.serveraddr); in dhcp_init_ifc()
457 r = send_message(s, if_index, msg, size); in dhcp_init_ifc()