]> git.ipfire.org Git - thirdparty/ulogd2.git/commitdiff
Add SCTP support to BASE plugin.
authorEric Leblond <eric@inl.fr>
Fri, 24 Oct 2008 10:44:07 +0000 (12:44 +0200)
committerEric Leblond <eric@inl.fr>
Tue, 9 Dec 2008 00:19:25 +0000 (01:19 +0100)
THis patch adds basic support for SCTP in the BASE plugin.

Signed-off-by: Eric Leblond <eric@inl.fr>
filter/raw2packet/ulogd_raw2packet_BASE.c

index c38c696d8e5e47624316f020013afa5acfb1e9df..584d1c4a49c1a9d1f0838efd21f4833b719454f4 100644 (file)
@@ -113,6 +113,10 @@ enum output_keys {
        KEY_ARP_SPA,
        KEY_ARP_THA,
        KEY_ARP_TPA,
+       KEY_SCTP_SPORT,
+       KEY_SCTP_DPORT,
+       KEY_SCTP_CSUM,
+
 };
 
 static struct ulogd_key iphdr_rets[] = {
@@ -507,6 +511,21 @@ static struct ulogd_key iphdr_rets[] = {
                .flags = ULOGD_RETF_NONE,
                .name = "arp.daddr",
        },
+       [KEY_SCTP_SPORT] = {
+               .type = ULOGD_RET_UINT16,
+               .flags = ULOGD_RETF_NONE,
+               .name = "sctp.sport", 
+       },
+       [KEY_SCTP_DPORT] = {
+               .type = ULOGD_RET_UINT16,
+               .flags = ULOGD_RETF_NONE,
+               .name = "sctp.dport", 
+       },
+       [KEY_SCTP_CSUM] = {
+               .type = ULOGD_RET_UINT32,
+               .flags = ULOGD_RETF_NONE,
+               .name = "sctp.csum",
+       },
 };
 
 /***********************************************************************
@@ -565,6 +584,37 @@ static int _interp_udp(struct ulogd_pluginstance *pi, struct udphdr *udph,
        return ULOGD_IRET_OK;
 }
 
+/***********************************************************************
+ *                     SCTP HEADER
+ ***********************************************************************/
+
+/* Section 3.1.  SCTP Common Header Format */
+typedef struct sctphdr {
+       __be16 source;
+       __be16 dest;
+       __be32 vtag;
+       __be32 checksum;
+} __attribute__((packed)) sctp_sctphdr_t;
+
+static int _interp_sctp(struct ulogd_pluginstance *pi, struct sctphdr *sctph,
+                      u_int32_t len)
+               
+{
+       struct ulogd_key *ret = pi->output.keys;
+
+       if (len < sizeof(struct sctphdr))
+               return ULOGD_IRET_OK;
+
+       ret[KEY_SCTP_SPORT].u.value.ui16 = ntohs(sctph->source);
+       ret[KEY_SCTP_SPORT].flags |= ULOGD_RETF_VALID;
+       ret[KEY_SCTP_DPORT].u.value.ui16 = ntohs(sctph->dest);
+       ret[KEY_SCTP_DPORT].flags |= ULOGD_RETF_VALID;
+       ret[KEY_SCTP_CSUM].u.value.ui32 = ntohl(sctph->checksum);
+       ret[KEY_SCTP_CSUM].flags |= ULOGD_RETF_VALID;
+       
+       return ULOGD_IRET_OK;
+}
+
 /***********************************************************************
  *                     ICMP HEADER
  ***********************************************************************/
@@ -688,6 +738,9 @@ static int _interp_iphdr(struct ulogd_pluginstance *pi, u_int32_t len)
        case IPPROTO_ICMP:
                _interp_icmp(pi, nexthdr, len);
                break;
+       case IPPROTO_SCTP:
+               _interp_sctp(pi, nexthdr, len);
+               break;
        case IPPROTO_AH:
        case IPPROTO_ESP:
                _interp_ahesp(pi, nexthdr, len);