]>
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
);
54 void bstr_print(FILE *fd
, const struct bstr
*b
, int ascii
);
66 static inline struct ematch
*new_ematch(struct bstr
*args
, int inverted
)
68 struct ematch
*e
= calloc(1, sizeof(*e
));
74 e
->inverted
= inverted
;
79 void print_ematch_tree(const struct ematch
*tree
);
82 char kind
[EMATCHKINDSIZ
];
84 int (*parse_eopt
)(struct nlmsghdr
*, struct tcf_ematch_hdr
*,
86 int (*parse_eopt_argv
)(struct nlmsghdr
*, struct tcf_ematch_hdr
*,
88 int (*print_eopt
)(FILE *, struct tcf_ematch_hdr
*, void *, int);
89 void (*print_usage
)(FILE *);
90 struct ematch_util
*next
;
93 static inline int parse_layer(const struct bstr
*b
)
95 if (*((char *) b
->data
) == 'l')
96 return TCF_LAYER_LINK
;
97 else if (*((char *) b
->data
) == 'n')
98 return TCF_LAYER_NETWORK
;
99 else if (*((char *) b
->data
) == 't')
100 return TCF_LAYER_TRANSPORT
;
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
*);