let ipkg fail when a package file to be installed is not found
[openwrt.git] / openwrt / package / arpd / patches / pcap-and-arg.patch
1 --- arpd/arpd.c Sun Feb  9 05:20:40 2003
2 +++ arpd/arpd.c.new     Mon Aug  1 00:50:40 2005
3 @@ -70,7 +70,7 @@
4  static void
5  usage(void)
6  {
7 -       fprintf(stderr, "Usage: arpd [-d] [-i interface] [net]\n");
8 +       fprintf(stderr, "Usage: arpd [-d] [-i interface] [-a 'pcap_expr'] [{host|net|range} ...]\n");
9         exit(1);
10  }
11  
12 @@ -182,7 +182,7 @@
13  }
14  
15  static void
16 -arpd_init(char *dev, int naddresses, char **addresses)
17 +arpd_init(char *dev, char *and_pcap_exp, int naddresses, char **addresses)
18  {
19         struct bpf_program fcode;
20         char filter[1024], ebuf[PCAP_ERRBUF_SIZE], *dst;
21 @@ -214,9 +214,13 @@
22                 errx(1, "bad interface configuration: not IP or Ethernet");
23         arpd_ifent.intf_addr.addr_bits = IP_ADDR_BITS;
24         
25 -       snprintf(filter, sizeof(filter), "arp %s%s%s and not ether src %s",
26 +       snprintf(filter, sizeof(filter), "arp %s%s%s and not ether src %s%s%s%s",
27             dst ? "and (" : "", dst ? dst : "", dst ? ")" : "",
28 -           addr_ntoa(&arpd_ifent.intf_link_addr));
29 +           addr_ntoa(&arpd_ifent.intf_link_addr),
30 +           and_pcap_exp ? " and (" : "",
31 +           and_pcap_exp ? and_pcap_exp : "",
32 +           and_pcap_exp ? ")" : ""
33 +           );
34         
35         if ((arpd_pcap = pcap_open_live(dev, 128, 0, 500, ebuf)) == NULL)
36                 errx(1, "pcap_open_live: %s", ebuf);
37 @@ -465,14 +469,14 @@
38  {
39         struct event recv_ev;
40         extern int (*event_sigcb)(void);
41 -       char *dev;
42 +       char *dev, *and_pcap_exp;
43         int c, debug;
44         FILE *fp;
45  
46         dev = NULL;
47         debug = 0;
48         
49 -       while ((c = getopt(argc, argv, "di:h?")) != -1) {
50 +       while ((c = getopt(argc, argv, "a:di:h?")) != -1) {
51                 switch (c) {
52                 case 'd':
53                         debug = 1;
54 @@ -480,6 +484,9 @@
55                 case 'i':
56                         dev = optarg;
57                         break;
58 +               case 'a':
59 +                       and_pcap_exp = optarg;
60 +                       break;
61                 default:
62                         usage();
63                         break;
64 @@ -489,9 +496,9 @@
65         argv += optind;
66  
67         if (argc == 0)
68 -               arpd_init(dev, 0, NULL);
69 +               arpd_init(dev, and_pcap_exp, 0, NULL);
70         else
71 -               arpd_init(dev, argc, argv);
72 +               arpd_init(dev, and_pcap_exp, argc, argv);
73         
74         if ((fp = fopen(PIDFILE, "w")) == NULL)
75                 err(1, "fopen");