• Home
  • History
  • Annotate
  • Raw
  • Download

Lines Matching full:cb

29 #define XTOPT_MKPTR(cb) \  argument
30 ((void *)((char *)(cb)->data + (cb)->entry->ptroff))
176 static void xtopt_parse_int(struct xt_option_call *cb) in xtopt_parse_int() argument
178 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_int()
182 if (cb->entry->min != 0) in xtopt_parse_int()
183 lmin = cb->entry->min; in xtopt_parse_int()
184 if (cb->entry->max != 0) in xtopt_parse_int()
185 lmax = cb->entry->max; in xtopt_parse_int()
187 if (!xtables_strtoul(cb->arg, NULL, &value, lmin, lmax)) in xtopt_parse_int()
191 cb->ext_name, entry->name, lmin, lmax); in xtopt_parse_int()
194 cb->val.u8 = value; in xtopt_parse_int()
196 *(uint8_t *)XTOPT_MKPTR(cb) = cb->val.u8; in xtopt_parse_int()
198 cb->val.u16 = value; in xtopt_parse_int()
200 *(uint16_t *)XTOPT_MKPTR(cb) = cb->val.u16; in xtopt_parse_int()
202 cb->val.u32 = value; in xtopt_parse_int()
204 *(uint32_t *)XTOPT_MKPTR(cb) = cb->val.u32; in xtopt_parse_int()
206 cb->val.u64 = value; in xtopt_parse_int()
208 *(uint64_t *)XTOPT_MKPTR(cb) = cb->val.u64; in xtopt_parse_int()
215 static void xtopt_parse_float(struct xt_option_call *cb) in xtopt_parse_float() argument
217 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_float()
221 value = strtod(cb->arg, &end); in xtopt_parse_float()
222 if (end == cb->arg || *end != '\0' || in xtopt_parse_float()
228 cb->ext_name, entry->name, entry->min, entry->max); in xtopt_parse_float()
230 cb->val.dbl = value; in xtopt_parse_float()
232 *(double *)XTOPT_MKPTR(cb) = cb->val.dbl; in xtopt_parse_float()
236 * Copy the parsed value to the appropriate entry in cb->val.
238 static void xtopt_mint_value_to_cb(struct xt_option_call *cb, uintmax_t value) in xtopt_mint_value_to_cb() argument
240 const struct xt_option_entry *entry = cb->entry; in xtopt_mint_value_to_cb()
242 if (cb->nvals >= ARRAY_SIZE(cb->val.u32_range)) in xtopt_mint_value_to_cb()
245 cb->val.u8_range[cb->nvals] = value; in xtopt_mint_value_to_cb()
247 cb->val.u16_range[cb->nvals] = value; in xtopt_mint_value_to_cb()
249 cb->val.u32_range[cb->nvals] = value; in xtopt_mint_value_to_cb()
251 cb->val.u64_range[cb->nvals] = value; in xtopt_mint_value_to_cb()
257 static void xtopt_mint_value_to_ptr(struct xt_option_call *cb, void **datap, in xtopt_mint_value_to_ptr() argument
260 const struct xt_option_entry *entry = cb->entry; in xtopt_mint_value_to_ptr()
281 * two values from the string will be put into @cb however (and as such,
282 * @cb->val.uXX_range is just that large) to cater for the few extensions that
286 static void xtopt_parse_mint(struct xt_option_call *cb) in xtopt_parse_mint() argument
288 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_mint()
292 void *put = XTOPT_MKPTR(cb); in xtopt_parse_mint()
300 maxiter = ARRAY_SIZE(cb->val.u32_range); in xtopt_parse_mint()
305 cb->nvals = 0; in xtopt_parse_mint()
306 for (arg = cb->arg, end = (char *)arg; ; arg = end + 1) { in xtopt_parse_mint()
307 if (cb->nvals == maxiter) in xtopt_parse_mint()
310 cb->ext_name, entry->name, maxiter); in xtopt_parse_mint()
314 value = (cb->nvals == 1) ? lmax : 0; in xtopt_parse_mint()
320 cb->ext_name, entry->name, arg, lmax); in xtopt_parse_mint()
325 cb->ext_name, entry->name, end); in xtopt_parse_mint()
327 xtopt_mint_value_to_cb(cb, value); in xtopt_parse_mint()
328 ++cb->nvals; in xtopt_parse_mint()
329 xtopt_mint_value_to_ptr(cb, &put, value); in xtopt_parse_mint()
335 static void xtopt_parse_string(struct xt_option_call *cb) in xtopt_parse_string() argument
337 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_string()
338 size_t z = strlen(cb->arg); in xtopt_parse_string()
353 p = XTOPT_MKPTR(cb); in xtopt_parse_string()
354 strncpy(p, cb->arg, z); in xtopt_parse_string()
377 static bool tos_parse_numeric(const char *str, struct xt_option_call *cb, in tos_parse_numeric() argument
384 cb->val.tos_value = value; in tos_parse_numeric()
385 cb->val.tos_mask = max; in tos_parse_numeric()
393 cb->val.tos_mask = value; in tos_parse_numeric()
406 static void xtopt_parse_tosmask(struct xt_option_call *cb) in xtopt_parse_tosmask() argument
411 if (xtables_strtoui(cb->arg, &tmp, NULL, 0, UINT8_MAX)) { in xtopt_parse_tosmask()
412 tos_parse_numeric(cb->arg, cb, UINT8_MAX); in xtopt_parse_tosmask()
419 cb->val.tos_mask = cb->entry->max; in xtopt_parse_tosmask()
421 if (strcasecmp(cb->arg, symbol->name) == 0) { in xtopt_parse_tosmask()
422 cb->val.tos_value = symbol->value; in xtopt_parse_tosmask()
427 cb->arg); in xtopt_parse_tosmask()
433 static void xtopt_parse_markmask(struct xt_option_call *cb) in xtopt_parse_markmask() argument
435 xtables_parse_mark_mask(cb, &cb->val.mark, &cb->val.mask); in xtopt_parse_markmask()
446 static void xtopt_parse_sysloglevel(struct xt_option_call *cb) in xtopt_parse_sysloglevel() argument
462 if (!xtables_strtoui(cb->arg, NULL, &num, 0, 7)) { in xtopt_parse_sysloglevel()
463 e = bsearch(cb->arg, log_names, ARRAY_SIZE(log_names), in xtopt_parse_sysloglevel()
467 "log level \"%s\" unknown\n", cb->arg); in xtopt_parse_sysloglevel()
470 cb->val.syslog_level = num; in xtopt_parse_sysloglevel()
471 if (cb->entry->flags & XTOPT_PUT) in xtopt_parse_sysloglevel()
472 *(uint8_t *)XTOPT_MKPTR(cb) = num; in xtopt_parse_sysloglevel()
495 * result is stored in @cb->val.haddr. Additionally, @cb->val.hmask and
496 * @cb->val.hlen are set for completeness to the appropriate values.
498 static void xtopt_parse_host(struct xt_option_call *cb) in xtopt_parse_host() argument
505 ret = getaddrinfo(cb->arg, NULL, &hints, &res); in xtopt_parse_host()
510 memset(&cb->val.hmask, 0xFF, sizeof(cb->val.hmask)); in xtopt_parse_host()
511 cb->val.hlen = (afinfo->family == NFPROTO_IPV4) ? 32 : 128; in xtopt_parse_host()
515 memset(&cb->val.haddr, 0, sizeof(cb->val.haddr)); in xtopt_parse_host()
516 memcpy(&cb->val.haddr, in xtopt_parse_host()
522 if (memcmp(&cb->val.haddr, in xtopt_parse_host()
527 cb->arg); in xtopt_parse_host()
531 if (cb->entry->flags & XTOPT_PUT) in xtopt_parse_host()
533 memcpy(XTOPT_MKPTR(cb), &cb->val.haddr, in xtopt_parse_host()
534 sizeof(cb->val.haddr)); in xtopt_parse_host()
569 * /etc/protocols and put the result into @cb->val.protocol.
571 static void xtopt_parse_protocol(struct xt_option_call *cb) in xtopt_parse_protocol() argument
573 cb->val.protocol = xtables_parse_protocol(cb->arg); in xtopt_parse_protocol()
574 if (cb->entry->flags & XTOPT_PUT) in xtopt_parse_protocol()
575 *(uint8_t *)XTOPT_MKPTR(cb) = cb->val.protocol; in xtopt_parse_protocol()
580 * @cb->val.port.
582 static void xtopt_parse_port(struct xt_option_call *cb) in xtopt_parse_port() argument
584 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_port()
587 ret = xtables_getportbyname(cb->arg); in xtopt_parse_port()
591 cb->arg); in xtopt_parse_port()
594 cb->val.port = ret; in xtopt_parse_port()
596 *(uint16_t *)XTOPT_MKPTR(cb) = cb->val.port; in xtopt_parse_port()
599 static void xtopt_parse_mport(struct xt_option_call *cb) in xtopt_parse_mport() argument
602 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_mport()
607 wp_arg = lo_arg = strdup(cb->arg); in xtopt_parse_mport()
613 maxiter = 2; /* ARRAY_SIZE(cb->val.port_range) */ in xtopt_parse_mport()
618 cb->val.port_range[0] = 0; in xtopt_parse_mport()
619 cb->val.port_range[1] = UINT16_MAX; in xtopt_parse_mport()
620 cb->nvals = 0; in xtopt_parse_mport()
623 if (cb->nvals == maxiter) in xtopt_parse_mport()
626 cb->ext_name, entry->name, maxiter); in xtopt_parse_mport()
628 ++cb->nvals; in xtopt_parse_mport()
639 if (cb->nvals < ARRAY_SIZE(cb->val.port_range)) in xtopt_parse_mport()
640 cb->val.port_range[cb->nvals] = value; in xtopt_parse_mport()
641 ++cb->nvals; in xtopt_parse_mport()
644 if (cb->nvals == 1) { in xtopt_parse_mport()
645 cb->val.port_range[1] = cb->val.port_range[0]; in xtopt_parse_mport()
646 ++cb->nvals; in xtopt_parse_mport()
649 memcpy(XTOPT_MKPTR(cb), cb->val.port_range, sizeof(uint16_t) * in xtopt_parse_mport()
650 (cb->nvals <= maxiter ? cb->nvals : maxiter)); in xtopt_parse_mport()
654 static int xtopt_parse_mask(struct xt_option_call *cb) in xtopt_parse_mask() argument
661 ret = getaddrinfo(cb->arg, NULL, &hints, &res); in xtopt_parse_mask()
665 memcpy(&cb->val.hmask, xtables_sa_host(res->ai_addr, res->ai_family), in xtopt_parse_mask()
670 cb->val.hlen = xtables_ipmask_to_cidr(&cb->val.hmask.in); in xtopt_parse_mask()
673 cb->val.hlen = xtables_ip6mask_to_cidr(&cb->val.hmask.in6); in xtopt_parse_mask()
683 * limits. The result is stored in @cb->val.hlen.
685 static void xtopt_parse_plen(struct xt_option_call *cb) in xtopt_parse_plen() argument
687 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_plen()
690 cb->val.hlen = (afinfo->family == NFPROTO_IPV4) ? 32 : 128; in xtopt_parse_plen()
691 if (!xtables_strtoui(cb->arg, NULL, &prefix_len, 0, cb->val.hlen)) { in xtopt_parse_plen()
693 if (xtopt_parse_mask(cb)) in xtopt_parse_plen()
700 cb->ext_name, entry->name, 0, cb->val.hlen); in xtopt_parse_plen()
702 cb->val.hlen = prefix_len; in xtopt_parse_plen()
707 * a bitmask, and make it available through @cb->val.hmask (hlen remains
710 static void xtopt_parse_plenmask(struct xt_option_call *cb) in xtopt_parse_plenmask() argument
712 const struct xt_option_entry *entry = cb->entry; in xtopt_parse_plenmask()
713 uint32_t *mask = cb->val.hmask.all; in xtopt_parse_plenmask()
715 xtopt_parse_plen(cb); in xtopt_parse_plenmask()
719 if (cb->val.hlen == 0) { in xtopt_parse_plenmask()
721 } else if (cb->val.hlen <= 32) { in xtopt_parse_plenmask()
722 mask[0] <<= 32 - cb->val.hlen; in xtopt_parse_plenmask()
724 } else if (cb->val.hlen <= 64) { in xtopt_parse_plenmask()
725 mask[1] <<= 32 - (cb->val.hlen - 32); in xtopt_parse_plenmask()
727 } else if (cb->val.hlen <= 96) { in xtopt_parse_plenmask()
728 mask[2] <<= 32 - (cb->val.hlen - 64); in xtopt_parse_plenmask()
730 } else if (cb->val.hlen <= 128) { in xtopt_parse_plenmask()
731 mask[3] <<= 32 - (cb->val.hlen - 96); in xtopt_parse_plenmask()
738 memcpy(XTOPT_MKPTR(cb), mask, sizeof(union nf_inet_addr)); in xtopt_parse_plenmask()
741 static void xtopt_parse_hostmask(struct xt_option_call *cb) in xtopt_parse_hostmask() argument
743 const char *orig_arg = cb->arg; in xtopt_parse_hostmask()
746 if (strchr(cb->arg, '/') == NULL) { in xtopt_parse_hostmask()
747 xtopt_parse_host(cb); in xtopt_parse_hostmask()
761 cb->arg = work; in xtopt_parse_hostmask()
762 xtopt_parse_host(cb); in xtopt_parse_hostmask()
763 cb->arg = p; in xtopt_parse_hostmask()
764 xtopt_parse_plenmask(cb); in xtopt_parse_hostmask()
765 cb->arg = orig_arg; in xtopt_parse_hostmask()
768 static void xtopt_parse_ethermac(struct xt_option_call *cb) in xtopt_parse_ethermac() argument
770 const char *arg = cb->arg; in xtopt_parse_ethermac()
774 for (i = 0; i < ARRAY_SIZE(cb->val.ethermac) - 1; ++i) { in xtopt_parse_ethermac()
775 cb->val.ethermac[i] = strtoul(arg, &end, 16); in xtopt_parse_ethermac()
780 i = ARRAY_SIZE(cb->val.ethermac) - 1; in xtopt_parse_ethermac()
781 cb->val.ethermac[i] = strtoul(arg, &end, 16); in xtopt_parse_ethermac()
784 if (cb->entry->flags & XTOPT_PUT) in xtopt_parse_ethermac()
785 memcpy(XTOPT_MKPTR(cb), cb->val.ethermac, in xtopt_parse_ethermac()
786 sizeof(cb->val.ethermac)); in xtopt_parse_ethermac()
821 void xtables_option_parse(struct xt_option_call *cb) in xtables_option_parse() argument
823 const struct xt_option_entry *entry = cb->entry; in xtables_option_parse()
824 unsigned int eflag = 1 << cb->entry->id; in xtables_option_parse()
833 cb->xflags & eflag) in xtables_option_parse()
836 cb->ext_name, cb->entry->name); in xtables_option_parse()
837 if (cb->invert && !(entry->flags & XTOPT_INVERT)) in xtables_option_parse()
840 cb->ext_name, entry->name); in xtables_option_parse()
844 cb->ext_name, entry->name); in xtables_option_parse()
850 cb->nvals = 1; in xtables_option_parse()
853 xtopt_subparse[entry->type](cb); in xtables_option_parse()
855 cb->xflags |= 1 << entry->id; in xtables_option_parse()
918 struct xt_option_call cb; in xtables_option_tpcall() local
928 cb.entry = xtables_option_lookup(t->x6_options, c); in xtables_option_tpcall()
929 if (cb.entry == NULL) in xtables_option_tpcall()
932 cb.arg = optarg; in xtables_option_tpcall()
933 cb.invert = invert; in xtables_option_tpcall()
934 cb.ext_name = t->name; in xtables_option_tpcall()
935 cb.data = t->t->data; in xtables_option_tpcall()
936 cb.xflags = t->tflags; in xtables_option_tpcall()
937 cb.target = &t->t; in xtables_option_tpcall()
938 cb.xt_entry = fw; in xtables_option_tpcall()
939 cb.udata = t->udata; in xtables_option_tpcall()
940 t->x6_parse(&cb); in xtables_option_tpcall()
941 t->tflags = cb.xflags; in xtables_option_tpcall()
954 struct xt_option_call cb; in xtables_option_mpcall() local
964 cb.entry = xtables_option_lookup(m->x6_options, c); in xtables_option_mpcall()
965 if (cb.entry == NULL) in xtables_option_mpcall()
968 cb.arg = optarg; in xtables_option_mpcall()
969 cb.invert = invert; in xtables_option_mpcall()
970 cb.ext_name = m->name; in xtables_option_mpcall()
971 cb.data = m->m->data; in xtables_option_mpcall()
972 cb.xflags = m->mflags; in xtables_option_mpcall()
973 cb.match = &m->m; in xtables_option_mpcall()
974 cb.xt_entry = fw; in xtables_option_mpcall()
975 cb.udata = m->udata; in xtables_option_mpcall()
976 m->x6_parse(&cb); in xtables_option_mpcall()
977 m->mflags = cb.xflags; in xtables_option_mpcall()
1056 struct xt_fcheck_call cb; in xtables_option_tfcall() local
1058 cb.ext_name = t->name; in xtables_option_tfcall()
1059 cb.data = t->t->data; in xtables_option_tfcall()
1060 cb.xflags = t->tflags; in xtables_option_tfcall()
1061 cb.udata = t->udata; in xtables_option_tfcall()
1062 t->x6_fcheck(&cb); in xtables_option_tfcall()
1077 struct xt_fcheck_call cb; in xtables_option_mfcall() local
1079 cb.ext_name = m->name; in xtables_option_mfcall()
1080 cb.data = m->m->data; in xtables_option_mfcall()
1081 cb.xflags = m->mflags; in xtables_option_mfcall()
1082 cb.udata = m->udata; in xtables_option_mfcall()
1083 m->x6_fcheck(&cb); in xtables_option_mfcall()