Index: src/datacarousel/datagram.c =================================================================== --- src.orig/datacarousel/datagram.c 2006-01-02 19:23:47.000000000 +0100 +++ src/datacarousel/datagram.c 2006-08-22 22:20:13.000000000 +0200 @@ -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); Index: src/dvbsnoop.c =================================================================== --- src.orig/dvbsnoop.c 2005-09-07 01:13:50.000000000 +0200 +++ src/dvbsnoop.c 2006-08-22 21:51:07.000000000 +0200 @@ -142,9 +142,45 @@ #include "dvb_api/fe_info.h" +/* + * Open a tunnel/tap device as found in networking/tuntap.txt of the + * Linux Kernel + */ + #include + #include +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_fd = -1; int main(int argc, char **argv) @@ -152,7 +188,7 @@ OPTION opt; int err = 0; - + char dev[20] = ""; /* -- init options and cmdline parsing @@ -166,7 +202,10 @@ 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 ); + } indent (0); if (! opt.binary_out) { Index: src/misc/cmdline.c =================================================================== --- src.orig/misc/cmdline.c 2006-03-06 01:04:54.000000000 +0100 +++ src/misc/cmdline.c 2006-08-22 21:17:47.000000000 +0200 @@ -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: src/misc/cmdline.h =================================================================== --- src.orig/misc/cmdline.h 2006-03-06 01:04:54.000000000 +0100 +++ src/misc/cmdline.h 2006-08-22 21:16:11.000000000 +0200 @@ -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;