Home | History | Annotate | Download | only in dhcpcd

Lines Matching refs:dhcp

2  * dhcpcd - DHCP client daemon
38 #include "dhcp.h"
297 #define get_option_raw(dhcp, opt) get_option(dhcp, opt, NULL, NULL)
299 get_option(const struct dhcp_message *dhcp, uint8_t opt, int *len, int *type)
301 const uint8_t *p = dhcp->options;
302 const uint8_t *e = p + sizeof(dhcp->options);
315 opt_buffer = xmalloc(sizeof(*dhcp));
336 p = dhcp->bootfile;
337 e = p + sizeof(dhcp->bootfile);
341 p = dhcp->servername;
342 e = p + sizeof(dhcp->servername);
374 get_option_addr(struct in_addr *a, const struct dhcp_message *dhcp,
377 const uint8_t *p = get_option_raw(dhcp, option);
386 get_option_uint32(uint32_t *i, const struct dhcp_message *dhcp, uint8_t option)
388 const uint8_t *p = get_option_raw(dhcp, option);
399 get_option_uint16(uint16_t *i, const struct dhcp_message *dhcp, uint8_t option)
401 const uint8_t *p = get_option_raw(dhcp, option);
412 get_option_uint8(uint8_t *i, const struct dhcp_message *dhcp, uint8_t option)
414 const uint8_t *p = get_option_raw(dhcp, option);
640 get_option_string(const struct dhcp_message *dhcp, uint8_t option)
647 p = get_option(dhcp, option, &len, &type);
704 get_option_routes(const struct dhcp_message *dhcp,
714 p = get_option(dhcp, DHO_CSR, &len, NULL);
717 p = get_option(dhcp
730 p = get_option(dhcp, DHO_STATICROUTE, &len, NULL);
749 p = get_option(dhcp, DHO_ROUTER, &len, NULL);
802 dhcp_message_add_addr(struct dhcp_message *dhcp,
808 p = dhcp->options;
814 len = p - (uint8_t *)dhcp;
815 if (len + 6 > sizeof(*dhcp)) {
830 struct dhcp_message *dhcp;
842 dhcp = xzalloc(sizeof (*dhcp));
843 m = (uint8_t *)dhcp;
844 p = dhcp->options;
852 dhcp->ciaddr = iface->addr.s_addr;
855 dhcp->ciaddr = lease->addr.s_addr;
858 dhcp->op = DHCP_BOOTREQUEST;
859 dhcp->hwtype = iface->family;
863 dhcp->hwlen = iface->hwlen;
864 memcpy(&dhcp->chaddr, &iface->hwaddr, iface->hwlen);
869 dhcp->ciaddr == 0 &&
872 dhcp->flags = htons(BROADCAST_FLAG);
876 dhcp->secs = htons((uint16_t)UINT16_MAX);
878 dhcp->secs = htons(up);
880 dhcp->xid = iface->state->xid;
881 dhcp->cookie = htonl(MAGIC_COOKIE);
933 * handle DHCP packets any bigger. */
966 * confuses some DHCP servers when updating DNS.
1027 /* Some crappy DHCP servers think they have to obey the BOOTP minimum
1034 *message = dhcp;
1039 write_lease(const struct interface *iface, const struct dhcp_message *dhcp)
1042 ssize_t bytes = sizeof(*dhcp);
1043 const uint8_t *p = dhcp->options;
1044 const uint8_t *e = p + sizeof(dhcp->options);
1049 if (is_bootp(dhcp)) {
1074 bytes = p - (const uint8_t *)dhcp;
1083 bytes = write(fd, dhcp, bytes);
1092 struct dhcp_message *dhcp;
1104 dhcp = xmalloc(sizeof(*dhcp));
1105 memset(dhcp, 0, sizeof(*dhcp));
1106 bytes = read(fd, dhcp, sizeof(*dhcp));
1109 free(dhcp);
1110 dhcp = NULL;
1112 return dhcp;
1207 /* Some DHCP servers return NULL strings */
1294 configure_env(char **env, const char *prefix, const struct dhcp_message *dhcp,
1310 get_option_uint8(&overl, dhcp, DHO_OPTIONSOVERLOADED);
1318 if (get_option_raw(dhcp, opt->option))
1321 if (dhcp->yiaddr || dhcp->ciaddr)
1323 if (*dhcp->bootfile && !(overl & 1))
1325 if (*dhcp->servername && !(overl & 2))
1331 if (dhcp->yiaddr || dhcp->ciaddr) {
1332 /* Set some useful variables that we derive from the DHCP
1334 addr.s_addr = dhcp->yiaddr ? dhcp->yiaddr : dhcp->ciaddr;
1336 if (get_option_addr(&net, dhcp, DHO_SUBNETMASK) == -1) {
1343 if (get_option_addr(&brd, dhcp, DHO_BROADCAST) == -1) {
1347 addr.s_addr = dhcp->yiaddr & net.s_addr;
1351 if (*dhcp->bootfile && !(overl & 1))
1352 setvar(&ep, prefix, "filename", (const char *)dhcp->bootfile);
1353 if (*dhcp->servername && !(overl & 2))
1354 setvar(&ep, prefix, "server_name", (const char *)dhcp->servername);
1362 p = get_option(dhcp, opt->option, &pl, NULL);
1384 get_lease(struct dhcp_lease *lease, const struct dhcp_message *dhcp)
1388 lease->cookie = dhcp->cookie;
1390 if (dhcp->yiaddr)
1391 lease->addr.s_addr = dhcp->yiaddr;
1393 lease->addr.s_addr = dhcp->ciaddr;
1394 if (get_option_addr(&lease->net, dhcp, DHO_SUBNETMASK) == -1)
1396 if (get_option_addr(&lease->brd, dhcp, DHO_BROADCAST) == -1)
1398 if (get_option_uint32(&lease->leasetime, dhcp, DHO_LEASETIME) == 0) {
1405 if (get_option_uint32(&lease->renewaltime, dhcp, DHO_RENEWALTIME) != 0)
1407 if (get_option_uint32(&lease->rebindtime, dhcp, DHO_REBINDTIME) != 0)
1409 if (get_option_addr(&lease->server, dhcp, DHO_SERVERID) != 0)