All pastes #153838 Raw Edit

Unnamed

public text v1 · immutable
#153838 ·published 2006-08-29 21:51 UTC
rendered paste body
Index: dvbsnoop.c
===================================================================
RCS file: /cvs/tuxbox/apps/dvb/dvbsnoop/src/dvbsnoop.c,v
retrieving revision 1.32
diff -u -r1.32 dvbsnoop.c
--- a/dvbsnoop.c        6 Sep 2005 23:13:50 -0000       1.32
+++ b/dvbsnoop.c        29 Aug 2006 21:51:12 -0000
@@ -142,9 +142,61 @@
 #include "dvb_api/fe_info.h"
 
 
+/*
+ * Open a tunnel/tap device as found in networking/tuntap.txt of the
+ * Linux Kernel
+ */
+#include <linux/if.h>
+#include <linux/if_tun.h>
+#include <netinet/in.h>
 
 
+int tun_alloc(char *dev)
+{
+  struct ifreq ifr;
+  int fd, err;
+
+  if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) {
+    perror("Error opening /dev/net/tun:");
+    return -1;
+  }
+
+  memset(&ifr, 0, sizeof(ifr));
+
+  /* Flags: IFF_TUN   - TUN device (no Ethernet headers)
+   *        IFF_TAP   - TAP device
+   *
+   *        IFF_NO_PI - Do not provide packet information
+   */
+  ifr.ifr_flags = IFF_TUN | IFF_NO_PI;
+  if( *dev )
+    strncpy(ifr.ifr_name, dev, IFNAMSIZ);
+
+  if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){
+    perror("IOCTL failed");
+    close(fd);
+    return -1;
+  }
+  strcpy(dev, ifr.ifr_name);
+  return fd;
+}
 
+int tun_ifup( char* dev ) {
+    struct ifreq ifr;
+    int fd = socket (  PF_INET, SOCK_DGRAM, IPPROTO_IP );
+    strcpy( ifr.ifr_name, dev );
+    if ( ioctl( fd, SIOCGIFFLAGS, &ifr ) < 0 )
+        return -1;
+
+    ifr.ifr_flags |= IFF_UP;
+    if ( ioctl( fd, SIOCSIFFLAGS, &ifr ) < 0 )
+        return -2;
+
+    return 0;
+}
+
+
+int tun_fd = -1;
 
 int main(int argc, char **argv)
 
@@ -152,7 +204,7 @@
 
   OPTION  opt;
   int     err = 0;
-
+  char    dev[20] = "";
 
   /*
     -- init options and cmdline parsing
@@ -166,7 +218,12 @@
   setVerboseLevel (opt.printdecode);
   setHexPrintMode (opt.printhex);
 
-
+  if(! opt.tap_fd ) {
+    tun_fd = tun_alloc(dev);
+    printf( "Opened TAP device: %d %s\n", tun_fd, dev );
+    if (  tun_fd >= 0 )
+        tun_ifup( dev );
+  }
 
   indent (0);
   if (! opt.binary_out) {
cvs diff: Diffing datacarousel
Index: datacarousel/datagram.c
===================================================================
RCS file: /cvs/tuxbox/apps/dvb/dvbsnoop/src/datacarousel/datagram.c,v
retrieving revision 1.19
diff -u -r1.19 datagram.c
--- a/datacarousel/datagram.c   2 Jan 2006 18:23:47 -0000       1.19
+++ b/datacarousel/datagram.c   29 Aug 2006 21:51:12 -0000
@@ -85,7 +85,7 @@
 #include "misc/output.h"
 
 
-
+extern int tun_fd;
 
 
 void section_DSMCC_DATAGRAM (u_char *b, int len)
@@ -204,6 +204,9 @@
         int k;
         k = llc_snap (4,b);
  } else {
+    if ( tun_fd > 0 ) {
+        write(tun_fd, b, len1-4);
+    }
         print_databytes (4, "IP_datagram_bytes", b, len1-4);
  }
  b += (len1 - 4);
cvs diff: Diffing descriptors
cvs diff: Diffing dvb_api
Index: dvb_api/dmx_tspidscan.c
===================================================================
RCS file: /cvs/tuxbox/apps/dvb/dvbsnoop/src/dvb_api/dmx_tspidscan.c,v
retrieving revision 1.23
diff -u -r1.23 dmx_tspidscan.c
--- a/dvb_api/dmx_tspidscan.c   2 Jan 2006 18:23:59 -0000       1.23
+++ b/dvb_api/dmx_tspidscan.c   29 Aug 2006 21:51:12 -0000
@@ -133,8 +133,8 @@
 
 // timeout in ms
 // TimoutHIGH will be used on PIDs < 0x20
-#define PID_TIMEOUT_LOW                (250 - PID_TIME_WAIT)
-#define PID_TIMEOUT_HIGH       (30100 - PID_TIME_WAIT)
+#define PID_TIMEOUT_LOW                (10000 - PID_TIME_WAIT)
+#define PID_TIMEOUT_HIGH       (40100 - PID_TIME_WAIT)
 
 // max filters (will be checked dynamically)
 #define MAX_PID_FILTER         256
cvs diff: Diffing ebu
cvs diff: Diffing misc
Index: misc/cmdline.c
===================================================================
RCS file: /cvs/tuxbox/apps/dvb/dvbsnoop/src/misc/cmdline.c,v
retrieving revision 1.51
diff -u -r1.51 cmdline.c
--- a/misc/cmdline.c    6 Mar 2006 00:04:54 -0000       1.51
+++ b/misc/cmdline.c    29 Aug 2006 21:51:12 -0000
@@ -281,6 +281,7 @@
   memset(opt->filter, 0, DMX_FILTER_SIZE);
   memset(opt->mask,   0, DMX_FILTER_SIZE);
 
+  opt->tap_fd = -1;
 
   // -- store for getOption 
   opt_ptr = opt;
@@ -367,6 +368,8 @@
      } else if (isdigit (argv[i][0])) {
          opt->pid = str2i(argv[i]);    // PID
         if (opt->pid > MAX_PID) opt->help = 1;
+     } else if (!strcmp(argv[i],"-tap")) {
+       opt->tap_fd = 0;
      } else {
          opt->help = 1;
          break;
Index: misc/cmdline.h
===================================================================
RCS file: /cvs/tuxbox/apps/dvb/dvbsnoop/src/misc/cmdline.h,v
retrieving revision 1.33
diff -u -r1.33 cmdline.h
--- a/misc/cmdline.h    6 Mar 2006 00:04:54 -0000       1.33
+++ b/misc/cmdline.h    29 Aug 2006 21:51:12 -0000
@@ -64,6 +64,7 @@
   int         dsmcc_save;              // save modules from DSM-CC to file
   int         hide_copyright;                  // suppress message at prog start
   int         help;
+  int         tap_fd;   // TUN/TAP Filedescriptor used to dumb packages into the IP Stack
 } OPTION;
 
 
cvs diff: Diffing pes
cvs diff: Diffing private
cvs diff: Diffing private/default
cvs diff: Diffing private/premiere.de
cvs diff: Diffing sections
cvs diff: Diffing strings
cvs diff: Diffing testdata
cvs diff: Diffing ts
cvs diff: Diffing tvanytime