• Home
  • Raw
  • Download

Lines Matching refs:opt

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