]>
git.proxmox.com Git - mirror_iproute2.git/blob - tc/m_ematch.h
1 /* SPDX-License-Identifier: GPL-2.0 */
13 #define EMATCHKINDSIZ 16
22 struct bstr
*bstr_alloc(const char *text
);
24 static inline struct bstr
*bstr_new(char *data
, unsigned int len
)
26 struct bstr
*b
= calloc(1, sizeof(*b
));
37 static inline int bstrcmp(const struct bstr
*b
, const char *text
)
39 int len
= strlen(text
);
43 return strncmp(b
->data
, text
, len
);
48 static inline struct bstr
*bstr_next(struct bstr
*b
)
53 unsigned long bstrtoul(const struct bstr
*b
);
65 static inline struct ematch
*new_ematch(struct bstr
*args
, int inverted
)
67 struct ematch
*e
= calloc(1, sizeof(*e
));
73 e
->inverted
= inverted
;
78 void print_ematch_tree(const struct ematch
*tree
);
81 char kind
[EMATCHKINDSIZ
];
83 int (*parse_eopt
)(struct nlmsghdr
*, struct tcf_ematch_hdr
*,
85 int (*parse_eopt_argv
)(struct nlmsghdr
*, struct tcf_ematch_hdr
*,
87 int (*print_eopt
)(FILE *, struct tcf_ematch_hdr
*, void *, int);
88 void (*print_usage
)(FILE *);
89 struct ematch_util
*next
;
92 static inline int parse_layer(const struct bstr
*b
)
94 if (*((char *) b
->data
) == 'l')
95 return TCF_LAYER_LINK
;
96 else if (*((char *) b
->data
) == 'n')
97 return TCF_LAYER_NETWORK
;
98 else if (*((char *) b
->data
) == 't')
99 return TCF_LAYER_TRANSPORT
;
104 __attribute__((format(printf
, 5, 6)))
105 int em_parse_error(int err
, struct bstr
*args
, struct bstr
*carg
,
106 struct ematch_util
*, char *fmt
, ...);
107 int print_ematch(FILE *, const struct rtattr
*);
108 int parse_ematch(int *, char ***, int, struct nlmsghdr
*);