• Home
  • Raw
  • Download

Lines Matching refs:rule

55 	struct rtnl_rule *rule = nl_object_priv(c);  in rule_free_data()  local
57 if (!rule) in rule_free_data()
60 nl_addr_put(rule->r_src); in rule_free_data()
61 nl_addr_put(rule->r_dst); in rule_free_data()
101 struct rtnl_rule *rule; in rule_msg_parser() local
106 rule = rtnl_rule_alloc(); in rule_msg_parser()
107 if (!rule) { in rule_msg_parser()
112 rule->ce_msgtype = n->nlmsg_type; in rule_msg_parser()
119 rule->r_family = family = frh->family; in rule_msg_parser()
120 rule->r_table = frh->table; in rule_msg_parser()
121 rule->r_action = frh->action; in rule_msg_parser()
122 rule->r_flags = frh->flags; in rule_msg_parser()
124 rule->ce_mask = (RULE_ATTR_FAMILY | RULE_ATTR_ACTION | RULE_ATTR_FLAGS); in rule_msg_parser()
125 if (rule->r_table) in rule_msg_parser()
126 rule->ce_mask |= RULE_ATTR_TABLE; in rule_msg_parser()
130 rule->r_dsfield = frh->tos; in rule_msg_parser()
131 rule->ce_mask |= RULE_ATTR_DSFIELD; in rule_msg_parser()
135 rule->r_table = nla_get_u32(tb[FRA_TABLE]); in rule_msg_parser()
136 if (rule->r_table) in rule_msg_parser()
137 rule->ce_mask |= RULE_ATTR_TABLE; in rule_msg_parser()
141 nla_strlcpy(rule->r_iifname, tb[FRA_IIFNAME], IFNAMSIZ); in rule_msg_parser()
142 rule->ce_mask |= RULE_ATTR_IIFNAME; in rule_msg_parser()
146 nla_strlcpy(rule->r_oifname, tb[FRA_OIFNAME], IFNAMSIZ); in rule_msg_parser()
147 rule->ce_mask |= RULE_ATTR_OIFNAME; in rule_msg_parser()
151 rule->r_prio = nla_get_u32(tb[FRA_PRIORITY]); in rule_msg_parser()
152 rule->ce_mask |= RULE_ATTR_PRIO; in rule_msg_parser()
156 rule->r_mark = nla_get_u32(tb[FRA_FWMARK]); in rule_msg_parser()
157 rule->ce_mask |= RULE_ATTR_MARK; in rule_msg_parser()
161 rule->r_mask = nla_get_u32(tb[FRA_FWMASK]); in rule_msg_parser()
162 rule->ce_mask |= RULE_ATTR_MASK; in rule_msg_parser()
166 rule->r_goto = nla_get_u32(tb[FRA_GOTO]); in rule_msg_parser()
167 rule->ce_mask |= RULE_ATTR_GOTO; in rule_msg_parser()
171 if (!(rule->r_src = nl_addr_alloc_attr(tb[FRA_SRC], family))) in rule_msg_parser()
174 nl_addr_set_prefixlen(rule->r_src, frh->src_len); in rule_msg_parser()
175 rule->ce_mask |= RULE_ATTR_SRC; in rule_msg_parser()
179 if (!(rule->r_dst = nl_addr_alloc_attr(tb[FRA_DST], family))) in rule_msg_parser()
181 nl_addr_set_prefixlen(rule->r_dst, frh->dst_len); in rule_msg_parser()
182 rule->ce_mask |= RULE_ATTR_DST; in rule_msg_parser()
187 rule->r_flow = nla_get_u32(tb[FRA_FLOW]); in rule_msg_parser()
188 rule->ce_mask |= RULE_ATTR_FLOW; in rule_msg_parser()
192 rule->r_l3mdev = nla_get_u8(tb[FRA_L3MDEV]); in rule_msg_parser()
193 rule->ce_mask |= RULE_ATTR_L3MDEV; in rule_msg_parser()
197 rule->r_protocol = nla_get_u8(tb[FRA_PROTOCOL]); in rule_msg_parser()
198 rule->ce_mask |= RULE_ATTR_PROTOCOL; in rule_msg_parser()
202 rule->r_ip_proto = nla_get_u8(tb[FRA_IP_PROTO]); in rule_msg_parser()
203 rule->ce_mask |= RULE_ATTR_IP_PROTO; in rule_msg_parser()
210 rule->r_sport = *pr; in rule_msg_parser()
211 rule->ce_mask |= RULE_ATTR_SPORT; in rule_msg_parser()
218 rule->r_dport = *pr; in rule_msg_parser()
219 rule->ce_mask |= RULE_ATTR_DPORT; in rule_msg_parser()
222 err = pp->pp_cb((struct nl_object *) rule, pp); in rule_msg_parser()
224 rtnl_rule_put(rule); in rule_msg_parser()
380 void rtnl_rule_put(struct rtnl_rule *rule) in rtnl_rule_put() argument
382 nl_object_put((struct nl_object *) rule); in rtnl_rule_put()
584 int rtnl_rule_build_delete_request(struct rtnl_rule *rule, int flags, in rtnl_rule_build_delete_request() argument
587 return build_rule_msg(rule, RTM_DELRULE, flags, result); in rtnl_rule_build_delete_request()
602 int rtnl_rule_delete(struct nl_sock *sk, struct rtnl_rule *rule, int flags) in rtnl_rule_delete() argument
607 if ((err = rtnl_rule_build_delete_request(rule, flags, &msg)) < 0) in rtnl_rule_delete()
625 void rtnl_rule_set_family(struct rtnl_rule *rule, int family) in rtnl_rule_set_family() argument
627 rule->r_family = family; in rtnl_rule_set_family()
628 rule->ce_mask |= RULE_ATTR_FAMILY; in rtnl_rule_set_family()
631 int rtnl_rule_get_family(struct rtnl_rule *rule) in rtnl_rule_get_family() argument
633 if (rule->ce_mask & RULE_ATTR_FAMILY) in rtnl_rule_get_family()
634 return rule->r_family; in rtnl_rule_get_family()
639 void rtnl_rule_set_prio(struct rtnl_rule *rule, uint32_t prio) in rtnl_rule_set_prio() argument
641 rule->r_prio = prio; in rtnl_rule_set_prio()
642 rule->ce_mask |= RULE_ATTR_PRIO; in rtnl_rule_set_prio()
645 uint32_t rtnl_rule_get_prio(struct rtnl_rule *rule) in rtnl_rule_get_prio() argument
647 return rule->r_prio; in rtnl_rule_get_prio()
650 void rtnl_rule_set_mark(struct rtnl_rule *rule, uint32_t mark) in rtnl_rule_set_mark() argument
652 rule->r_mark = mark; in rtnl_rule_set_mark()
653 rule->ce_mask |= RULE_ATTR_MARK; in rtnl_rule_set_mark()
656 uint32_t rtnl_rule_get_mark(struct rtnl_rule *rule) in rtnl_rule_get_mark() argument
658 return rule->r_mark; in rtnl_rule_get_mark()
661 void rtnl_rule_set_mask(struct rtnl_rule *rule, uint32_t mask) in rtnl_rule_set_mask() argument
663 rule->r_mask = mask; in rtnl_rule_set_mask()
664 rule->ce_mask |= RULE_ATTR_MASK; in rtnl_rule_set_mask()
667 uint32_t rtnl_rule_get_mask(struct rtnl_rule *rule) in rtnl_rule_get_mask() argument
669 return rule->r_mask; in rtnl_rule_get_mask()
672 void rtnl_rule_set_table(struct rtnl_rule *rule, uint32_t table) in rtnl_rule_set_table() argument
674 rule->r_table = table; in rtnl_rule_set_table()
675 rule->ce_mask |= RULE_ATTR_TABLE; in rtnl_rule_set_table()
678 uint32_t rtnl_rule_get_table(struct rtnl_rule *rule) in rtnl_rule_get_table() argument
680 return rule->r_table; in rtnl_rule_get_table()
683 void rtnl_rule_set_dsfield(struct rtnl_rule *rule, uint8_t dsfield) in rtnl_rule_set_dsfield() argument
685 rule->r_dsfield = dsfield; in rtnl_rule_set_dsfield()
686 rule->ce_mask |= RULE_ATTR_DSFIELD; in rtnl_rule_set_dsfield()
689 uint8_t rtnl_rule_get_dsfield(struct rtnl_rule *rule) in rtnl_rule_get_dsfield() argument
691 return rule->r_dsfield; in rtnl_rule_get_dsfield()
694 static inline int __assign_addr(struct rtnl_rule *rule, struct nl_addr **pos, in __assign_addr() argument
697 if (rule->ce_mask & RULE_ATTR_FAMILY) { in __assign_addr()
698 if (new->a_family != rule->r_family) in __assign_addr()
701 rule->r_family = new->a_family; in __assign_addr()
709 rule->ce_mask |= (flag | RULE_ATTR_FAMILY); in __assign_addr()
714 int rtnl_rule_set_src(struct rtnl_rule *rule, struct nl_addr *src) in rtnl_rule_set_src() argument
716 return __assign_addr(rule, &rule->r_src, src, RULE_ATTR_SRC); in rtnl_rule_set_src()
719 struct nl_addr *rtnl_rule_get_src(struct rtnl_rule *rule) in rtnl_rule_get_src() argument
721 return rule->r_src; in rtnl_rule_get_src()
724 int rtnl_rule_set_dst(struct rtnl_rule *rule, struct nl_addr *dst) in rtnl_rule_set_dst() argument
726 return __assign_addr(rule, &rule->r_dst, dst, RULE_ATTR_DST); in rtnl_rule_set_dst()
729 struct nl_addr *rtnl_rule_get_dst(struct rtnl_rule *rule) in rtnl_rule_get_dst() argument
731 return rule->r_dst; in rtnl_rule_get_dst()
734 int rtnl_rule_set_iif(struct rtnl_rule *rule, const char *dev) in rtnl_rule_set_iif() argument
739 strcpy(rule->r_iifname, dev); in rtnl_rule_set_iif()
740 rule->ce_mask |= RULE_ATTR_IIFNAME; in rtnl_rule_set_iif()
744 char *rtnl_rule_get_iif(struct rtnl_rule *rule) in rtnl_rule_get_iif() argument
746 if (rule->ce_mask & RULE_ATTR_IIFNAME) in rtnl_rule_get_iif()
747 return rule->r_iifname; in rtnl_rule_get_iif()
752 int rtnl_rule_set_oif(struct rtnl_rule *rule, const char *dev) in rtnl_rule_set_oif() argument
757 strcpy(rule->r_oifname, dev); in rtnl_rule_set_oif()
758 rule->ce_mask |= RULE_ATTR_OIFNAME; in rtnl_rule_set_oif()
762 char *rtnl_rule_get_oif(struct rtnl_rule *rule) in rtnl_rule_get_oif() argument
764 if (rule->ce_mask & RULE_ATTR_OIFNAME) in rtnl_rule_get_oif()
765 return rule->r_oifname; in rtnl_rule_get_oif()
770 void rtnl_rule_set_action(struct rtnl_rule *rule, uint8_t action) in rtnl_rule_set_action() argument
772 rule->r_action = action; in rtnl_rule_set_action()
773 rule->ce_mask |= RULE_ATTR_ACTION; in rtnl_rule_set_action()
776 uint8_t rtnl_rule_get_action(struct rtnl_rule *rule) in rtnl_rule_get_action() argument
778 return rule->r_action; in rtnl_rule_get_action()
790 void rtnl_rule_set_l3mdev(struct rtnl_rule *rule, int value) in rtnl_rule_set_l3mdev() argument
793 rule->r_l3mdev = (uint8_t) value; in rtnl_rule_set_l3mdev()
794 rule->ce_mask |= RULE_ATTR_L3MDEV; in rtnl_rule_set_l3mdev()
796 rule->r_l3mdev = 0; in rtnl_rule_set_l3mdev()
797 rule->ce_mask &= ~((uint32_t) RULE_ATTR_L3MDEV); in rtnl_rule_set_l3mdev()
810 int rtnl_rule_get_l3mdev(struct rtnl_rule *rule) in rtnl_rule_get_l3mdev() argument
812 if (!rule) in rtnl_rule_get_l3mdev()
814 if (!(rule->ce_mask & RULE_ATTR_L3MDEV)) in rtnl_rule_get_l3mdev()
816 return rule->r_l3mdev; in rtnl_rule_get_l3mdev()
819 int rtnl_rule_set_protocol(struct rtnl_rule *rule, uint8_t protocol) in rtnl_rule_set_protocol() argument
822 rule->r_protocol = protocol; in rtnl_rule_set_protocol()
823 rule->ce_mask |= RULE_ATTR_PROTOCOL; in rtnl_rule_set_protocol()
825 rule->r_protocol = 0; in rtnl_rule_set_protocol()
826 rule->ce_mask &= ~((uint32_t) RULE_ATTR_PROTOCOL); in rtnl_rule_set_protocol()
831 int rtnl_rule_get_protocol(struct rtnl_rule *rule, uint8_t *protocol) in rtnl_rule_get_protocol() argument
833 if (!(rule->ce_mask & RULE_ATTR_PROTOCOL)) in rtnl_rule_get_protocol()
836 *protocol = rule->r_protocol; in rtnl_rule_get_protocol()
840 int rtnl_rule_set_ipproto(struct rtnl_rule *rule, uint8_t ip_proto) in rtnl_rule_set_ipproto() argument
843 rule->r_ip_proto = ip_proto; in rtnl_rule_set_ipproto()
844 rule->ce_mask |= RULE_ATTR_IP_PROTO; in rtnl_rule_set_ipproto()
846 rule->r_ip_proto = 0; in rtnl_rule_set_ipproto()
847 rule->ce_mask &= ~((uint32_t) RULE_ATTR_IP_PROTO); in rtnl_rule_set_ipproto()
852 int rtnl_rule_get_ipproto(struct rtnl_rule *rule, uint8_t *ip_proto) in rtnl_rule_get_ipproto() argument
854 if (!(rule->ce_mask & RULE_ATTR_IP_PROTO)) in rtnl_rule_get_ipproto()
857 *ip_proto = rule->r_ip_proto; in rtnl_rule_get_ipproto()
881 int rtnl_rule_set_sport(struct rtnl_rule *rule, uint16_t sport) in rtnl_rule_set_sport() argument
883 return __rtnl_rule_set_port(&rule->r_sport, sport, sport, in rtnl_rule_set_sport()
884 RULE_ATTR_SPORT, &rule->ce_mask); in rtnl_rule_set_sport()
887 int rtnl_rule_set_sport_range(struct rtnl_rule *rule, uint16_t start, in rtnl_rule_set_sport_range() argument
890 return __rtnl_rule_set_port(&rule->r_sport, start, end, in rtnl_rule_set_sport_range()
891 RULE_ATTR_SPORT, &rule->ce_mask); in rtnl_rule_set_sport_range()
894 int rtnl_rule_get_sport(struct rtnl_rule *rule, uint16_t *start, uint16_t *end) in rtnl_rule_get_sport() argument
896 if (!(rule->ce_mask & RULE_ATTR_SPORT)) in rtnl_rule_get_sport()
899 *start = rule->r_sport.start; in rtnl_rule_get_sport()
900 *end = rule->r_sport.end; in rtnl_rule_get_sport()
904 int rtnl_rule_set_dport(struct rtnl_rule *rule, uint16_t dport) in rtnl_rule_set_dport() argument
906 return __rtnl_rule_set_port(&rule->r_dport, dport, dport, in rtnl_rule_set_dport()
907 RULE_ATTR_DPORT, &rule->ce_mask); in rtnl_rule_set_dport()
910 int rtnl_rule_set_dport_range(struct rtnl_rule *rule, uint16_t start, in rtnl_rule_set_dport_range() argument
913 return __rtnl_rule_set_port(&rule->r_dport, start, end, in rtnl_rule_set_dport_range()
914 RULE_ATTR_DPORT, &rule->ce_mask); in rtnl_rule_set_dport_range()
917 int rtnl_rule_get_dport(struct rtnl_rule *rule, uint16_t *start, uint16_t *end) in rtnl_rule_get_dport() argument
919 if (!(rule->ce_mask & RULE_ATTR_DPORT)) in rtnl_rule_get_dport()
922 *start = rule->r_dport.start; in rtnl_rule_get_dport()
923 *end = rule->r_dport.end; in rtnl_rule_get_dport()
927 void rtnl_rule_set_realms(struct rtnl_rule *rule, uint32_t realms) in rtnl_rule_set_realms() argument
929 rule->r_flow = realms; in rtnl_rule_set_realms()
930 rule->ce_mask |= RULE_ATTR_FLOW; in rtnl_rule_set_realms()
933 uint32_t rtnl_rule_get_realms(struct rtnl_rule *rule) in rtnl_rule_get_realms() argument
935 return rule->r_flow; in rtnl_rule_get_realms()
938 void rtnl_rule_set_goto(struct rtnl_rule *rule, uint32_t ref) in rtnl_rule_set_goto() argument
940 rule->r_goto = ref; in rtnl_rule_set_goto()
941 rule->ce_mask |= RULE_ATTR_GOTO; in rtnl_rule_set_goto()
944 uint32_t rtnl_rule_get_goto(struct rtnl_rule *rule) in rtnl_rule_get_goto() argument
946 return rule->r_goto; in rtnl_rule_get_goto()