• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iptables-1.4.12.1/iptables/

Lines Matching refs:cb

29 #define XTOPT_MKPTR(cb) \
30 ((void *)((char *)(cb)->data + (cb)->entry->ptroff))
172 static void xtopt_parse_int(struct xt_option_call *cb)
174 const struct xt_option_entry *entry = cb->entry;
178 if (cb->entry->min != 0)
179 lmin = cb->entry->min;
180 if (cb->entry->max != 0)
181 lmax = cb->entry->max;
183 if (!xtables_strtoul(cb->arg, NULL, &value, lmin, lmax))
187 cb->ext_name, entry->name, lmin, lmax);
190 cb->val.u8 = value;
192 *(uint8_t *)XTOPT_MKPTR(cb) = cb->val.u8;
194 cb->val.u16 = value;
196 *(uint16_t *)XTOPT_MKPTR(cb) = cb->val.u16;
198 cb->val.u32 = value;
200 *(uint32_t *)XTOPT_MKPTR(cb) = cb->val.u32;
202 cb->val.u64 = value;
204 *(uint64_t *)XTOPT_MKPTR(cb) = cb->val.u64;
211 static void xtopt_parse_float(struct xt_option_call *cb)
213 const struct xt_option_entry *entry = cb->entry;
217 value = strtod(cb->arg, &end);
218 if (end == cb->arg || *end != '\0' ||
224 cb->ext_name, entry->name, entry->min, entry->max);
226 cb->val.dbl = value;
228 *(double *)XTOPT_MKPTR(cb) = cb->val.dbl;
232 * Copy the parsed value to the appropriate entry in cb->val.
234 static void xtopt_mint_value_to_cb(struct xt_option_call *cb, uintmax_t value)
236 const struct xt_option_entry *entry = cb->entry;
238 if (cb->nvals >= ARRAY_SIZE(cb->val.u32_range))
241 cb->val.u8_range[cb->nvals] = value;
243 cb->val.u16_range[cb->nvals] = value;
245 cb->val.u32_range[cb->nvals] = value;
247 cb->val.u64_range[cb->nvals] = value;
253 static void xtopt_mint_value_to_ptr(struct xt_option_call *cb, void **datap,
256 const struct xt_option_entry *entry = cb->entry;
277 * two values from the string will be put into @cb however (and as such,
278 * @cb->val.uXX_range is just that large) to cater for the few extensions that
282 static void xtopt_parse_mint(struct xt_option_call *cb)
284 const struct xt_option_entry *entry = cb->entry;
285 const char *arg = cb->arg;
288 void *put = XTOPT_MKPTR(cb);
296 maxiter = ARRAY_SIZE(cb->val.u32_range);
301 cb->nvals = 0;
302 for (arg = cb->arg, end = (char *)arg; ; arg = end + 1) {
303 if (cb->nvals == maxiter)
306 cb->ext_name, entry->name, maxiter);
310 value = (cb->nvals == 1) ? lmax : 0;
316 cb->ext_name, entry->name, arg, lmax);
321 cb->ext_name, entry->name, end);
323 xtopt_mint_value_to_cb(cb, value);
324 ++cb->nvals;
325 xtopt_mint_value_to_ptr(cb, &put, value);
331 static void xtopt_parse_string(struct xt_option_call *cb)
333 const struct xt_option_entry *entry = cb->entry;
334 size_t z = strlen(cb->arg);
349 p = XTOPT_MKPTR(cb);
350 strncpy(p, cb->arg, z);
373 static bool tos_parse_numeric(const char *str, struct xt_option_call *cb,
380 cb->val.tos_value = value;
381 cb->val.tos_mask = max;
389 cb->val.tos_mask = value;
402 static void xtopt_parse_tosmask(struct xt_option_call *cb)
407 if (xtables_strtoui(cb->arg, &tmp, NULL, 0, UINT8_MAX)) {
408 tos_parse_numeric(cb->arg, cb, UINT8_MAX);
415 cb->val.tos_mask = cb->entry->max;
417 if (strcasecmp(cb->arg, symbol->name) == 0) {
418 cb->val.tos_value = symbol->value;
423 cb->arg);
429 static void xtopt_parse_markmask(struct xt_option_call *cb)
434 if (!xtables_strtoui(cb->arg, &end, &mark, 0, UINT32_MAX))
438 cb->ext_name, cb->entry->name);
444 cb->ext_name, cb->entry->name);
449 cb->ext_name, cb->entry->name);
450 cb->val.mark = mark;
451 cb->val.mask = mask;
462 static void xtopt_parse_sysloglevel(struct xt_option_call *cb)
478 if (!xtables_strtoui(cb->arg, NULL, &num, 0, 7)) {
479 e = bsearch(cb->arg, log_names, ARRAY_SIZE(log_names),
483 "log level \"%s\" unknown\n", cb->arg);
486 cb->val.syslog_level = num;
487 if (cb->entry->flags & XTOPT_PUT)
488 *(uint8_t *)XTOPT_MKPTR(cb) = num;
511 * result is stored in @cb->val.haddr. Additionally, @cb->val.hmask and
512 * @cb->val.hlen are set for completeness to the appropriate values.
514 static void xtopt_parse_host(struct xt_option_call *cb)
521 ret = getaddrinfo(cb->arg, NULL, &hints, &res);
526 memset(&cb->val.hmask, 0xFF, sizeof(cb->val.hmask));
527 cb->val.hlen = (afinfo->family == NFPROTO_IPV4) ? 32 : 128;
531 memset(&cb->val.haddr, 0, sizeof(cb->val.haddr));
532 memcpy(&cb->val.haddr,
538 if (memcmp(&cb->val.haddr,
543 cb->arg);
547 if (cb->entry->flags & XTOPT_PUT)
549 memcpy(XTOPT_MKPTR(cb), &cb->val.haddr,
550 sizeof(cb->val.haddr));
585 * /etc/protocols and put the result into @cb->val.protocol.
587 static void xtopt_parse_protocol(struct xt_option_call *cb)
589 cb->val.protocol = xtables_parse_protocol(cb->arg);
590 if (cb->entry->flags & XTOPT_PUT)
591 *(uint8_t *)XTOPT_MKPTR(cb) = cb->val.protocol;
596 * @cb->val.port.
598 static void xtopt_parse_port(struct xt_option_call *cb)
600 const struct xt_option_entry *entry = cb->entry;
603 ret = xtables_getportbyname(cb->arg);
607 cb->arg);
610 cb->val.port = ret;
612 *(uint16_t *)XTOPT_MKPTR(cb) = cb->val.port;
615 static void xtopt_parse_mport(struct xt_option_call *cb)
618 const struct xt_option_entry *entry = cb->entry;
623 wp_arg = lo_arg = strdup(cb->arg);
629 maxiter = 2; /* ARRAY_SIZE(cb->val.port_range) */
634 cb->val.port_range[0] = 0;
635 cb->val.port_range[1] = UINT16_MAX;
636 cb->nvals = 0;
639 if (cb->nvals == maxiter)
642 cb->ext_name, entry->name, maxiter);
644 ++cb->nvals;
655 if (cb->nvals < ARRAY_SIZE(cb->val.port_range))
656 cb->val.port_range[cb->nvals] = value;
657 ++cb->nvals;
660 if (cb->nvals == 1) {
661 cb->val.port_range[1] = cb->val.port_range[0];
662 ++cb->nvals;
665 memcpy(XTOPT_MKPTR(cb), cb->val.port_range, sizeof(uint16_t) *
666 (cb->nvals <= maxiter ? cb->nvals : maxiter));
672 * limits. The result is stored in @cb->val.hlen.
674 static void xtopt_parse_plen(struct xt_option_call *cb)
676 const struct xt_option_entry *entry = cb->entry;
679 cb->val.hlen = (afinfo->family == NFPROTO_IPV4) ? 32 : 128;
680 if (!xtables_strtoui(cb->arg, NULL, &prefix_len, 0, cb->val.hlen))
684 cb->ext_name, entry->name, 0, cb->val.hlen);
686 cb->val.hlen = prefix_len;
691 * a bitmask, and make it available through @cb->val.hmask (hlen remains
694 static void xtopt_parse_plenmask(struct xt_option_call *cb)
696 const struct xt_option_entry *entry = cb->entry;
697 uint32_t *mask = cb->val.hmask.all;
699 xtopt_parse_plen(cb);
703 if (cb->val.hlen == 0) {
705 } else if (cb->val.hlen <= 32) {
706 mask[0] <<= 32 - cb->val.hlen;
708 } else if (cb->val.hlen <= 64) {
709 mask[1] <<= 32 - (cb->val.hlen - 32);
711 } else if (cb->val.hlen <= 96) {
712 mask[2] <<= 32 - (cb->val.hlen - 64);
714 } else if (cb->val.hlen <= 128) {
715 mask[3] <<= 32 - (cb->val.hlen - 96);
722 memcpy(XTOPT_MKPTR(cb), mask, sizeof(union nf_inet_addr));
725 static void xtopt_parse_hostmask(struct xt_option_call *cb)
727 const char *orig_arg = cb->arg;
730 if (strchr(cb->arg, '/') == NULL) {
731 xtopt_parse_host(cb);
745 cb->arg = work;
746 xtopt_parse_host(cb);
747 cb->arg = p;
748 xtopt_parse_plenmask(cb);
749 cb->arg = orig_arg;
752 static void xtopt_parse_ethermac(struct xt_option_call *cb)
754 const char *arg = cb->arg;
758 for (i = 0; i < ARRAY_SIZE(cb->val.ethermac) - 1; ++i) {
759 cb->val.ethermac[i] = strtoul(arg, &end, 16);
764 i = ARRAY_SIZE(cb->val.ethermac) - 1;
765 cb->val.ethermac[i] = strtoul(arg, &end, 16);
768 if (cb->entry->flags & XTOPT_PUT)
769 memcpy(XTOPT_MKPTR(cb), cb->val.ethermac,
770 sizeof(cb->val.ethermac));
805 void xtables_option_parse(struct xt_option_call *cb)
807 const struct xt_option_entry *entry = cb->entry;
808 unsigned int eflag = 1 << cb->entry->id;
817 cb->xflags & eflag)
820 cb->ext_name, cb->entry->name);
821 if (cb->invert && !(entry->flags & XTOPT_INVERT))
824 cb->ext_name, entry->name);
828 cb->ext_name, entry->name);
831 xtopt_subparse[entry->type](cb);
833 cb->xflags |= 1 << entry->id;
896 struct xt_option_call cb;
906 cb.entry = xtables_option_lookup(t->x6_options, c);
907 if (cb.entry == NULL)
910 cb.arg = optarg;
911 cb.invert = invert;
912 cb.ext_name = t->name;
913 cb.data = t->t->data;
914 cb.xflags = t->tflags;
915 cb.target = &t->t;
916 cb.xt_entry = fw;
917 cb.udata = t->udata;
918 t->x6_parse(&cb);
919 t->tflags = cb.xflags;
932 struct xt_option_call cb;
942 cb.entry = xtables_option_lookup(m->x6_options, c);
943 if (cb.entry == NULL)
946 cb.arg = optarg;
947 cb.invert = invert;
948 cb.ext_name = m->name;
949 cb.data = m->m->data;
950 cb.xflags = m->mflags;
951 cb.match = &m->m;
952 cb.xt_entry = fw;
953 cb.udata = m->udata;
954 m->x6_parse(&cb);
955 m->mflags = cb.xflags;
1034 struct xt_fcheck_call cb;
1036 cb.ext_name = t->name;
1037 cb.data = t->t->data;
1038 cb.xflags = t->tflags;
1039 cb.udata = t->udata;
1040 t->x6_fcheck(&cb);
1055 struct xt_fcheck_call cb;
1057 cb.ext_name = m->name;
1058 cb.data = m->m->data;
1059 cb.xflags = m->mflags;
1060 cb.udata = m->udata;
1061 m->x6_fcheck(&cb);