Implement DCCP protocol support for portcons.

This commit is contained in:
Chris PeBenito 2016-04-06 13:01:28 -04:00
parent bb1acd1c7f
commit 1147d00797
3 changed files with 13 additions and 1 deletions

View File

@ -694,6 +694,11 @@
<string/>
</property>
</item>
<item>
<property name="text">
<string>DCCP</string>
</property>
</item>
<item>
<property name="text">
<string>TCP</string>

View File

@ -4919,6 +4919,8 @@ int define_port_context(unsigned int low, unsigned int high)
protocol = IPPROTO_TCP;
} else if ((strcmp(id, "udp") == 0) || (strcmp(id, "UDP") == 0)) {
protocol = IPPROTO_UDP;
} else if ((strcmp(id, "dccp") == 0) || (strcmp(id, "DCCP") == 0)) {
protocol = IPPROTO_DCCP;
} else {
yyerror2("unrecognized protocol %s", id);
free(newc);

View File

@ -25,6 +25,10 @@ from . import context
port_range = namedtuple("port_range", ["low", "high"])
# Python does not have a constant
# for the DCCP protocol.
IPPROTO_DCCP = getprotobyname("dccp")
def netifcon_factory(policy, name):
"""Factory function for creating netifcon objects."""
@ -146,7 +150,8 @@ class PortconProtocol(int):
corresponding protocol string (udp, tcp).
"""
_proto_to_text = {IPPROTO_TCP: 'tcp',
_proto_to_text = {IPPROTO_DCCP: 'dccp',
IPPROTO_TCP: 'tcp',
IPPROTO_UDP: 'udp'}
def __new__(cls, value):