Deleted Added
full compact
filter.c (49144) filter.c (49372)
1/*
2 * PPP Filter command Interface
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
1/*
2 * PPP Filter command Interface
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 * $Id: filter.c,v 1.32 1999/07/27 23:43:58 brian Exp $
20 * $Id: filter.c,v 1.33 1999/07/28 03:01:51 brian Exp $
21 *
22 * TODO: Shoud send ICMP error message when we discard packets.
23 */
24
25#include <sys/param.h>
26#include <netinet/in.h>
27#include <arpa/inet.h>
28#include <netdb.h>

--- 227 unchanged lines hidden (view full) ---

256 if (argc > 0) {
257 log_Printf(LogWARN, "ParseUdpOrTcp: bad src/dst port syntax: %s\n", *argv);
258 return 0;
259 }
260
261 return 1;
262}
263
21 *
22 * TODO: Shoud send ICMP error message when we discard packets.
23 */
24
25#include <sys/param.h>
26#include <netinet/in.h>
27#include <arpa/inet.h>
28#include <netdb.h>

--- 227 unchanged lines hidden (view full) ---

256 if (argc > 0) {
257 log_Printf(LogWARN, "ParseUdpOrTcp: bad src/dst port syntax: %s\n", *argv);
258 return 0;
259 }
260
261 return 1;
262}
263
264static int ParseIgmp(int argc, char const * const *argv, struct filterent *tgt)
264static int
265ParseIgmp(int argc, char const * const *argv, struct filterent *tgt)
265{
266{
266 /* Filter currently is a catch-all. Requests are either permitted or
267 dropped. */
267 /*
268 * Filter currently is a catch-all. Requests are either permitted or
269 * dropped.
270 */
268 if (argc != 0) {
269 log_Printf(LogWARN, "ParseIgmp: Too many parameters\n");
270 return 0;
271 } else
272 tgt->f_srcop = OP_NONE;
273
274 return 1;
275}
276
271 if (argc != 0) {
272 log_Printf(LogWARN, "ParseIgmp: Too many parameters\n");
273 return 0;
274 } else
275 tgt->f_srcop = OP_NONE;
276
277 return 1;
278}
279
280static int
281ParseOspf(int argc, char const * const *argv, struct filterent *tgt)
282{
283 /*
284 * Filter currently is a catch-all. Requests are either permitted or
285 * dropped.
286 */
287 if (argc != 0) {
288 log_Printf(LogWARN, "ParseOspf: Too many parameters\n");
289 return 0;
290 } else
291 tgt->f_srcop = OP_NONE;
292
293 return 1;
294}
295
277static unsigned
278addrtype(const char *addr)
279{
280 if (!strncasecmp(addr, "MYADDR", 6) && (addr[6] == '\0' || addr[6] == '/'))
281 return T_MYADDR;
282 if (!strncasecmp(addr, "HISADDR", 7) && (addr[7] == '\0' || addr[7] == '/'))
283 return T_HISADDR;
284

--- 142 unchanged lines hidden (view full) ---

427 val = ParseUdpOrTcp(argc, argv, P_UDP, &filterdata);
428 break;
429 case P_ICMP:
430 val = ParseIcmp(argc, argv, &filterdata);
431 break;
432 case P_IGMP:
433 val = ParseIgmp(argc, argv, &filterdata);
434 break;
296static unsigned
297addrtype(const char *addr)
298{
299 if (!strncasecmp(addr, "MYADDR", 6) && (addr[6] == '\0' || addr[6] == '/'))
300 return T_MYADDR;
301 if (!strncasecmp(addr, "HISADDR", 7) && (addr[7] == '\0' || addr[7] == '/'))
302 return T_HISADDR;
303

--- 142 unchanged lines hidden (view full) ---

446 val = ParseUdpOrTcp(argc, argv, P_UDP, &filterdata);
447 break;
448 case P_ICMP:
449 val = ParseIcmp(argc, argv, &filterdata);
450 break;
451 case P_IGMP:
452 val = ParseIgmp(argc, argv, &filterdata);
453 break;
454 case P_OSPF:
455 val = ParseOspf(argc, argv, &filterdata);
456 break;
435 }
436
437 log_Printf(LogDEBUG, "Parse: Src: %s\n", inet_ntoa(filterdata.f_src.ipaddr));
438 log_Printf(LogDEBUG, "Parse: Src mask: %s\n", inet_ntoa(filterdata.f_src.mask));
439 log_Printf(LogDEBUG, "Parse: Dst: %s\n", inet_ntoa(filterdata.f_dst.ipaddr));
440 log_Printf(LogDEBUG, "Parse: Dst mask: %s\n", inet_ntoa(filterdata.f_dst.mask));
441 log_Printf(LogDEBUG, "Parse: Proto = %d\n", proto);
442

--- 121 unchanged lines hidden (view full) ---

564 prompt_Printf(arg->prompt, "%s:\n", filter[f]->name);
565 doShowFilter(filter[f]->rule, arg->prompt);
566 }
567 }
568
569 return 0;
570}
571
457 }
458
459 log_Printf(LogDEBUG, "Parse: Src: %s\n", inet_ntoa(filterdata.f_src.ipaddr));
460 log_Printf(LogDEBUG, "Parse: Src mask: %s\n", inet_ntoa(filterdata.f_src.mask));
461 log_Printf(LogDEBUG, "Parse: Dst: %s\n", inet_ntoa(filterdata.f_dst.ipaddr));
462 log_Printf(LogDEBUG, "Parse: Dst mask: %s\n", inet_ntoa(filterdata.f_dst.mask));
463 log_Printf(LogDEBUG, "Parse: Proto = %d\n", proto);
464

--- 121 unchanged lines hidden (view full) ---

586 prompt_Printf(arg->prompt, "%s:\n", filter[f]->name);
587 doShowFilter(filter[f]->rule, arg->prompt);
588 }
589 }
590
591 return 0;
592}
593
572static const char *protoname[] = { "none", "tcp", "udp", "icmp", "igmp" };
594static const char *protoname[] = {
595 "none", "tcp", "udp", "icmp", "ospf", "igmp"
596};
573
574const char *
575filter_Proto2Nam(int proto)
576{
577 if (proto >= sizeof protoname / sizeof protoname[0])
578 return "unknown";
579 return protoname[proto];
580}

--- 62 unchanged lines hidden ---
597
598const char *
599filter_Proto2Nam(int proto)
600{
601 if (proto >= sizeof protoname / sizeof protoname[0])
602 return "unknown";
603 return protoname[proto];
604}

--- 62 unchanged lines hidden ---