Home | History | Annotate | Download | only in dhcpcd

Lines Matching refs:dhcp

2  * dhcpcd - DHCP client daemon
38 #include "dhcp.h"
82 * Without this some DHCP servers may skip the DNS entries in the DHCP replies.*/
93 * Without this some DHCP servers may skip the DNS entries in the DHCP replies.*/
301 #define get_option_raw(dhcp, opt) get_option(dhcp, opt, NULL, NULL)
303 get_option(const struct dhcp_message *dhcp, uint8_t opt, int *len, int *type)
305 const uint8_t *p = dhcp->options;
306 const uint8_t *e = p + sizeof(dhcp->options);
319 opt_buffer = xmalloc(sizeof(*dhcp));
340 p = dhcp->bootfile;
341 e = p + sizeof(dhcp->bootfile);
345 p = dhcp->servername;
346 e = p + sizeof(dhcp->servername);
378 get_option_addr(struct in_addr *a, const struct dhcp_message *dhcp,
381 const uint8_t *p = get_option_raw(dhcp, option);
390 get_option_uint32(uint32_t *i, const struct dhcp_message *dhcp, uint8_t option)
392 const uint8_t *p = get_option_raw(dhcp, option);
403 get_option_uint16(uint16_t *i, const struct dhcp_message *dhcp, uint8_t option)
405 const uint8_t *p = get_option_raw(dhcp, option);
416 get_option_uint8(uint8_t *i, const struct dhcp_message *dhcp, uint8_t option)
418 const uint8_t *p = get_option_raw(dhcp, option);
644 get_option_string(const struct dhcp_message *dhcp, uint8_t option)
651 p = get_option(dhcp, option, &len, &type);
708 get_option_routes(const struct dhcp_message *dhcp,
718 p = get_option(dhcp, DHO_CSR, &len, NULL);
721 p = get_option(dhcp, DHO_MSCSR, &len, NULL);
734 p = get_option(dhcp, DHO_STATICROUTE, &len, NULL);
753 p = get_option(dhcp, DHO_ROUTER, &len, NULL);
806 dhcp_message_add_addr(struct dhcp_message *dhcp,
812 p = dhcp->options;
818 len = p - (uint8_t *)dhcp;
819 if (len + 6 > sizeof(*dhcp)) {
834 struct dhcp_message *dhcp;
846 dhcp = xzalloc(sizeof (*dhcp));
847 m = (uint8_t *)dhcp;
848 p = dhcp->options;
856 dhcp->ciaddr = iface->addr.s_addr;
859 dhcp->ciaddr = lease->addr.s_addr;
862 dhcp->op = DHCP_BOOTREQUEST;
863 dhcp->hwtype = iface->family;
867 dhcp->hwlen = iface->hwlen;
868 memcpy(&dhcp->chaddr, &iface->hwaddr, iface->hwlen);
873 dhcp->ciaddr == 0 &&
876 dhcp->flags = htons(BROADCAST_FLAG);
880 dhcp->secs = htons((uint16_t)UINT16_MAX);
882 dhcp->secs = htons(up);
884 dhcp->xid = iface->state->xid;
885 dhcp->cookie = htonl(MAGIC_COOKIE);
937 * handle DHCP packets any bigger. */
970 * confuses some DHCP servers when updating DNS.
1031 /* Some crappy DHCP servers think they have to obey the BOOTP minimum
1038 *message = dhcp;
1043 write_lease(const struct interface *iface, const struct dhcp_message *dhcp)
1046 ssize_t bytes = sizeof(*dhcp);
1047 const uint8_t *p = dhcp->options;
1048 const uint8_t *e = p + sizeof(dhcp->options);
1053 if (is_bootp(dhcp)) {
1078 bytes = p - (const uint8_t *)dhcp;
1087 bytes = write(fd, dhcp, bytes);
1096 struct dhcp_message *dhcp;
1108 dhcp = xmalloc(sizeof(*dhcp));
1109 memset(dhcp, 0, sizeof(*dhcp));
1110 bytes = read(fd, dhcp, sizeof(*dhcp));
1113 free(dhcp);
1114 dhcp = NULL;
1116 return dhcp;
1211 /* Some DHCP servers return NULL strings */
1298 configure_env(char **env, const char *prefix, const struct dhcp_message *dhcp,
1314 get_option_uint8(&overl, dhcp, DHO_OPTIONSOVERLOADED);
1322 if (get_option_raw(dhcp, opt->option))
1325 if (dhcp->yiaddr || dhcp->ciaddr)
1327 if (*dhcp->bootfile && !(overl & 1))
1329 if (*dhcp->servername && !(overl & 2))
1335 if (dhcp->yiaddr || dhcp->ciaddr) {
1336 /* Set some useful variables that we derive from the DHCP
1338 addr.s_addr = dhcp->yiaddr ? dhcp->yiaddr : dhcp->ciaddr;
1340 if (get_option_addr(&net, dhcp, DHO_SUBNETMASK) == -1) {
1347 if (get_option_addr(&brd, dhcp, DHO_BROADCAST) == -1) {
1351 addr.s_addr = dhcp->yiaddr & net.s_addr;
1355 if (*dhcp->bootfile && !(overl & 1))
1356 setvar(&ep, prefix, "filename", (const char *)dhcp->bootfile);
1357 if (*dhcp->servername && !(overl & 2))
1358 setvar(&ep, prefix, "server_name", (const char *)dhcp->servername);
1366 p = get_option(dhcp, opt->option, &pl, NULL);
1388 get_lease(struct dhcp_lease *lease, const struct dhcp_message *dhcp)
1392 lease->cookie = dhcp->cookie;
1394 if (dhcp->yiaddr)
1395 lease->addr.s_addr = dhcp->yiaddr;
1397 lease->addr.s_addr = dhcp->ciaddr;
1398 if (get_option_addr(&lease->net, dhcp, DHO_SUBNETMASK) == -1)
1400 if (get_option_addr(&lease->brd, dhcp, DHO_BROADCAST) == -1)
1402 if (get_option_uint32(&lease->leasetime, dhcp, DHO_LEASETIME) == 0) {
1409 if (get_option_uint32(&lease->renewaltime, dhcp, DHO_RENEWALTIME) != 0)
1411 if (get_option_uint32(&lease->rebindtime, dhcp, DHO_REBINDTIME) != 0)
1413 if (get_option_addr(&lease->server, dhcp, DHO_SERVERID) != 0)