From 00e4f0ed720071a4c133800dde581fef0dee768d Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Fri, 24 Oct 2008 14:32:06 +0200 Subject: SCTP support for PRINTPKT. This patch modifies PRINTPKT plugin to add SCTP support. Signed-off-by: Eric Leblond --- include/ulogd/printpkt.h | 2 ++ util/printpkt.c | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/ulogd/printpkt.h b/include/ulogd/printpkt.h index 6207d5b..a11ce4a 100644 --- a/include/ulogd/printpkt.h +++ b/include/ulogd/printpkt.h @@ -61,6 +61,8 @@ enum pkt_keys { KEY_ARP_SPA, KEY_ARP_THA, KEY_ARP_TPA, + KEY_SCTP_SPORT, + KEY_SCTP_DPORT, __PRINTPKT_KEYS }; #define PRINTPKT_KEYS (__PRINTPKT_KEYS) diff --git a/util/printpkt.c b/util/printpkt.c index 2292377..5250792 100644 --- a/util/printpkt.c +++ b/util/printpkt.c @@ -102,7 +102,8 @@ struct ulogd_key printpkt_keys[] = { [KEY_ARP_SPA] = { .name = "arp.saddr.str", }, [KEY_ARP_THA] = { .name = "arp.dhwaddr", }, [KEY_ARP_TPA] = { .name = "arp.daddr.str", }, - + [KEY_SCTP_SPORT] = { .name = "sctp.sport", }, + [KEY_SCTP_DPORT] = { .name = "sctp.dport", }, }; static int printpkt_proto(struct ulogd_key *res, char *buf, int protocol) @@ -167,6 +168,18 @@ static int printpkt_proto(struct ulogd_key *res, char *buf, int protocol) ikey_get_u16(&res[KEY_UDP_DPORT]), ikey_get_u16(&res[KEY_UDP_LEN])); break; + case IPPROTO_SCTP: + buf_cur += sprintf(buf_cur, "PROTO=SCTP "); + + if (!pp_is_valid(res, KEY_SCTP_SPORT)) { + buf_cur += sprintf(buf_cur, "INCOMPLETE"); + break; + } + + buf_cur += sprintf(buf_cur, "SPT=%u DPT=%u ", + ikey_get_u16(&res[KEY_SCTP_SPORT]), + ikey_get_u16(&res[KEY_SCTP_DPORT])); + break; case IPPROTO_ESP: case IPPROTO_AH: buf_cur += sprintf(buf_cur, "PROTO=%s ", @@ -223,6 +236,7 @@ static int printpkt_ipv4(struct ulogd_key *res, char *buf) switch (ikey_get_u8(&res[KEY_IP_PROTOCOL])) { case IPPROTO_TCP: case IPPROTO_UDP: + case IPPROTO_SCTP: case IPPROTO_ESP: case IPPROTO_AH: buf_cur += printpkt_proto(res, buf_cur, @@ -311,6 +325,7 @@ static int printpkt_ipv6(struct ulogd_key *res, char *buf) switch (ikey_get_u8(&res[KEY_IP6_NEXTHDR])) { case IPPROTO_TCP: case IPPROTO_UDP: + case IPPROTO_SCTP: case IPPROTO_ESP: case IPPROTO_AH: buf_cur += printpkt_proto(res, buf_cur, -- cgit v1.2.3