2 * p_ip6.c packet editor: IPV6 header
4 * This program is free software; you can distribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Amir Vadai <amir@vadai.me>
17 #include <sys/socket.h>
18 #include <netinet/in.h>
19 #include <arpa/inet.h>
26 parse_ip6(int *argc_p
, char ***argv_p
,
27 struct m_pedit_sel
*sel
, struct m_pedit_key
*tkey
)
31 char **argv
= *argv_p
;
39 tkey
->htype
= TCA_PEDIT_KEY_EX_HDR_TYPE_IP6
;
41 if (strcmp(*argv
, "src") == 0) {
44 res
= parse_cmd(&argc
, &argv
, 16, TIPV6
, RU32
, sel
, tkey
);
47 if (strcmp(*argv
, "dst") == 0) {
50 res
= parse_cmd(&argc
, &argv
, 16, TIPV6
, RU32
, sel
, tkey
);
53 if (strcmp(*argv
, "flow_lbl") == 0) {
56 res
= parse_cmd(&argc
, &argv
, 4, TU32
, 0x0007ffff, sel
, tkey
);
59 if (strcmp(*argv
, "payload_len") == 0) {
62 res
= parse_cmd(&argc
, &argv
, 2, TU32
, RU16
, sel
, tkey
);
65 if (strcmp(*argv
, "nexthdr") == 0) {
68 res
= parse_cmd(&argc
, &argv
, 1, TU32
, RU8
, sel
, tkey
);
71 if (strcmp(*argv
, "hoplimit") == 0) {
74 res
= parse_cmd(&argc
, &argv
, 1, TU32
, RU8
, sel
, tkey
);
77 if (strcmp(*argv
, "traffic_class") == 0) {
80 res
= parse_cmd(&argc
, &argv
, 1, TU32
, RU8
, sel
, tkey
);
82 /* Shift the field by 4 bits on success. */
84 int nkeys
= sel
->sel
.nkeys
;
85 struct tc_pedit_key
*key
= &sel
->keys
[nkeys
- 1];
87 key
->mask
= htonl(ntohl(key
->mask
) << 4 | 0xf);
88 key
->val
= htonl(ntohl(key
->val
) << 4);
101 struct m_pedit_util p_pedit_ip6
= {
103 .parse_peopt
= parse_ip6
,