1 diff -urN iptables.old/extensions/libipt_multiport.c iptables.dev/extensions/libipt_multiport.c
2 --- iptables.old/extensions/libipt_multiport.c 2005-02-19 20:19:17.000000000 +0100
3 +++ iptables.dev/extensions/libipt_multiport.c 2006-02-04 05:46:12.154127750 +0100
5 /* To ensure that iptables compiles with an old kernel */
6 #include "../include/linux/netfilter_ipv4/ipt_multiport.h"
8 -/* Function which prints out usage message. */
13 -"multiport v%s options:\n"
14 -" --source-ports port[,port,port...]\n"
16 -" match source port(s)\n"
17 -" --destination-ports port[,port,port...]\n"
19 -" match destination port(s)\n"
20 -" --ports port[,port,port]\n"
21 -" match both source and destination port(s)\n"
22 -" NOTE: this kernel does not support port ranges in multiport.\n",
30 "invalid port/service `%s' specified", port);
34 -parse_multi_ports(const char *portstring, u_int16_t *ports, const char *proto)
36 - char *buffer, *cp, *next;
39 - buffer = strdup(portstring);
40 - if (!buffer) exit_error(OTHER_PROBLEM, "strdup failed");
42 - for (cp=buffer, i=0; cp && i<IPT_MULTI_PORTS; cp=next,i++)
44 - next=strchr(cp, ',');
45 - if (next) *next++='\0';
46 - ports[i] = parse_port(cp, proto);
48 - if (cp) exit_error(PARAMETER_PROBLEM, "too many ports specified");
54 parse_multi_ports_v1(const char *portstring,
55 struct ipt_multiport_v1 *multiinfo,
57 "multiport only works with TCP or UDP");
60 -/* Function which parses command options; returns true if it
63 -parse(int c, char **argv, int invert, unsigned int *flags,
64 - const struct ipt_entry *entry,
65 - unsigned int *nfcache,
66 - struct ipt_entry_match **match)
69 - struct ipt_multiport *multiinfo
70 - = (struct ipt_multiport *)(*match)->data;
74 - check_inverse(argv[optind-1], &invert, &optind, 0);
75 - proto = check_proto(entry);
76 - multiinfo->count = parse_multi_ports(argv[optind-1],
77 - multiinfo->ports, proto);
78 - multiinfo->flags = IPT_MULTIPORT_SOURCE;
82 - check_inverse(argv[optind-1], &invert, &optind, 0);
83 - proto = check_proto(entry);
84 - multiinfo->count = parse_multi_ports(argv[optind-1],
85 - multiinfo->ports, proto);
86 - multiinfo->flags = IPT_MULTIPORT_DESTINATION;
90 - check_inverse(argv[optind-1], &invert, &optind, 0);
91 - proto = check_proto(entry);
92 - multiinfo->count = parse_multi_ports(argv[optind-1],
93 - multiinfo->ports, proto);
94 - multiinfo->flags = IPT_MULTIPORT_EITHER;
102 - exit_error(PARAMETER_PROBLEM,
103 - "multiport does not support invert");
106 - exit_error(PARAMETER_PROBLEM,
107 - "multiport can only have one option");
113 parse_v1(int c, char **argv, int invert, unsigned int *flags,
114 const struct ipt_entry *entry,
116 printf("%s", service);
119 -/* Prints out the matchinfo. */
121 -print(const struct ipt_ip *ip,
122 - const struct ipt_entry_match *match,
125 - const struct ipt_multiport *multiinfo
126 - = (const struct ipt_multiport *)match->data;
129 - printf("multiport ");
131 - switch (multiinfo->flags) {
132 - case IPT_MULTIPORT_SOURCE:
136 - case IPT_MULTIPORT_DESTINATION:
140 - case IPT_MULTIPORT_EITHER:
149 - for (i=0; i < multiinfo->count; i++) {
150 - printf("%s", i ? "," : "");
151 - print_port(multiinfo->ports[i], ip->proto, numeric);
157 print_v1(const struct ipt_ip *ip,
158 const struct ipt_entry_match *match,
163 -/* Saves the union ipt_matchinfo in parsable form to stdout. */
164 -static void save(const struct ipt_ip *ip, const struct ipt_entry_match *match)
166 - const struct ipt_multiport *multiinfo
167 - = (const struct ipt_multiport *)match->data;
170 - switch (multiinfo->flags) {
171 - case IPT_MULTIPORT_SOURCE:
172 - printf("--sports ");
175 - case IPT_MULTIPORT_DESTINATION:
176 - printf("--dports ");
179 - case IPT_MULTIPORT_EITHER:
180 - printf("--ports ");
184 - for (i=0; i < multiinfo->count; i++) {
185 - printf("%s", i ? "," : "");
186 - print_port(multiinfo->ports[i], ip->proto, 1);
191 static void save_v1(const struct ipt_ip *ip,
192 const struct ipt_entry_match *match)
194 @@ -432,19 +277,20 @@
199 static struct iptables_match multiport = {
203 .version = IPTABLES_VERSION,
204 - .size = IPT_ALIGN(sizeof(struct ipt_multiport)),
205 - .userspacesize = IPT_ALIGN(sizeof(struct ipt_multiport)),
208 + .size = IPT_ALIGN(sizeof(struct ipt_multiport_v1)),
209 + .userspacesize = IPT_ALIGN(sizeof(struct ipt_multiport_v1)),
213 + .parse = &parse_v1,
214 .final_check = &final_check,
217 + .print = &print_v1,