diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2019-03-08 23:39:07 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2019-04-02 00:27:38 +0200 |
commit | 16e769ad99e0177c28d6dd73d6f279043bceac97 (patch) | |
tree | 7d9c594bde51e68c4150d7150f6367d3e33b5298 | |
parent | d4e5d95e90ac9e5b8eefcdb2aa6baef295dd14cd (diff) |
Filter: Tunnel Encaps color attribute
-rw-r--r-- | filter/config.Y | 6 | ||||
-rw-r--r-- | filter/filter.c | 21 | ||||
-rw-r--r-- | nest/attrs.h | 2 |
3 files changed, 28 insertions, 1 deletions
diff --git a/filter/config.Y b/filter/config.Y index 04e5758c..45d02908 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -115,6 +115,9 @@ f_new_tlv_item(u32 type, u32 v1) struct tlv v; v.type = type; switch (type) { + case TLV_COLOR: + v.u.color = v1; + break; case TLV_UDP_DEST_PORT: v.u.udp_dest_port = v1; break; @@ -480,7 +483,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN, PREPEND, FIRST, LAST, LAST_NONAGGREGATED, MATCH, EMPTY, FILTER, WHERE, EVAL, ATTRIBUTE, - TLV, TUNNEL_ENCAP, REMOTE_ENDPOINT, UDP_DEST_PORT, + TLV, TUNNEL_ENCAP, REMOTE_ENDPOINT, UDP_DEST_PORT, COLOR, BT_ASSERT, BT_TEST_SUITE, FORMAT) %nonassoc THEN @@ -780,6 +783,7 @@ lc_item: tlv_item: '(' TUNNEL_ENCAP ',' cnum ',' TEXT ')' { $$ = f_new_tlv_encap($4, $6); } | '(' UDP_DEST_PORT ',' cnum ')' { $$ = f_new_tlv_item(TLV_UDP_DEST_PORT, $4); } + | '(' COLOR ',' cnum ')' { $$ = f_new_tlv_item(TLV_COLOR, $4); } | '(' REMOTE_ENDPOINT ',' NUM ',' fipa ')' { $$ = f_new_tlv_remote_ep($4, $6); } set_item: diff --git a/filter/filter.c b/filter/filter.c index af1165bd..97017cee 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -656,6 +656,14 @@ calc_tunnel_encap(struct f_tree *t, int *type) len = 4 + 2 + tlv->u.tunnel_encap.length; *type = tlv->u.tunnel_encap.type; break; + case TLV_COLOR: + /* + Sub-TLV Type (1 Octet) + Sub-TLV Length (1 Octet) + Sub-TLV Value (8 Octets) + */ + len = 10; + break; case TLV_UDP_DEST_PORT: /* Sub-TLV Type (1 Octet) @@ -709,6 +717,19 @@ build_tunnel_encap_rec(void *p, struct f_tree *t) put_u8(p, len); p++; memcpy(p, tlv->u.tunnel_encap.data, len); p+=len; break; + case TLV_COLOR: + /* + Sub-TLV Type (1 Octet) + Sub-TLV Length (1 Octet) + Sub-TLV Value (8 Octets) + */ + put_u8(p, tlv->type); p++; + put_u8(p, 8); p++; + put_u8(p, 0x03); p++; + put_u8(p, 0x0b); p++; + put_u16(p, 0x0); p+=2; + put_u32(p, tlv->u.color); p+=4; + break; case TLV_UDP_DEST_PORT: /* Sub-TLV Type (1 Octet) diff --git a/nest/attrs.h b/nest/attrs.h index 68e4c876..e7485a7f 100644 --- a/nest/attrs.h +++ b/nest/attrs.h @@ -202,6 +202,7 @@ void ec_set_sort_x(struct adata *set); /* Sort in place */ /* Tunnel Encapsulation TLV types */ #define TLV_TUNNEL_TYPE 0x00 /* Reserved. Used internally only. */ #define TLV_ENCAPSULATION 0x01 +#define TLV_COLOR 0x04 #define TLV_REMOTE_ENDPOINT 0x06 #define TLV_UDP_DEST_PORT 0x08 @@ -218,6 +219,7 @@ struct tlv { u32 asn; ip_addr ip; } remote_endpoint; + u32 color; u16 udp_dest_port; } u; }; |