Lines Matching defs:msg

166 int decode_dhcp_msg(dhcp_msg *msg, int len, dhcp_info *info)
177 if (msg->options[0] != OPT_COOKIE1) return -1;
178 if (msg->options[1] != OPT_COOKIE2) return -1;
179 if (msg->options[2] != OPT_COOKIE3) return -1;
180 if (msg->options[3] != OPT_COOKIE4) return -1;
182 x = msg->options + 4;
232 info->ipaddr = msg->yiaddr;
249 void dump_dhcp_msg(dhcp_msg *msg, int len)
265 if (msg->op == OP_BOOTREQUEST)
267 else if (msg->op == OP_BOOTREPLY)
272 name, msg->op, msg->htype, msg->hlen, msg->hops);
274 ntohl(msg->xid), ntohs(msg->secs), ntohs(msg->flags), len);
275 ALOGD("ciaddr = %s", ipaddr(msg->ciaddr));
276 ALOGD("yiaddr = %s", ipaddr(msg->yiaddr));
277 ALOGD("siaddr = %s", ipaddr(msg->siaddr));
278 ALOGD("giaddr = %s", ipaddr(msg->giaddr));
280 c = msg->hlen > 16 ? 16 : msg->hlen;
281 hex2str(buf, msg->chaddr, c);
285 if ((msg->sname[n] < ' ') || (msg->sname[n] > 127)) {
286 if (msg->sname[n] == 0) break;
287 msg->sname[n] = '.';
290 msg->sname[63] = 0;
293 if ((msg->file[n] < ' ') || (msg->file[n] > 127)) {
294 if (msg->file[n] == 0) break;
295 msg->file[n] = '.';
298 msg->file[127] = 0;
300 ALOGD("sname = '%s'", msg->sname);
301 ALOGD("file = '%s'", msg->file);
305 x = msg->options + 4;
342 static int send_message(int sock, int if_index, dhcp_msg *msg, int size)
345 dump_dhcp_msg(msg, size);
347 return send_packet(sock, if_index, msg, size, INADDR_ANY, INADDR_BROADCAST,
351 static int is_valid_reply(dhcp_msg *msg, dhcp_msg *reply, int sz)
361 if (reply->xid != msg->xid) {
363 ntohl(msg->xid));
366 if (reply->htype != msg->htype) {
367 if (verbose) ALOGD("netcfg: Wrong Htype %d != %d\n", reply->htype, msg->htype);
370 if (reply->hlen != msg->hlen) {
371 if (verbose) ALOGD("netcfg: Wrong Hlen %d != %d\n", reply->hlen, msg->hlen);
374 if (memcmp(msg->chaddr, reply->chaddr, msg->hlen)) {
375 if (verbose) ALOGD("netcfg: Wrong chaddr %x != %x\n", *(reply->chaddr),*(msg->chaddr));
392 dhcp_msg *msg;
443 msg = NULL;
446 msg = &discover_msg;
447 size = init_dhcp_discover_msg(msg, hwaddr, xid);
450 msg = &request_msg;
451 size = init_dhcp_request_msg(msg, hwaddr, xid, info.ipaddr, info.serveraddr);
457 r = send_message(s, if_index, msg, size);
459 printerr("error sending dhcp msg: %s\n", strerror(errno));