1 Index: iptables-1.3.8/extensions/libipt_multiport.c
2 ===================================================================
3 --- iptables-1.3.8.orig/extensions/libipt_multiport.c 2007-07-31 15:27:55.000000000 -0500
4 +++ iptables-1.3.8/extensions/libipt_multiport.c 2007-07-31 15:27:56.000000000 -0500
6 /* To ensure that iptables compiles with an old kernel */
7 #include "../include/linux/netfilter_ipv4/ipt_multiport.h"
9 -/* Function which prints out usage message. */
14 -"multiport v%s options:\n"
15 -" --source-ports port[,port,port...]\n"
17 -" match source port(s)\n"
18 -" --destination-ports port[,port,port...]\n"
20 -" match destination port(s)\n"
21 -" --ports port[,port,port]\n"
22 -" match both source and destination port(s)\n"
23 -" NOTE: this kernel does not support port ranges in multiport.\n",
35 -parse_multi_ports(const char *portstring, u_int16_t *ports, const char *proto)
37 - char *buffer, *cp, *next;
40 - buffer = strdup(portstring);
41 - if (!buffer) exit_error(OTHER_PROBLEM, "strdup failed");
43 - for (cp=buffer, i=0; cp && i<IPT_MULTI_PORTS; cp=next,i++)
45 - next=strchr(cp, ',');
46 - if (next) *next++='\0';
47 - ports[i] = parse_port(cp, proto);
49 - if (cp) exit_error(PARAMETER_PROBLEM, "too many ports specified");
55 parse_multi_ports_v1(const char *portstring,
56 struct ipt_multiport_v1 *multiinfo,
58 "multiport only works with TCP, UDP, UDPLITE, SCTP and DCCP");
61 -/* Function which parses command options; returns true if it
64 -parse(int c, char **argv, int invert, unsigned int *flags,
65 - const struct ipt_entry *entry,
66 - unsigned int *nfcache,
67 - struct ipt_entry_match **match)
70 - struct ipt_multiport *multiinfo
71 - = (struct ipt_multiport *)(*match)->data;
75 - check_inverse(argv[optind-1], &invert, &optind, 0);
76 - proto = check_proto(entry);
77 - multiinfo->count = parse_multi_ports(argv[optind-1],
78 - multiinfo->ports, proto);
79 - multiinfo->flags = IPT_MULTIPORT_SOURCE;
83 - check_inverse(argv[optind-1], &invert, &optind, 0);
84 - proto = check_proto(entry);
85 - multiinfo->count = parse_multi_ports(argv[optind-1],
86 - multiinfo->ports, proto);
87 - multiinfo->flags = IPT_MULTIPORT_DESTINATION;
91 - check_inverse(argv[optind-1], &invert, &optind, 0);
92 - proto = check_proto(entry);
93 - multiinfo->count = parse_multi_ports(argv[optind-1],
94 - multiinfo->ports, proto);
95 - multiinfo->flags = IPT_MULTIPORT_EITHER;
103 - exit_error(PARAMETER_PROBLEM,
104 - "multiport does not support invert");
107 - exit_error(PARAMETER_PROBLEM,
108 - "multiport can only have one option");
114 parse_v1(int c, char **argv, int invert, unsigned int *flags,
115 const struct ipt_entry *entry,
117 printf("%s", service);
120 -/* Prints out the matchinfo. */
122 -print(const struct ipt_ip *ip,
123 - const struct ipt_entry_match *match,
126 - const struct ipt_multiport *multiinfo
127 - = (const struct ipt_multiport *)match->data;
130 - printf("multiport ");
132 - switch (multiinfo->flags) {
133 - case IPT_MULTIPORT_SOURCE:
137 - case IPT_MULTIPORT_DESTINATION:
141 - case IPT_MULTIPORT_EITHER:
150 - for (i=0; i < multiinfo->count; i++) {
151 - printf("%s", i ? "," : "");
152 - print_port(multiinfo->ports[i], ip->proto, numeric);
158 print_v1(const struct ipt_ip *ip,
159 const struct ipt_entry_match *match,
164 -/* Saves the union ipt_matchinfo in parsable form to stdout. */
165 -static void save(const struct ipt_ip *ip, const struct ipt_entry_match *match)
167 - const struct ipt_multiport *multiinfo
168 - = (const struct ipt_multiport *)match->data;
171 - switch (multiinfo->flags) {
172 - case IPT_MULTIPORT_SOURCE:
173 - printf("--sports ");
176 - case IPT_MULTIPORT_DESTINATION:
177 - printf("--dports ");
180 - case IPT_MULTIPORT_EITHER:
181 - printf("--ports ");
185 - for (i=0; i < multiinfo->count; i++) {
186 - printf("%s", i ? "," : "");
187 - print_port(multiinfo->ports[i], ip->proto, 1);
192 static void save_v1(const struct ipt_ip *ip,
193 const struct ipt_entry_match *match)
195 @@ -427,19 +272,20 @@
200 static struct iptables_match multiport = {
204 .version = IPTABLES_VERSION,
205 - .size = IPT_ALIGN(sizeof(struct ipt_multiport)),
206 - .userspacesize = IPT_ALIGN(sizeof(struct ipt_multiport)),
209 + .size = IPT_ALIGN(sizeof(struct ipt_multiport_v1)),
210 + .userspacesize = IPT_ALIGN(sizeof(struct ipt_multiport_v1)),
214 + .parse = &parse_v1,
215 .final_check = &final_check,
218 + .print = &print_v1,