netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Leblond <eric@inl.fr>
To: netfilter-devel@vger.kernel.org
Cc: pablo@netfilter.org, Eric Leblond <eric@inl.fr>
Subject: [ULOGD2 PATCH 06/18] SCTP support for PRINTPKT.
Date: Mon,  1 Dec 2008 22:36:04 +0100	[thread overview]
Message-ID: <1228167376-22101-7-git-send-email-eric@inl.fr> (raw)
In-Reply-To: <1228167376-22101-1-git-send-email-eric@inl.fr>

This patch modifies PRINTPKT plugin to add SCTP support.

Signed-off-by: Eric Leblond <eric@inl.fr>
---
 include/ulogd/printpkt.h |    2 ++
 util/printpkt.c          |   17 ++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)

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,
-- 
1.5.6.3


  parent reply	other threads:[~2008-12-01 21:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-01 21:35 [ULOGD2 PATCH 0/18] Code cleaning, SCTP support, NFLOG logic fix Eric Leblond
2008-12-01 21:35 ` [ULOGD2 PATCH 01/18] add ukey_* function for key assignation Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 02/18] Modify usage of nflog_bind_pf function Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 03/18] Get rid of addressfamily variable in NFLOG input plugin Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 04/18] Document group 0 usage and suppress address_family Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 05/18] Add SCTP support to BASE plugin Eric Leblond
2008-12-01 21:36 ` Eric Leblond [this message]
2008-12-01 21:36 ` [ULOGD2 PATCH 07/18] Add SCTP support to MySQL and PGSQL output Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 08/18] Treat nice function return Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 09/18] Fix stop function of NFCT plugin Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 10/18] Don't free pluginstance when leaving Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 11/18] Fix minor memory leak in NFLOG plugin Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 12/18] Call pluginstance stop function when exiting Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 13/18] Add SIGINT to list of terminal signal Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 14/18] Unload plugins when quitting Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 15/18] Introduce config_stop() function Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 16/18] Free stacks when exiting Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 17/18] Fix memory leak in destructor_nfct() Eric Leblond
2008-12-01 21:36 ` [ULOGD2 PATCH 18/18] Add valgrind compilation option Eric Leblond
2008-12-10 11:07 ` [ULOGD2 PATCH 0/18] Code cleaning, SCTP support, NFLOG logic fix Eric Leblond

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1228167376-22101-7-git-send-email-eric@inl.fr \
    --to=eric@inl.fr \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).