Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / libpcap / pcap-linux.c.rej
blob941503fb9619dae49799eb97ad56de88b58fbbef
1 --- pcap-linux.c        2008-10-27 18:52:19.000000000 -0700
2 +++ pcap-linux.c        2008-12-15 10:40:38.000000000 -0800
3 @@ -300,32 +304,72 @@
4  pcap_create(const char *device, char *ebuf)
5  {
6         pcap_t *handle;
7 +       char *device_no_prefix = (char*)device;
9 +#ifdef HAVE_REMOTE
10 +       /*
11 +               Retrofit; we have to make older applications compatible with the remote capture
12 +               So, we're calling the pcap_open_remote() from here, that is a very dirty thing.
13 +               Obviously, we cannot exploit all the new features; for instance, we cannot
14 +               send authentication, we cannot use a UDP data connection, and so on.
15 +       */
17 +       char host[PCAP_BUF_SIZE + 1];
18 +       char port[PCAP_BUF_SIZE + 1];
19 +       char name[PCAP_BUF_SIZE + 1];
20 +       int srctype;
22 +       if (pcap_parsesrcstr(device, &srctype, host, port, name, ebuf) )
23 +               return NULL;
25 +       if (srctype == PCAP_SRC_IFREMOTE)
26 +       {
27 +               handle = pcap_create_common(device, ebuf);
28 +               if (handle == NULL)
29 +                       return NULL;
31 +               handle->activate_op = pcap_activate_linux;
32 +               handle->can_set_rfmon_op = NULL;
33 +               return handle;
34 +       }
35 +       
36 +       if (srctype == PCAP_SRC_IFLOCAL)
37 +       {
38 +               /*
39 +                * If it starts with rpcap://, cut down the string
40 +                */
41 +               if (strncmp(device, PCAP_SRC_IF_STRING, strlen(PCAP_SRC_IF_STRING)) == 0)
42 +               {
43 +                       device_no_prefix = (char*)device + strlen(PCAP_SRC_IF_STRING);
44 +               }
45 +       }
46 +#endif         /* HAVE_REMOTE */
48  #ifdef HAVE_DAG_API
49 -       if (strstr(device, "dag")) {
50 -               return dag_create(device, ebuf);
51 +       if (strstr(device_no_prefix, "dag")) {
52 +               return dag_create(device_no_prefix, ebuf);
53         }
54  #endif /* HAVE_DAG_API */
56  #ifdef HAVE_SEPTEL_API
57 -       if (strstr(device, "septel")) {
58 -               return septel_create(device, ebuf);
59 +       if (strstr(device_no_prefix, "septel")) {
60 +               return septel_create(device_no_prefix, ebuf);
61         }
62  #endif /* HAVE_SEPTEL_API */
64  #ifdef PCAP_SUPPORT_BT
65 -       if (strstr(device, "bluetooth")) {
66 -               return bt_create(device, ebuf);
67 +       if (strstr(device_no_prefix, "bluetooth")) {
68 +               return bt_create(device_no_prefix, ebuf);
69         }
70  #endif
72  #ifdef PCAP_SUPPORT_USB
73 -       if (strstr(device, "usb")) {
74 -               return usb_create(device, ebuf);
75 +       if (strstr(device_no_prefix, "usb")) {
76 +               return usb_create(device_no_prefix, ebuf);
77         }
78  #endif
80 -       handle = pcap_create_common(device, ebuf);
81 +       handle = pcap_create_common(device_no_prefix, ebuf);
82         if (handle == NULL)
83                 return NULL;