|
Packit |
7b22a4 |
/* Shared library add-on to iptables for DCCP matching
|
|
Packit |
7b22a4 |
*
|
|
Packit |
7b22a4 |
* (C) 2005 by Harald Welte <laforge@netfilter.org>
|
|
Packit |
7b22a4 |
*
|
|
Packit |
7b22a4 |
* This program is distributed under the terms of GNU GPL v2, 1991
|
|
Packit |
7b22a4 |
*
|
|
Packit |
7b22a4 |
*/
|
|
Packit |
7b22a4 |
#include <stdint.h>
|
|
Packit |
7b22a4 |
#include <stdio.h>
|
|
Packit |
7b22a4 |
#include <string.h>
|
|
Packit |
7b22a4 |
#include <stdlib.h>
|
|
Packit |
7b22a4 |
#include <netdb.h>
|
|
Packit |
7b22a4 |
#include <arpa/inet.h>
|
|
Packit |
7b22a4 |
#include <xtables.h>
|
|
Packit |
7b22a4 |
#include <linux/dccp.h>
|
|
Packit |
7b22a4 |
#include <linux/netfilter/x_tables.h>
|
|
Packit |
7b22a4 |
#include <linux/netfilter/xt_dccp.h>
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
#if 0
|
|
Packit |
7b22a4 |
#define DEBUGP(format, first...) printf(format, ##first)
|
|
Packit |
7b22a4 |
#define static
|
|
Packit |
7b22a4 |
#else
|
|
Packit |
7b22a4 |
#define DEBUGP(format, fist...)
|
|
Packit |
7b22a4 |
#endif
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
enum {
|
|
Packit |
7b22a4 |
O_SOURCE_PORT = 0,
|
|
Packit |
7b22a4 |
O_DEST_PORT,
|
|
Packit |
7b22a4 |
O_DCCP_TYPES,
|
|
Packit |
7b22a4 |
O_DCCP_OPTION,
|
|
Packit |
7b22a4 |
};
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static void dccp_help(void)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
printf(
|
|
Packit |
7b22a4 |
"dccp match options\n"
|
|
Packit |
7b22a4 |
"[!] --source-port port[:port] match source port(s)\n"
|
|
Packit |
7b22a4 |
" --sport ...\n"
|
|
Packit |
7b22a4 |
"[!] --destination-port port[:port] match destination port(s)\n"
|
|
Packit |
7b22a4 |
" --dport ...\n"
|
|
Packit |
7b22a4 |
"[!] --dccp-types type[,...] match when packet is one of the given types\n"
|
|
Packit |
7b22a4 |
"[!] --dccp-option option match if option (by number!) is set\n"
|
|
Packit |
7b22a4 |
);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
#define s struct xt_dccp_info
|
|
Packit |
7b22a4 |
static const struct xt_option_entry dccp_opts[] = {
|
|
Packit |
7b22a4 |
{.name = "source-port", .id = O_SOURCE_PORT, .type = XTTYPE_PORTRC,
|
|
Packit |
7b22a4 |
.flags = XTOPT_INVERT | XTOPT_PUT, XTOPT_POINTER(s, spts)},
|
|
Packit |
7b22a4 |
{.name = "sport", .id = O_SOURCE_PORT, .type = XTTYPE_PORTRC,
|
|
Packit |
7b22a4 |
.flags = XTOPT_INVERT | XTOPT_PUT, XTOPT_POINTER(s, spts)},
|
|
Packit |
7b22a4 |
{.name = "destination-port", .id = O_DEST_PORT, .type = XTTYPE_PORTRC,
|
|
Packit |
7b22a4 |
.flags = XTOPT_INVERT | XTOPT_PUT, XTOPT_POINTER(s, dpts)},
|
|
Packit |
7b22a4 |
{.name = "dport", .id = O_DEST_PORT, .type = XTTYPE_PORTRC,
|
|
Packit |
7b22a4 |
.flags = XTOPT_INVERT | XTOPT_PUT, XTOPT_POINTER(s, dpts)},
|
|
Packit |
7b22a4 |
{.name = "dccp-types", .id = O_DCCP_TYPES, .type = XTTYPE_STRING,
|
|
Packit |
7b22a4 |
.flags = XTOPT_INVERT},
|
|
Packit |
7b22a4 |
{.name = "dccp-option", .id = O_DCCP_OPTION, .type = XTTYPE_UINT8,
|
|
Packit |
7b22a4 |
.min = 1, .max = UINT8_MAX, .flags = XTOPT_INVERT | XTOPT_PUT,
|
|
Packit |
7b22a4 |
XTOPT_POINTER(s, option)},
|
|
Packit |
7b22a4 |
XTOPT_TABLEEND,
|
|
Packit |
7b22a4 |
};
|
|
Packit |
7b22a4 |
#undef s
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static const char *const dccp_pkt_types[] = {
|
|
Packit |
7b22a4 |
[DCCP_PKT_REQUEST] = "REQUEST",
|
|
Packit |
7b22a4 |
[DCCP_PKT_RESPONSE] = "RESPONSE",
|
|
Packit |
7b22a4 |
[DCCP_PKT_DATA] = "DATA",
|
|
Packit |
7b22a4 |
[DCCP_PKT_ACK] = "ACK",
|
|
Packit |
7b22a4 |
[DCCP_PKT_DATAACK] = "DATAACK",
|
|
Packit |
7b22a4 |
[DCCP_PKT_CLOSEREQ] = "CLOSEREQ",
|
|
Packit |
7b22a4 |
[DCCP_PKT_CLOSE] = "CLOSE",
|
|
Packit |
7b22a4 |
[DCCP_PKT_RESET] = "RESET",
|
|
Packit |
7b22a4 |
[DCCP_PKT_SYNC] = "SYNC",
|
|
Packit |
7b22a4 |
[DCCP_PKT_SYNCACK] = "SYNCACK",
|
|
Packit |
7b22a4 |
[DCCP_PKT_INVALID] = "INVALID",
|
|
Packit |
7b22a4 |
};
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static uint16_t
|
|
Packit |
7b22a4 |
parse_dccp_types(const char *typestring)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
uint16_t typemask = 0;
|
|
Packit |
7b22a4 |
char *ptr, *buffer;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
buffer = strdup(typestring);
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
for (ptr = strtok(buffer, ","); ptr; ptr = strtok(NULL, ",")) {
|
|
Packit |
7b22a4 |
unsigned int i;
|
|
Packit |
7b22a4 |
for (i = 0; i < ARRAY_SIZE(dccp_pkt_types); ++i)
|
|
Packit |
7b22a4 |
if (!strcasecmp(dccp_pkt_types[i], ptr)) {
|
|
Packit |
7b22a4 |
typemask |= (1 << i);
|
|
Packit |
7b22a4 |
break;
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
if (i == ARRAY_SIZE(dccp_pkt_types))
|
|
Packit |
7b22a4 |
xtables_error(PARAMETER_PROBLEM,
|
|
Packit |
7b22a4 |
"Unknown DCCP type `%s'", ptr);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
free(buffer);
|
|
Packit |
7b22a4 |
return typemask;
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static void dccp_parse(struct xt_option_call *cb)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
struct xt_dccp_info *einfo = cb->data;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
xtables_option_parse(cb);
|
|
Packit |
7b22a4 |
switch (cb->entry->id) {
|
|
Packit |
7b22a4 |
case O_SOURCE_PORT:
|
|
Packit |
7b22a4 |
einfo->flags |= XT_DCCP_SRC_PORTS;
|
|
Packit |
7b22a4 |
if (cb->invert)
|
|
Packit |
7b22a4 |
einfo->invflags |= XT_DCCP_SRC_PORTS;
|
|
Packit |
7b22a4 |
break;
|
|
Packit |
7b22a4 |
case O_DEST_PORT:
|
|
Packit |
7b22a4 |
einfo->flags |= XT_DCCP_DEST_PORTS;
|
|
Packit |
7b22a4 |
if (cb->invert)
|
|
Packit |
7b22a4 |
einfo->invflags |= XT_DCCP_DEST_PORTS;
|
|
Packit |
7b22a4 |
break;
|
|
Packit |
7b22a4 |
case O_DCCP_TYPES:
|
|
Packit |
7b22a4 |
einfo->flags |= XT_DCCP_TYPE;
|
|
Packit |
7b22a4 |
einfo->typemask = parse_dccp_types(cb->arg);
|
|
Packit |
7b22a4 |
if (cb->invert)
|
|
Packit |
7b22a4 |
einfo->invflags |= XT_DCCP_TYPE;
|
|
Packit |
7b22a4 |
break;
|
|
Packit |
7b22a4 |
case O_DCCP_OPTION:
|
|
Packit |
7b22a4 |
einfo->flags |= XT_DCCP_OPTION;
|
|
Packit |
7b22a4 |
if (cb->invert)
|
|
Packit |
7b22a4 |
einfo->invflags |= XT_DCCP_OPTION;
|
|
Packit |
7b22a4 |
break;
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static const char *
|
|
Packit |
7b22a4 |
port_to_service(int port)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
const struct servent *service;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if ((service = getservbyport(htons(port), "dccp")))
|
|
Packit |
7b22a4 |
return service->s_name;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
return NULL;
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static void
|
|
Packit |
7b22a4 |
print_port(uint16_t port, int numeric)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
const char *service;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (numeric || (service = port_to_service(port)) == NULL)
|
|
Packit |
7b22a4 |
printf("%u", port);
|
|
Packit |
7b22a4 |
else
|
|
Packit |
7b22a4 |
printf("%s", service);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static void
|
|
Packit |
7b22a4 |
print_ports(const char *name, uint16_t min, uint16_t max,
|
|
Packit |
7b22a4 |
int invert, int numeric)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
const char *inv = invert ? "!" : "";
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (min != 0 || max != 0xFFFF || invert) {
|
|
Packit |
7b22a4 |
printf(" %s", name);
|
|
Packit |
7b22a4 |
if (min == max) {
|
|
Packit |
7b22a4 |
printf(":%s", inv);
|
|
Packit |
7b22a4 |
print_port(min, numeric);
|
|
Packit |
7b22a4 |
} else {
|
|
Packit |
7b22a4 |
printf("s:%s", inv);
|
|
Packit |
7b22a4 |
print_port(min, numeric);
|
|
Packit |
7b22a4 |
printf(":");
|
|
Packit |
7b22a4 |
print_port(max, numeric);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static void
|
|
Packit |
7b22a4 |
print_types(uint16_t types, int inverted, int numeric)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
int have_type = 0;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (inverted)
|
|
Packit |
7b22a4 |
printf(" !");
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
printf(" ");
|
|
Packit |
7b22a4 |
while (types) {
|
|
Packit |
7b22a4 |
unsigned int i;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
for (i = 0; !(types & (1 << i)); i++);
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (have_type)
|
|
Packit |
7b22a4 |
printf(",");
|
|
Packit |
7b22a4 |
else
|
|
Packit |
7b22a4 |
have_type = 1;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (numeric)
|
|
Packit |
7b22a4 |
printf("%u", i);
|
|
Packit |
7b22a4 |
else
|
|
Packit |
7b22a4 |
printf("%s", dccp_pkt_types[i]);
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
types &= ~(1 << i);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static void
|
|
Packit |
7b22a4 |
print_option(uint8_t option, int invert, int numeric)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
if (option || invert)
|
|
Packit |
7b22a4 |
printf(" option=%s%u", invert ? "!" : "", option);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static void
|
|
Packit |
7b22a4 |
dccp_print(const void *ip, const struct xt_entry_match *match, int numeric)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
const struct xt_dccp_info *einfo =
|
|
Packit |
7b22a4 |
(const struct xt_dccp_info *)match->data;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
printf(" dccp");
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (einfo->flags & XT_DCCP_SRC_PORTS) {
|
|
Packit |
7b22a4 |
print_ports("spt", einfo->spts[0], einfo->spts[1],
|
|
Packit |
7b22a4 |
einfo->invflags & XT_DCCP_SRC_PORTS,
|
|
Packit |
7b22a4 |
numeric);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (einfo->flags & XT_DCCP_DEST_PORTS) {
|
|
Packit |
7b22a4 |
print_ports("dpt", einfo->dpts[0], einfo->dpts[1],
|
|
Packit |
7b22a4 |
einfo->invflags & XT_DCCP_DEST_PORTS,
|
|
Packit |
7b22a4 |
numeric);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (einfo->flags & XT_DCCP_TYPE) {
|
|
Packit |
7b22a4 |
print_types(einfo->typemask,
|
|
Packit |
7b22a4 |
einfo->invflags & XT_DCCP_TYPE,
|
|
Packit |
7b22a4 |
numeric);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (einfo->flags & XT_DCCP_OPTION) {
|
|
Packit |
7b22a4 |
print_option(einfo->option,
|
|
Packit |
7b22a4 |
einfo->invflags & XT_DCCP_OPTION, numeric);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static void dccp_save(const void *ip, const struct xt_entry_match *match)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
const struct xt_dccp_info *einfo =
|
|
Packit |
7b22a4 |
(const struct xt_dccp_info *)match->data;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (einfo->flags & XT_DCCP_SRC_PORTS) {
|
|
Packit |
7b22a4 |
if (einfo->invflags & XT_DCCP_SRC_PORTS)
|
|
Packit |
7b22a4 |
printf(" !");
|
|
Packit |
7b22a4 |
if (einfo->spts[0] != einfo->spts[1])
|
|
Packit |
7b22a4 |
printf(" --sport %u:%u",
|
|
Packit |
7b22a4 |
einfo->spts[0], einfo->spts[1]);
|
|
Packit |
7b22a4 |
else
|
|
Packit |
7b22a4 |
printf(" --sport %u", einfo->spts[0]);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (einfo->flags & XT_DCCP_DEST_PORTS) {
|
|
Packit |
7b22a4 |
if (einfo->invflags & XT_DCCP_DEST_PORTS)
|
|
Packit |
7b22a4 |
printf(" !");
|
|
Packit |
7b22a4 |
if (einfo->dpts[0] != einfo->dpts[1])
|
|
Packit |
7b22a4 |
printf(" --dport %u:%u",
|
|
Packit |
7b22a4 |
einfo->dpts[0], einfo->dpts[1]);
|
|
Packit |
7b22a4 |
else
|
|
Packit |
7b22a4 |
printf(" --dport %u", einfo->dpts[0]);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (einfo->flags & XT_DCCP_TYPE) {
|
|
Packit |
7b22a4 |
printf("%s --dccp-types",
|
|
Packit |
7b22a4 |
einfo->invflags & XT_DCCP_TYPE ? " !" : "");
|
|
Packit |
7b22a4 |
print_types(einfo->typemask, false, 0);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (einfo->flags & XT_DCCP_OPTION) {
|
|
Packit |
7b22a4 |
printf("%s --dccp-option %u",
|
|
Packit |
7b22a4 |
einfo->invflags & XT_DCCP_OPTION ? " !" : "",
|
|
Packit |
7b22a4 |
einfo->option);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static const char *const dccp_pkt_types_xlate[] = {
|
|
Packit |
7b22a4 |
[DCCP_PKT_REQUEST] = "request",
|
|
Packit |
7b22a4 |
[DCCP_PKT_RESPONSE] = "response",
|
|
Packit |
7b22a4 |
[DCCP_PKT_DATA] = "data",
|
|
Packit |
7b22a4 |
[DCCP_PKT_ACK] = "ack",
|
|
Packit |
7b22a4 |
[DCCP_PKT_DATAACK] = "dataack",
|
|
Packit |
7b22a4 |
[DCCP_PKT_CLOSEREQ] = "closereq",
|
|
Packit |
7b22a4 |
[DCCP_PKT_CLOSE] = "close",
|
|
Packit |
7b22a4 |
[DCCP_PKT_RESET] = "reset",
|
|
Packit |
7b22a4 |
[DCCP_PKT_SYNC] = "sync",
|
|
Packit |
7b22a4 |
[DCCP_PKT_SYNCACK] = "syncack",
|
|
Packit |
7b22a4 |
};
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static int dccp_type_xlate(const struct xt_dccp_info *einfo,
|
|
Packit |
7b22a4 |
struct xt_xlate *xl)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
bool have_type = false, set_need = false;
|
|
Packit |
7b22a4 |
uint16_t types = einfo->typemask;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (types & (1 << DCCP_PKT_INVALID))
|
|
Packit |
7b22a4 |
return 0;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
xt_xlate_add(xl, " dccp type%s ", einfo->invflags ? " !=" : "");
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if ((types != 0) && !(types == (types & -types))) {
|
|
Packit |
7b22a4 |
xt_xlate_add(xl, "{");
|
|
Packit |
7b22a4 |
set_need = true;
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
while (types) {
|
|
Packit |
7b22a4 |
unsigned int i;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
for (i = 0; !(types & (1 << i)); i++);
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (have_type)
|
|
Packit |
7b22a4 |
xt_xlate_add(xl, ", ");
|
|
Packit |
7b22a4 |
else
|
|
Packit |
7b22a4 |
have_type = true;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
xt_xlate_add(xl, "%s", dccp_pkt_types_xlate[i]);
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
types &= ~(1 << i);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (set_need)
|
|
Packit |
7b22a4 |
xt_xlate_add(xl, "}");
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
return 1;
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
static int dccp_xlate(struct xt_xlate *xl,
|
|
Packit |
7b22a4 |
const struct xt_xlate_mt_params *params)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
const struct xt_dccp_info *einfo =
|
|
Packit |
7b22a4 |
(const struct xt_dccp_info *)params->match->data;
|
|
Packit |
7b22a4 |
char *space = "";
|
|
Packit |
7b22a4 |
int ret = 1;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
xt_xlate_add(xl, "dccp ");
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (einfo->flags & XT_DCCP_SRC_PORTS) {
|
|
Packit |
7b22a4 |
if (einfo->spts[0] != einfo->spts[1])
|
|
Packit |
7b22a4 |
xt_xlate_add(xl, "sport%s %u-%u",
|
|
Packit |
7b22a4 |
einfo->invflags & XT_DCCP_SRC_PORTS ? " !=" : "",
|
|
Packit |
7b22a4 |
einfo->spts[0], einfo->spts[1]);
|
|
Packit |
7b22a4 |
else
|
|
Packit |
7b22a4 |
xt_xlate_add(xl, "sport%s %u",
|
|
Packit |
7b22a4 |
einfo->invflags & XT_DCCP_SRC_PORTS ? " !=" : "",
|
|
Packit |
7b22a4 |
einfo->spts[0]);
|
|
Packit |
7b22a4 |
space = " ";
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (einfo->flags & XT_DCCP_DEST_PORTS) {
|
|
Packit |
7b22a4 |
if (einfo->dpts[0] != einfo->dpts[1])
|
|
Packit |
7b22a4 |
xt_xlate_add(xl, "%sdport%s %u-%u", space,
|
|
Packit |
7b22a4 |
einfo->invflags & XT_DCCP_DEST_PORTS ? " !=" : "",
|
|
Packit |
7b22a4 |
einfo->dpts[0], einfo->dpts[1]);
|
|
Packit |
7b22a4 |
else
|
|
Packit |
7b22a4 |
xt_xlate_add(xl, "%sdport%s %u", space,
|
|
Packit |
7b22a4 |
einfo->invflags & XT_DCCP_DEST_PORTS ? " !=" : "",
|
|
Packit |
7b22a4 |
einfo->dpts[0]);
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (einfo->flags & XT_DCCP_TYPE)
|
|
Packit |
7b22a4 |
ret = dccp_type_xlate(einfo, xl);
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
if (einfo->flags & XT_DCCP_OPTION)
|
|
Packit |
7b22a4 |
ret = 0;
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
return ret;
|
|
Packit |
7b22a4 |
}
|
|
Packit |
7b22a4 |
static struct xtables_match dccp_match = {
|
|
Packit |
7b22a4 |
.name = "dccp",
|
|
Packit |
7b22a4 |
.family = NFPROTO_UNSPEC,
|
|
Packit |
7b22a4 |
.version = XTABLES_VERSION,
|
|
Packit |
7b22a4 |
.size = XT_ALIGN(sizeof(struct xt_dccp_info)),
|
|
Packit |
7b22a4 |
.userspacesize = XT_ALIGN(sizeof(struct xt_dccp_info)),
|
|
Packit |
7b22a4 |
.help = dccp_help,
|
|
Packit |
7b22a4 |
.print = dccp_print,
|
|
Packit |
7b22a4 |
.save = dccp_save,
|
|
Packit |
7b22a4 |
.x6_parse = dccp_parse,
|
|
Packit |
7b22a4 |
.x6_options = dccp_opts,
|
|
Packit |
7b22a4 |
.xlate = dccp_xlate,
|
|
Packit |
7b22a4 |
};
|
|
Packit |
7b22a4 |
|
|
Packit |
7b22a4 |
void _init(void)
|
|
Packit |
7b22a4 |
{
|
|
Packit |
7b22a4 |
xtables_register_match(&dccp_match);
|
|
Packit |
7b22a4 |
}
|