Home | History | Annotate | Download | only in src

Lines Matching refs:opt

81 #define option_len(opt) ((int)(((unsigned char *)(opt))[1]))
82 #define option_ptr(opt, i) ((void *)&(((unsigned char *)(opt))[2u+(unsigned int)(i)]))
84 static int sanitise(unsigned char *opt, char *buf);
86 static unsigned int calc_time(struct dhcp_context *context, struct dhcp_config *config, unsigned char *opt);
87 static void option_put(struct dhcp_packet *mess, unsigned char *end, int opt, int len, unsigned int val);
89 int opt, char *string, int null_term);
90 static struct in_addr option_addr(unsigned char *opt);
91 static struct in_addr option_addr_arr(unsigned char *opt, int offset);
92 static unsigned int option_uint(unsigned char *opt, int i, int size);
96 static unsigned char *option_find1(unsigned char *p, unsigned char *end, int opt, int minsize);
113 static void match_vendor_opts(unsigned char *opt, struct dhcp_opt *dopt);
124 unsigned char *opt, *clid = NULL;
165 if ((opt = option_find(mess, sz, OPTION_MESSAGE_TYPE, 1)))
167 mess_type = option_uint(opt, 0, 1);
176 if ((opt = option_find(mess, sz, OPTION_MAXMESSAGE, 2)))
178 size_t size = (size_t)option_uint(opt, 0, 2) - 28;
197 if ((opt = option_find(mess, sz, OPTION_AGENT_ID, 1)))
205 unsigned int total = option_len(opt) + 2;
211 memcpy(agent_id, opt, total);
215 if ((sopt = option_find1(option_ptr(opt, 0), option_ptr(opt, option_len(opt)), SUBOPT_SUBNET_SELECT, INADDRSZ)))
219 if ((sopt = option_find1(option_ptr(opt, 0), option_ptr(opt, option_len(opt)), SUBOPT_SERVER_OR, INADDRSZ)))
236 if ((sopt = option_find1(option_ptr(opt, 0), option_ptr(opt, option_len(opt)), search, 1)) &&
248 if (subnet_addr.s_addr == 0 && (opt = option_find(mess, sz, OPTION_SUBNET_SELECT, INADDRSZ)))
249 subnet_addr = option_addr(opt);
252 if ((opt = option_find(mess, sz, OPTION_CLIENT_ID, 1)))
254 clid_len = option_len(opt);
255 clid = option_ptr(opt, 0);
499 if ((opt = option_find(mess, sz, OPTION_CLIENT_FQDN, 4)))
502 int len = option_len(opt);
504 unsigned char *pp, *op = option_ptr(opt, 0);
542 else if ((opt = option_find(mess, sz, OPTION_HOSTNAME, 1)))
544 int len = option_len(opt);
545 memcpy(daemon->dhcp_buff, option_ptr(opt, 0), len);
609 if (!(opt = option_find(mess, sz, o->opt, 1)) ||
610 o->len > option_len(opt))
617 if (memcmp_masked(o->val, option_ptr(opt, 0), o->len, o->u.wildcard_mask))
621 for (i = 0; i <= (option_len(opt) - o->len); )
623 if (memcmp(o->val, option_ptr(opt, i), o->len) == 0)
653 if ((opt = option_find(mess, sz, OPTION_USER_CLASS, 1)))
655 unsigned char *ucp = option_ptr(opt, 0);
657 for (j = 0; j < option_len(opt); j += ucp[j] + 1);
658 if (j == option_len(opt))
659 for (j = 0; j < option_len(opt); j = tmp)
677 if ((opt = option_find(mess, sz, mopt, 1)))
680 for (i = 0; i <= (option_len(opt) - vendor->len); i++)
681 if (memcmp(vendor->data, option_ptr(opt, i), vendor->len) == 0)
712 (opt = option_find(mess, sz, OPTION_VENDOR_ID, 9)) &&
713 strncmp(option_ptr(opt, 0), "PXEClient", 9) == 0)
715 if ((opt = option_find(mess, sz, OPTION_PXE_UUID, 17)))
717 memcpy(pxe_uuid, option_ptr(opt, 0), 17);
723 (opt = option_find(mess, sz, OPTION_VENDOR_CLASS_OPT, 1)) &&
724 (opt = option_find1(option_ptr(opt, 0), option_ptr(opt, option_len(opt)), SUBOPT_PXE_BOOT_ITEM, 4)))
727 int type = option_uint(opt, 0, 2);
728 int layer = option_uint(opt, 2, 2);
741 memcpy(save71, option_ptr(opt, 0), 4);
766 opt71.opt = SUBOPT_PXE_BOOT_ITEM;
777 if ((opt = option_find(mess, sz, OPTION_ARCH, 2)))
779 pxearch = option_uint(opt, 0, 2);
824 if ((opt = option_find(mess, sz, OPTION_REQUESTED_OPTIONS, 0)))
827 memcpy(req_options, option_ptr(opt, 0), option_len(opt));
828 req_options[option_len(opt)] = OPTION_END;
834 if (!(opt = option_find(mess, sz, OPTION_SERVER_IDENTIFIER, INADDRSZ)) ||
835 option_addr(opt).s_addr != server_id(context, override, fallback).s_addr)
841 if (!(opt = option_find(mess, sz, OPTION_REQUESTED_IP, INADDRSZ)))
844 log_packet("DHCPDECLINE", option_ptr(opt, 0), emac, emac_len, iface_name, daemon->dhcp_buff, mess->xid);
846 if (lease && lease->addr.s_addr == option_addr(opt).s_addr)
850 config->addr.s_addr == option_addr(opt).s_addr)
867 !(opt = option_find(mess, sz, OPTION_SERVER_IDENTIFIER, INADDRSZ)) ||
868 option_addr(opt).s_addr != server_id(context, override, fallback).s_addr)
884 opt = NULL;
892 if ((opt = option_find(mess, sz, OPTION_REQUESTED_IP, INADDRSZ)))
893 addr = option_addr(opt);
931 else if (opt && address_available(context, addr, netid) && !lease_find_by_addr(addr) &&
940 log_packet("DHCPDISCOVER", opt ? option_ptr(opt, 0) : NULL, emac, emac_len, iface_name, message, mess->xid);
972 if ((opt = option_find(mess, sz, OPTION_REQUESTED_IP, INADDRSZ)))
975 mess->yiaddr = option_addr(opt);
980 if ((opt = option_find(mess, sz, OPTION_SERVER_IDENTIFIER, INADDRSZ)))
987 if (option_addr(opt).s_addr != override.s_addr)
993 if (context->local.s_addr == option_addr(opt).s_addr)
1145 if ((opt = option_find(mess, sz, OPTION_USER_CLASS, 1)))
1147 int len = option_len(opt);
1148 unsigned char *ucp = option_ptr(opt, 0);
1160 if ((opt = option_find(mess, sz, OPTION_VENDOR_ID, 1)))
1162 int len = option_len(opt);
1163 unsigned char *ucp = option_ptr(opt, 0);
1172 if ((opt = option_find(mess, sz, OPTION_HOSTNAME, 1)))
1174 int len = option_len(opt);
1175 unsigned char *ucp = option_ptr(opt, 0);
1337 static unsigned int calc_time(struct dhcp_context *context, struct dhcp_config *config, unsigned char *opt)
1341 if (opt)
1343 unsigned int req_time = option_uint(opt, 0, 4);
1363 static int sanitise(unsigned char *opt, char *buf)
1370 if (!opt)
1373 p = option_ptr(opt, 0);
1375 for (i = option_len(opt); i > 0; i--)
1448 static unsigned char *option_find1(unsigned char *p, unsigned char *end, int opt, int minsize)
1455 return opt == OPTION_END ? p : NULL;
1466 if (*p == opt && opt_len >= minsize)
1498 static struct in_addr option_addr_arr(unsigned char *opt, int offset)
1504 memcpy(&ret, option_ptr(opt, offset), INADDRSZ);
1509 static struct in_addr option_addr(unsigned char *opt)
1511 return option_addr_arr(opt, 0);
1514 static unsigned int option_uint(unsigned char *opt, int offset, int size)
1519 unsigned char *p = option_ptr(opt, offset);
1630 static unsigned char *free_space(struct dhcp_packet *mess, unsigned char *end, int opt, int len)
1680 my_syslog(MS_DHCP | LOG_WARNING, _("cannot send DHCP/BOOTP option %d: no space left in packet"), opt);
1685 *(p++) = opt;
1692 static void option_put(struct dhcp_packet *mess, unsigned char *end, int opt, int len, unsigned int val)
1695 unsigned char *p = free_space(mess, end, opt, len);
1702 static void option_put_string(struct dhcp_packet *mess, unsigned char *end, int opt,
1711 if ((p = free_space(mess, end, opt, len)))
1716 static int do_opt(struct dhcp_opt *opt, unsigned char *p, struct dhcp_context *context, int null_term)
1718 int len = opt->len;
1720 if ((opt->flags & DHOPT_STRING) && null_term && len != 255)
1725 if (context && (opt->flags & DHOPT_ADDR))
1728 struct in_addr *a = (struct in_addr *)opt->val;
1729 for (j = 0; j < opt->len; j+=INADDRSZ, a++)
1740 memcpy(p, opt->val, len);
1745 static int in_list(unsigned char *list, int opt)
1754 if (opt == list[i])
1760 static struct dhcp_opt *option_find2(struct dhcp_netid *netid, struct dhcp_opt *opts, int opt)
1764 if (tmp->opt == opt && !(tmp->flags & (DHOPT_ENCAPSULATE | DHOPT_VENDOR)))
1768 return netid ? option_find2(NULL, opts, opt) : NULL;
1773 static void match_vendor_opts(unsigned char *opt, struct dhcp_opt *dopt)
1778 if (opt && (dopt->flags & DHOPT_VENDOR))
1783 for (i = 0; i <= (option_len(opt) - len); i++)
1784 if (len == 0 || memcmp(dopt->u.vendor_class, option_ptr(opt, i), len) == 0)
1793 static void do_encap_opts(struct dhcp_opt *opt, int encap, int flag,
1801 for (enc_len = 0, start = opt; opt; opt = opt->next)
1802 if (opt->flags & flag)
1804 int new = do_opt(opt, NULL, NULL, null_term) + 2;
1810 for (; start && start != opt; start = start->next)
1814 *(p++) = start->opt;
1819 start = opt;
1830 *(p++) = start->opt;
1850 struct dhcp_opt *opt;
1853 for (opt = daemon->dhcp_opts; opt; opt = opt->next)
1854 if (opt->flags & DHOPT_VENDOR_MATCH)
1856 if (!match_netid(opt->netid, netid, 1))
1857 opt->flags &= ~DHOPT_VENDOR_MATCH;
1858 else if (opt->flags & DHOPT_FORCE)
1905 /* opt 43 max size is 255. encapsulated option has type and length
1955 ret->opt = SUBOPT_PXE_MENU;
1962 ret->opt = SUBOPT_PXE_SERVERS;
1967 if ((o->flags & DHOPT_VENDOR_MATCH) && o->opt == SUBOPT_PXE_MENU_PROMPT)
1975 ret->opt = SUBOPT_PXE_MENU_PROMPT;
1982 ret->opt = SUBOPT_PXE_DISCOVERY;
2026 struct dhcp_opt *opt, *config_opts = daemon->dhcp_opts;
2098 (opt = option_find2(netid, config_opts, OPTION_FILENAME)) && !(opt
2100 strncpy((char *)mess->file, (char *)opt->val, sizeof(mess->file)-1);
2105 (opt = option_find2(netid, config_opts, OPTION_SNAME)) && !(opt->flags & DHOPT_FORCE))
2107 strncpy((char *)mess->sname, (char *)opt->val, sizeof(mess->sname)-1);
2111 if ((opt = option_find2(netid, config_opts, OPTION_END)))
2112 mess->siaddr.s_addr = ((struct in_addr *)opt->val)->s_addr;
2213 for (opt = config_opts; opt; opt = opt->next)
2215 int optno = opt->opt;
2218 if (!(opt->flags & DHOPT_FORCE) && !in_list(req_options, optno))
2236 if (opt != option_find2(netid, config_opts, optno))
2242 if (opt->len == 0 &&
2256 len = do_opt(opt, NULL, context,
2261 do_opt(opt, p, context,
2275 for (opt = config_opts; opt; opt = opt->next)
2276 opt->flags &= ~DHOPT_ENCAP_DONE;
2278 for (opt = config_opts; opt; opt = opt->next)
2279 if ((opt->flags & (DHOPT_ENCAPSULATE | DHOPT_ENCAP_DONE)) == DHOPT_ENCAPSULATE)
2287 if ((o->flags & DHOPT_ENCAPSULATE) && opt->u.encap == o->u.encap)
2300 do_encap_opts(config_opts, opt->u.encap, DHOPT_ENCAP_MATCH, mess, end, null_term);