• Home
  • Raw
  • Download

Lines Matching refs:cb

29 #define XTOPT_MKPTR(cb) \  argument
30 ((void *)((char *)(cb)->data + (cb)->entry->ptroff))
163 static void xtopt_parse_int(struct xt_option_call *cb) in xtopt_parse_int() argument
165 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_int()
169 if (cb->entry->min != 0) in xtopt_parse_int()
170 lmin = cb->entry->min; in xtopt_parse_int()
171 if (cb->entry->max != 0) in xtopt_parse_int()
172 lmax = cb->entry->max; in xtopt_parse_int()
174 if (!xtables_strtoul_base(cb->arg, NULL, &value, in xtopt_parse_int()
175 lmin, lmax, cb->entry->base)) in xtopt_parse_int()
179 cb->ext_name, entry->name, lmin, lmax); in xtopt_parse_int()
182 cb->val.u8 = value; in xtopt_parse_int()
184 *(uint8_t *)XTOPT_MKPTR(cb) = cb->val.u8; in xtopt_parse_int()
186 cb->val.u16 = value; in xtopt_parse_int()
188 cb->val.u16 = htons(cb->val.u16); in xtopt_parse_int()
190 *(uint16_t *)XTOPT_MKPTR(cb) = cb->val.u16; in xtopt_parse_int()
192 cb->val.u32 = value; in xtopt_parse_int()
194 cb->val.u32 = htonl(cb->val.u32); in xtopt_parse_int()
196 *(uint32_t *)XTOPT_MKPTR(cb) = cb->val.u32; in xtopt_parse_int()
198 cb->val.u64 = value; in xtopt_parse_int()
200 cb->val.u64 = htonll(cb->val.u64); in xtopt_parse_int()
202 *(uint64_t *)XTOPT_MKPTR(cb) = cb->val.u64; in xtopt_parse_int()
209 static void xtopt_parse_float(struct xt_option_call *cb) in xtopt_parse_float() argument
211 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_float()
215 value = strtod(cb->arg, &end); in xtopt_parse_float()
216 if (end == cb->arg || *end != '\0' || in xtopt_parse_float()
222 cb->ext_name, entry->name, entry->min, entry->max); in xtopt_parse_float()
224 cb->val.dbl = value; in xtopt_parse_float()
226 *(double *)XTOPT_MKPTR(cb) = cb->val.dbl; in xtopt_parse_float()
232 static void xtopt_mint_value_to_cb(struct xt_option_call *cb, uintmax_t value) in xtopt_mint_value_to_cb() argument
234 const struct xt_option_entry *entry = cb->entry; in xtopt_mint_value_to_cb()
235 uint8_t i = cb->nvals; in xtopt_mint_value_to_cb()
237 if (i >= ARRAY_SIZE(cb->val.u32_range)) in xtopt_mint_value_to_cb()
240 cb->val.u8_range[i] = value; in xtopt_mint_value_to_cb()
242 cb->val.u16_range[i] = value; in xtopt_mint_value_to_cb()
244 cb->val.u16_range[i] = htons(cb->val.u16_range[i]); in xtopt_mint_value_to_cb()
246 cb->val.u32_range[i] = value; in xtopt_mint_value_to_cb()
248 cb->val.u32_range[i] = htonl(cb->val.u32_range[i]); in xtopt_mint_value_to_cb()
250 cb->val.u64_range[i] = value; in xtopt_mint_value_to_cb()
252 cb->val.u64_range[i] = htonll(cb->val.u64_range[i]); in xtopt_mint_value_to_cb()
259 static void xtopt_mint_value_to_ptr(struct xt_option_call *cb, void **datap, in xtopt_mint_value_to_ptr() argument
262 const struct xt_option_entry *entry = cb->entry; in xtopt_mint_value_to_ptr()
288 static void xtopt_parse_mint(struct xt_option_call *cb) in xtopt_parse_mint() argument
290 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_mint()
295 void *put = XTOPT_MKPTR(cb); in xtopt_parse_mint()
305 maxiter = ARRAY_SIZE(cb->val.u32_range); in xtopt_parse_mint()
310 cb->nvals = 0; in xtopt_parse_mint()
311 for (arg = cb->arg, end = (char *)arg; ; arg = end + 1) { in xtopt_parse_mint()
312 if (cb->nvals == maxiter) in xtopt_parse_mint()
315 cb->ext_name, entry->name, maxiter); in xtopt_parse_mint()
319 value = (cb->nvals == 1) ? lmax : lmin; in xtopt_parse_mint()
325 cb->ext_name, entry->name, arg, lmin, lmax); in xtopt_parse_mint()
330 cb->ext_name, entry->name, end); in xtopt_parse_mint()
333 xtopt_mint_value_to_cb(cb, value); in xtopt_parse_mint()
334 ++cb->nvals; in xtopt_parse_mint()
335 xtopt_mint_value_to_ptr(cb, &put, value); in xtopt_parse_mint()
341 static void xtopt_parse_string(struct xt_option_call *cb) in xtopt_parse_string() argument
343 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_string()
344 size_t z = strlen(cb->arg); in xtopt_parse_string()
359 p = XTOPT_MKPTR(cb); in xtopt_parse_string()
360 strncpy(p, cb->arg, z); in xtopt_parse_string()
383 static bool tos_parse_numeric(const char *str, struct xt_option_call *cb, in tos_parse_numeric() argument
390 cb->val.tos_value = value; in tos_parse_numeric()
391 cb->val.tos_mask = max; in tos_parse_numeric()
399 cb->val.tos_mask = value; in tos_parse_numeric()
412 static void xtopt_parse_tosmask(struct xt_option_call *cb) in xtopt_parse_tosmask() argument
417 if (xtables_strtoui(cb->arg, &tmp, NULL, 0, UINT8_MAX)) { in xtopt_parse_tosmask()
418 tos_parse_numeric(cb->arg, cb, UINT8_MAX); in xtopt_parse_tosmask()
425 cb->val.tos_mask = cb->entry->max; in xtopt_parse_tosmask()
427 if (strcasecmp(cb->arg, symbol->name) == 0) { in xtopt_parse_tosmask()
428 cb->val.tos_value = symbol->value; in xtopt_parse_tosmask()
433 cb->arg); in xtopt_parse_tosmask()
439 static void xtopt_parse_markmask(struct xt_option_call *cb) in xtopt_parse_markmask() argument
441 xtables_parse_mark_mask(cb, &cb->val.mark, &cb->val.mask); in xtopt_parse_markmask()
452 static void xtopt_parse_sysloglevel(struct xt_option_call *cb) in xtopt_parse_sysloglevel() argument
468 if (!xtables_strtoui(cb->arg, NULL, &num, 0, 7)) { in xtopt_parse_sysloglevel()
469 e = bsearch(cb->arg, log_names, ARRAY_SIZE(log_names), in xtopt_parse_sysloglevel()
473 "log level \"%s\" unknown\n", cb->arg); in xtopt_parse_sysloglevel()
476 cb->val.syslog_level = num; in xtopt_parse_sysloglevel()
477 if (cb->entry->flags & XTOPT_PUT) in xtopt_parse_sysloglevel()
478 *(uint8_t *)XTOPT_MKPTR(cb) = num; in xtopt_parse_sysloglevel()
504 static void xtopt_parse_host(struct xt_option_call *cb) in xtopt_parse_host() argument
511 ret = getaddrinfo(cb->arg, NULL, &hints, &res); in xtopt_parse_host()
516 memset(&cb->val.hmask, 0xFF, sizeof(cb->val.hmask)); in xtopt_parse_host()
517 cb->val.hlen = (afinfo_family() == NFPROTO_IPV4) ? 32 : 128; in xtopt_parse_host()
521 memset(&cb->val.haddr, 0, sizeof(cb->val.haddr)); in xtopt_parse_host()
522 memcpy(&cb->val.haddr, in xtopt_parse_host()
528 if (memcmp(&cb->val.haddr, in xtopt_parse_host()
533 cb->arg); in xtopt_parse_host()
537 if (cb->entry->flags & XTOPT_PUT) in xtopt_parse_host()
539 memcpy(XTOPT_MKPTR(cb), &cb->val.haddr, in xtopt_parse_host()
540 sizeof(cb->val.haddr)); in xtopt_parse_host()
577 static void xtopt_parse_protocol(struct xt_option_call *cb) in xtopt_parse_protocol() argument
579 cb->val.protocol = xtables_parse_protocol(cb->arg); in xtopt_parse_protocol()
580 if (cb->entry->flags & XTOPT_PUT) in xtopt_parse_protocol()
581 *(uint8_t *)XTOPT_MKPTR(cb) = cb->val.protocol; in xtopt_parse_protocol()
588 static void xtopt_parse_port(struct xt_option_call *cb) in xtopt_parse_port() argument
590 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_port()
593 ret = xtables_getportbyname(cb->arg); in xtopt_parse_port()
597 cb->arg); in xtopt_parse_port()
600 cb->val.port = ret; in xtopt_parse_port()
602 *(uint16_t *)XTOPT_MKPTR(cb) = cb->val.port; in xtopt_parse_port()
605 static void xtopt_parse_mport(struct xt_option_call *cb) in xtopt_parse_mport() argument
608 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_mport()
613 wp_arg = lo_arg = xtables_strdup(cb->arg); in xtopt_parse_mport()
622 cb->val.port_range[0] = 0; in xtopt_parse_mport()
623 cb->val.port_range[1] = UINT16_MAX; in xtopt_parse_mport()
624 cb->nvals = 0; in xtopt_parse_mport()
627 if (cb->nvals == maxiter) in xtopt_parse_mport()
630 cb->ext_name, entry->name, maxiter); in xtopt_parse_mport()
632 ++cb->nvals; in xtopt_parse_mport()
648 if (cb->nvals < ARRAY_SIZE(cb->val.port_range)) in xtopt_parse_mport()
649 cb->val.port_range[cb->nvals] = value; in xtopt_parse_mport()
650 ++cb->nvals; in xtopt_parse_mport()
653 if (cb->nvals == 1) { in xtopt_parse_mport()
654 cb->val.port_range[1] = cb->val.port_range[0]; in xtopt_parse_mport()
655 ++cb->nvals; in xtopt_parse_mport()
658 memcpy(XTOPT_MKPTR(cb), cb->val.port_range, sizeof(uint16_t) * in xtopt_parse_mport()
659 (cb->nvals <= maxiter ? cb->nvals : maxiter)); in xtopt_parse_mport()
663 static int xtopt_parse_mask(struct xt_option_call *cb) in xtopt_parse_mask() argument
670 ret = getaddrinfo(cb->arg, NULL, &hints, &res); in xtopt_parse_mask()
674 memcpy(&cb->val.hmask, xtables_sa_host(res->ai_addr, res->ai_family), in xtopt_parse_mask()
679 cb->val.hlen = xtables_ipmask_to_cidr(&cb->val.hmask.in); in xtopt_parse_mask()
682 cb->val.hlen = xtables_ip6mask_to_cidr(&cb->val.hmask.in6); in xtopt_parse_mask()
694 static void xtopt_parse_plen(struct xt_option_call *cb) in xtopt_parse_plen() argument
696 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_plen()
699 cb->val.hlen = (afinfo_family() == NFPROTO_IPV4) ? 32 : 128; in xtopt_parse_plen()
700 if (!xtables_strtoui(cb->arg, NULL, &prefix_len, 0, cb->val.hlen)) { in xtopt_parse_plen()
702 if (xtopt_parse_mask(cb)) in xtopt_parse_plen()
709 cb->ext_name, entry->name, 0, cb->val.hlen); in xtopt_parse_plen()
711 cb->val.hlen = prefix_len; in xtopt_parse_plen()
719 static void xtopt_parse_plenmask(struct xt_option_call *cb) in xtopt_parse_plenmask() argument
721 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_plenmask()
722 uint32_t *mask = cb->val.hmask.all; in xtopt_parse_plenmask()
724 xtopt_parse_plen(cb); in xtopt_parse_plenmask()
727 if (cb->val.hlen == (uint8_t)-1) in xtopt_parse_plenmask()
732 if (cb->val.hlen == 0) { in xtopt_parse_plenmask()
734 } else if (cb->val.hlen <= 32) { in xtopt_parse_plenmask()
735 mask[0] <<= 32 - cb->val.hlen; in xtopt_parse_plenmask()
737 } else if (cb->val.hlen <= 64) { in xtopt_parse_plenmask()
738 mask[1] <<= 32 - (cb->val.hlen - 32); in xtopt_parse_plenmask()
740 } else if (cb->val.hlen <= 96) { in xtopt_parse_plenmask()
741 mask[2] <<= 32 - (cb->val.hlen - 64); in xtopt_parse_plenmask()
743 } else if (cb->val.hlen <= 128) { in xtopt_parse_plenmask()
744 mask[3] <<= 32 - (cb->val.hlen - 96); in xtopt_parse_plenmask()
752 memcpy(XTOPT_MKPTR(cb), mask, sizeof(union nf_inet_addr)); in xtopt_parse_plenmask()
755 static void xtopt_parse_hostmask(struct xt_option_call *cb) in xtopt_parse_hostmask() argument
757 const char *orig_arg = cb->arg; in xtopt_parse_hostmask()
760 if (strchr(cb->arg, '/') == NULL) { in xtopt_parse_hostmask()
761 xtopt_parse_host(cb); in xtopt_parse_hostmask()
773 cb->arg = work; in xtopt_parse_hostmask()
774 xtopt_parse_host(cb); in xtopt_parse_hostmask()
775 cb->arg = p; in xtopt_parse_hostmask()
776 xtopt_parse_plenmask(cb); in xtopt_parse_hostmask()
777 cb->arg = orig_arg; in xtopt_parse_hostmask()
781 static void xtopt_parse_ethermac(struct xt_option_call *cb) in xtopt_parse_ethermac() argument
783 const char *arg = cb->arg; in xtopt_parse_ethermac()
787 for (i = 0; i < ARRAY_SIZE(cb->val.ethermac) - 1; ++i) { in xtopt_parse_ethermac()
788 cb->val.ethermac[i] = strtoul(arg, &end, 16); in xtopt_parse_ethermac()
793 i = ARRAY_SIZE(cb->val.ethermac) - 1; in xtopt_parse_ethermac()
794 cb->val.ethermac[i] = strtoul(arg, &end, 16); in xtopt_parse_ethermac()
797 if (cb->entry->flags & XTOPT_PUT) in xtopt_parse_ethermac()
798 memcpy(XTOPT_MKPTR(cb), cb->val.ethermac, in xtopt_parse_ethermac()
799 sizeof(cb->val.ethermac)); in xtopt_parse_ethermac()
805 static void xtopt_parse_ethermacmask(struct xt_option_call *cb) in xtopt_parse_ethermacmask() argument
807 memset(cb->val.ethermacmask, 0xff, ETH_ALEN); in xtopt_parse_ethermacmask()
808 if (xtables_parse_mac_and_mask(cb->arg, cb->val.ethermac, in xtopt_parse_ethermacmask()
809 cb->val.ethermacmask)) in xtopt_parse_ethermacmask()
844 void xtables_option_parse(struct xt_option_call *cb) in xtables_option_parse() argument
846 const struct xt_option_entry *entry = cb->entry; in xtables_option_parse()
847 unsigned int eflag = 1 << cb->entry->id; in xtables_option_parse()
856 cb->xflags & eflag) in xtables_option_parse()
859 cb->ext_name, cb->entry->name); in xtables_option_parse()
860 if (cb->invert && !(entry->flags & XTOPT_INVERT)) in xtables_option_parse()
863 cb->ext_name, entry->name); in xtables_option_parse()
867 cb->ext_name, entry->name); in xtables_option_parse()
873 cb->nvals = 1; in xtables_option_parse()
876 xtopt_subparse[entry->type](cb); in xtables_option_parse()
878 cb->xflags |= 1 << entry->id; in xtables_option_parse()
941 struct xt_option_call cb; in xtables_option_tpcall() local
951 cb.entry = xtables_option_lookup(t->x6_options, c); in xtables_option_tpcall()
952 if (cb.entry == NULL) in xtables_option_tpcall()
955 cb.arg = optarg; in xtables_option_tpcall()
956 cb.invert = invert; in xtables_option_tpcall()
957 cb.ext_name = t->name; in xtables_option_tpcall()
958 cb.data = t->t->data; in xtables_option_tpcall()
959 cb.xflags = t->tflags; in xtables_option_tpcall()
960 cb.target = &t->t; in xtables_option_tpcall()
961 cb.xt_entry = fw; in xtables_option_tpcall()
962 cb.udata = t->udata; in xtables_option_tpcall()
963 t->x6_parse(&cb); in xtables_option_tpcall()
964 t->tflags = cb.xflags; in xtables_option_tpcall()
977 struct xt_option_call cb; in xtables_option_mpcall() local
987 cb.entry = xtables_option_lookup(m->x6_options, c); in xtables_option_mpcall()
988 if (cb.entry == NULL) in xtables_option_mpcall()
991 cb.arg = optarg; in xtables_option_mpcall()
992 cb.invert = invert; in xtables_option_mpcall()
993 cb.ext_name = m->name; in xtables_option_mpcall()
994 cb.data = m->m->data; in xtables_option_mpcall()
995 cb.xflags = m->mflags; in xtables_option_mpcall()
996 cb.match = &m->m; in xtables_option_mpcall()
997 cb.xt_entry = fw; in xtables_option_mpcall()
998 cb.udata = m->udata; in xtables_option_mpcall()
999 m->x6_parse(&cb); in xtables_option_mpcall()
1000 m->mflags = cb.xflags; in xtables_option_mpcall()
1079 struct xt_fcheck_call cb; in xtables_option_tfcall() local
1081 cb.ext_name = t->name; in xtables_option_tfcall()
1082 cb.data = t->t->data; in xtables_option_tfcall()
1083 cb.xflags = t->tflags; in xtables_option_tfcall()
1084 cb.udata = t->udata; in xtables_option_tfcall()
1085 t->x6_fcheck(&cb); in xtables_option_tfcall()
1100 struct xt_fcheck_call cb; in xtables_option_mfcall() local
1102 cb.ext_name = m->name; in xtables_option_mfcall()
1103 cb.data = m->m->data; in xtables_option_mfcall()
1104 cb.xflags = m->mflags; in xtables_option_mfcall()
1105 cb.udata = m->udata; in xtables_option_mfcall()
1106 m->x6_fcheck(&cb); in xtables_option_mfcall()