From c5a077f5f97f0262782040b5f20e89a944202eb4 Mon Sep 17 00:00:00 2001
From: Harald Welte <laforge@gnumonks.org>
Date: Tue, 9 Nov 2010 16:58:31 +0100
Subject: Remove old 'tun' based interface to wireshark

this interface has long been replaced by GSMTAP on top of UDP, which
is supported in wireshark mainline
---
 gsm-tvoid/src/lib/Makefile.am |   2 -
 gsm-tvoid/src/lib/gsmstack.c  |   5 --
 gsm-tvoid/src/lib/gsmstack.h  |   4 --
 gsm-tvoid/src/lib/tun.c       | 125 ------------------------------------------
 gsm-tvoid/src/lib/tun.h       |   4 --
 5 files changed, 140 deletions(-)
 delete mode 100644 gsm-tvoid/src/lib/tun.c
 delete mode 100644 gsm-tvoid/src/lib/tun.h

(limited to 'gsm-tvoid')

diff --git a/gsm-tvoid/src/lib/Makefile.am b/gsm-tvoid/src/lib/Makefile.am
index 4f2ba65..382063a 100644
--- a/gsm-tvoid/src/lib/Makefile.am
+++ b/gsm-tvoid/src/lib/Makefile.am
@@ -51,7 +51,6 @@ _gsm_la_SOURCES = 		\
 	mm_f.cc				\
 	gsm_burst_cf.cc		\
 	gsm_burst_sink_c.cc	\
-	tun.c			\
 	out_pcap.c
 	
 
@@ -83,7 +82,6 @@ grinclude_HEADERS =		\
 	gsm_burst_cf.h		\
 	gsm_burst_sink_c.h	\
 	gsm_constants.h		\
-	tun.h			\
 	out_pcap.h		\
 	gsmtap.h
 
diff --git a/gsm-tvoid/src/lib/gsmstack.c b/gsm-tvoid/src/lib/gsmstack.c
index a46bc87..988689e 100644
--- a/gsm-tvoid/src/lib/gsmstack.c
+++ b/gsm-tvoid/src/lib/gsmstack.c
@@ -72,10 +72,6 @@ GS_new(GS_CTX *ctx)
 	ctx->fn = -1;
 	ctx->bsic = -1;
 
-	ctx->tun_fd = mktun("gsm", ctx->ether_addr);
-	if (ctx->tun_fd < 0)
-		fprintf(stderr, "cannot open 'gsm' tun device, did you create it?\n");
-
 	ctx->pcap_fd = open_pcap_file("tvoid.pcap");
 	if (ctx->pcap_fd < 0)
 		fprintf(stderr, "cannot open PCAP file: %s\n", strerror(errno));
@@ -165,7 +161,6 @@ GS_process(GS_CTX *ctx, int ts, int type, const unsigned char *src)
 		//DEBUGF("OK TS %d, len %d\n", ts, len);
 
 		out_gsmdecode(0, 0, ts, ctx->fn - 4, data, len);
-		write_interface(ctx->tun_fd, data+1, len-1, ctx->ether_addr);
 		write_pcap_packet(ctx->pcap_fd, 0 /* arfcn */, ts, ctx->fn,
 				  0, NORMAL, data, len);
 #if 0
diff --git a/gsm-tvoid/src/lib/gsmstack.h b/gsm-tvoid/src/lib/gsmstack.h
index a9da102..337293e 100644
--- a/gsm-tvoid/src/lib/gsmstack.h
+++ b/gsm-tvoid/src/lib/gsmstack.h
@@ -6,7 +6,6 @@
 extern "C" {
 #endif
 
-#include <linux/if_ether.h>
 #include "interleave.h"
 
 struct gs_ts_ctx {
@@ -26,9 +25,6 @@ typedef struct
 
 	struct gs_ts_ctx ts_ctx[8];
 
-	int tun_fd;
-	unsigned char ether_addr[ETH_ALEN];
-
 	int pcap_fd;
 	int burst_pcap_fd;
 } GS_CTX;
diff --git a/gsm-tvoid/src/lib/tun.c b/gsm-tvoid/src/lib/tun.c
deleted file mode 100644
index 2abda90..0000000
--- a/gsm-tvoid/src/lib/tun.c
+++ /dev/null
@@ -1,125 +0,0 @@
-// $Id: tun.cc,v 1.2 2007-07-07 16:31:42 jl Exp $
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <libgen.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <linux/if_tun.h>
-#include <linux/if.h>
-#include <linux/if_ether.h>
-#include <arpa/inet.h>
-
-int mktun(const char *chan_name, unsigned char *ether_addr) {
-
-	struct ifreq ifr;
-	// struct ifreq ifw;
-	char if_name[IFNAMSIZ];
-	int fd, one = 1;
-	// int sd;
-
-	// construct TUN interface
-	if((fd = open("/dev/net/tun", O_RDWR)) == -1) {
-		perror("open");
-		return -1;
-	}
-	memset(&ifr, 0, sizeof(ifr));
-	ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
-	snprintf(ifr.ifr_name, IFNAMSIZ, "%s", chan_name);
-	if(ioctl(fd, TUNSETIFF, (void *)&ifr) == -1) {
-		perror("TUNSETIFF");
-		close(fd);
-		return -1;
-	}
-
-	// save actual name
-	memcpy(if_name, ifr.ifr_name, IFNAMSIZ);
-
-	// get ether addr
-	memset(&ifr, 0, sizeof(ifr));
-	memcpy(ifr.ifr_name, if_name, IFNAMSIZ);
-	if(ioctl(fd, SIOCGIFHWADDR, (void *)&ifr) == -1) {
-		perror("SIOCGIFHWADDR");
-		close(fd);
-		return -1;
-	}
-	memcpy(ether_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
-
-	// set persistent
-	if(ioctl(fd, TUNSETPERSIST, (void *)&one) == -1) {
-		perror("TUNSETPERSIST");
-		close(fd);
-		return -1;
-	}
-
-	// set interface up
-	/* XXX must be root
-	if((sd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
-		perror("socket");
-		close(fd);
-		return -1;
-	}
-
-	// get current flags
-	memset(&ifr, 0, sizeof(ifr));
-	strncpy(ifr.ifr_name, if_name, IFNAMSIZ - 1);
-	if(ioctl(sd, SIOCGIFFLAGS, &ifr) == -1) {
-		perror("SIOCGIFFLAGS");
-		close(sd);
-		close(fd);
-		return -1;
-	}
-
-	// set up
-	memset(&ifw, 0, sizeof(ifw));
-	strncpy(ifw.ifr_name, if_name, IFNAMSIZ - 1);
-	ifw.ifr_flags = ifr.ifr_flags | IFF_UP | IFF_RUNNING;
-	if(ioctl(sd, SIOCSIFFLAGS, &ifw) == -1) {
-		perror("SIOCSIFFLAGS");
-		close(sd);
-		close(fd);
-		return -1;
-	}
-	close(sd);
-	 */
-
-	return fd;
-}
-
-
-static inline int min(int a, int b) {
-
-	return (a < b)? a : b;
-}
-
-
-static const unsigned int DEFAULT_MTU = 1500;
-static const unsigned short ether_type = 0xfed5; // current dtap ethertype
-
-int write_interface(int fd, unsigned char *data, unsigned int data_len,
-   unsigned char *ether_addr) {
-
-	unsigned char frame[DEFAULT_MTU]; // XXX buffer overflow?
-	struct ethhdr eh;
-
-	if(fd < 0)
-		return data_len;
-
-	memcpy(eh.h_dest, ether_addr, ETH_ALEN);
-	memcpy(eh.h_source, ether_addr, ETH_ALEN);
-	eh.h_proto = htons(ether_type);
-
-	memcpy(frame, &eh, sizeof(eh));
-	memcpy(frame + sizeof(eh), data,
-	   min(data_len, sizeof(frame) - sizeof(eh)));
-
-	if(write(fd, frame, sizeof(eh) + data_len) == -1) {
-		perror("write");
-		return -1;
-	}
-
-	return data_len;
-}
diff --git a/gsm-tvoid/src/lib/tun.h b/gsm-tvoid/src/lib/tun.h
deleted file mode 100644
index a7868c4..0000000
--- a/gsm-tvoid/src/lib/tun.h
+++ /dev/null
@@ -1,4 +0,0 @@
-// $Id: tun.h,v 1.1.1.1 2007-06-01 04:26:57 jl Exp $
-
-int mktun(const char *, unsigned char *);
-int write_interface(int, unsigned char *, unsigned int, unsigned char *);
-- 
cgit v1.2.3