Lines Matching defs:msg

189 int decode_dhcp_msg(dhcp_msg *msg, int len, dhcp_info *info)
200 if (msg->options[0] != OPT_COOKIE1) return -1;
201 if (msg->options[1] != OPT_COOKIE2) return -1;
202 if (msg->options[2] != OPT_COOKIE3) return -1;
203 if (msg->options[3] != OPT_COOKIE4) return -1;
205 x = msg->options + 4;
251 info->ipaddr = msg->yiaddr;
268 void dump_dhcp_msg(dhcp_msg *msg, int len)
284 if (msg->op == OP_BOOTREQUEST)
286 else if (msg->op == OP_BOOTREPLY)
291 name, msg->op, msg->htype, msg->hlen, msg->hops);
293 ntohl(msg->xid), ntohs(msg->secs), ntohs(msg->flags), len);
294 LOGD("ciaddr = %s", ipaddr(msg->ciaddr));
295 LOGD("yiaddr = %s", ipaddr(msg->yiaddr));
296 LOGD("siaddr = %s", ipaddr(msg->siaddr));
297 LOGD("giaddr = %s", ipaddr(msg->giaddr));
299 c = msg->hlen > 16 ? 16 : msg->hlen;
300 hex2str(buf, msg->chaddr, c);
304 if ((msg->sname[n] < ' ') || (msg->sname[n] > 127)) {
305 if (msg->sname[n] == 0) break;
306 msg->sname[n] = '.';
309 msg->sname[63] = 0;
312 if ((msg->file[n] < ' ') || (msg->file[n] > 127)) {
313 if (msg->file[n] == 0) break;
314 msg->file[n] = '.';
317 msg->file[127] = 0;
319 LOGD("sname = '%s'", msg->sname);
320 LOGD("file = '%s'", msg->file);
324 x = msg->options + 4;
361 static int send_message(int sock, int if_index, dhcp_msg *msg, int size)
364 dump_dhcp_msg(msg, size);
366 return send_packet(sock, if_index, msg, size, INADDR_ANY, INADDR_BROADCAST,
370 static int is_valid_reply(dhcp_msg *msg, dhcp_msg *reply, int sz)
380 if (reply->xid != msg->xid) {
382 ntohl(msg->xid));
385 if (reply->htype != msg->htype) {
386 if (verbose) LOGD("netcfg: Wrong Htype %d != %d\n", reply->htype, msg->htype);
389 if (reply->hlen != msg->hlen) {
390 if (verbose) LOGD("netcfg: Wrong Hlen %d != %d\n", reply->hlen, msg->hlen);
393 if (memcmp(msg->chaddr, reply->chaddr, msg->hlen)) {
394 if (verbose) LOGD("netcfg: Wrong chaddr %x != %x\n", *(reply->chaddr),*(msg->chaddr));
411 dhcp_msg *msg;
462 msg = NULL;
465 msg = &discover_msg;
466 size = init_dhcp_discover_msg(msg, hwaddr, xid);
469 msg = &request_msg;
470 size = init_dhcp_request_msg(msg, hwaddr, xid, info.ipaddr, info.serveraddr);
476 r = send_message(s, if_index, msg, size);
478 printerr("error sending dhcp msg: %s\n", strerror(errno));