Skip to content

Commit

Permalink
Add support to match sctp
Browse files Browse the repository at this point in the history
This commmit introduces to the parsing engine the specification
of the sctp header. Now it is possible to match sctp src and dst
ports.
  • Loading branch information
Eder Leão Fernandes authored and lupo89 committed Jun 25, 2015
1 parent f996c15 commit a28f31e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
26 changes: 24 additions & 2 deletions customnetpdl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@
<case value="1"> <nextproto proto="#icmp"/> </case>
<case value="6"> <nextproto proto="#tcp"/> </case>
<case value="17"> <nextproto proto="#udp"/> </case>
<case value="132"> <nextproto proto="#sctp"/> </case>
</switch>
</if-true>
</if>
Expand Down Expand Up @@ -1043,7 +1044,7 @@
<!-- <case value="29"> <nextproto proto="#TP4"/> </case> -->
<!-- <case value="45"> <nextproto proto="#IDRP"/> </case> -->
<case value="58"> <nextproto proto="#icmp6"/> </case>

<case value="132"> <nextproto proto="#sctp"/> </case>
</switch>
</encapsulation>

Expand Down Expand Up @@ -1737,7 +1738,6 @@
</fields>
</format>


<visualization>
<showsumtemplate name="udp">
<section name="next"/>
Expand All @@ -1749,6 +1749,28 @@
</visualization>
</protocol>

<protocol name="sctp" longname="SCTP (Stream Control Transmission Protocol)" showsumtemplate="sctp">

<format>
<fields>
<field type="fixed" name="sport" size="2" showtemplate="FieldDec"/>
<field type="fixed" name="dport" size="2" showtemplate="FieldDec"/>
<field type="fixed" name="ver_tag" longname="Verification Tag" size="4" showtemplate="FieldDec"/>
<field type="fixed" name="crc" longname="Checksum" size="4" showtemplate="FieldHex"/>
</fields>
</format>

<visualization>
<showsumtemplate name="sctp">
<section name="next"/>
<text value="SCTP: port "/>
<protofield name="sport" showdata="showvalue"/>
<text value=" => "/>
<protofield name="dport" showdata="showvalue"/>
</showsumtemplate>
</visualization>
</protocol>

<protocol name="icmp" longname="ICMP (Internet Control Message Protocol)" showsumtemplate="icmp">
<format>
<fields>
Expand Down
2 changes: 1 addition & 1 deletion lib/packets.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ BUILD_ASSERT_DECL(TCP_HEADER_LEN == sizeof(struct tcp_header));
struct sctp_header {
uint16_t sctp_src;
uint16_t sctp_dst;
uint32_t sctp_verif;
uint32_t sctp_ver_tag;
uint32_t sctp_csum;
};
BUILD_ASSERT_DECL(SCTP_HEADER_LEN == sizeof(struct sctp_header));
Expand Down
4 changes: 4 additions & 0 deletions nbee_link/nbee_link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,10 @@ extern "C" int nblink_packet_parse(struct ofpbuf * pktin, struct ofl_match * pk
else if (protocol_Name.compare("sctp") == 0 && pkt_proto->sctp == NULL)
{
pkt_proto->sctp = (struct sctp_header *) ((uint8_t*) pktin->data + proto->Position);
PDMLReader->GetPDMLField(proto->Name, (char*) "sport", proto->FirstField, &field);
nblink_extract_proto_fields(pktin, field, pktout, OXM_OF_SCTP_SRC);
PDMLReader->GetPDMLField(proto->Name, (char*) "dport", proto->FirstField, &field);
nblink_extract_proto_fields(pktin, field, pktout, OXM_OF_SCTP_DST);
}

if (protocol_Name.compare("icmp") == 0 && pkt_proto->icmp == NULL){
Expand Down

0 comments on commit a28f31e

Please sign in to comment.