summaryrefslogtreecommitdiff
path: root/gsm-receiver
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-11-07 15:43:05 +0100
committerHarald Welte <laforge@gnumonks.org>2010-11-07 15:43:05 +0100
commitaa2ed9259be0b40c53361e3df7e28d35c3f12e22 (patch)
tree86ccd61daa82bc28d8e06fedc254eaeda87b452e /gsm-receiver
parent3ac3890567168dacf833842cf483e3608c7a077c (diff)
remove legacy tun interface (we now have GSMTAP via UDP)
Thanks to Jakob Borg for indicating that this is no longer needed
Diffstat (limited to 'gsm-receiver')
-rw-r--r--gsm-receiver/src/lib/decoder/Makefile.am4
-rw-r--r--gsm-receiver/src/lib/decoder/gsmstack.h5
-rw-r--r--gsm-receiver/src/lib/decoder/tun.c125
-rw-r--r--gsm-receiver/src/lib/decoder/tun.h4
4 files changed, 2 insertions, 136 deletions
diff --git a/gsm-receiver/src/lib/decoder/Makefile.am b/gsm-receiver/src/lib/decoder/Makefile.am
index 2fcadbb..9582109 100644
--- a/gsm-receiver/src/lib/decoder/Makefile.am
+++ b/gsm-receiver/src/lib/decoder/Makefile.am
@@ -35,8 +35,7 @@ libdecoder_la_SOURCES = \
cch.c \
fire_crc.c \
gsmstack.c \
- interleave.c \
- tun.c
+ interleave.c
# tch.c \
# conv.c
@@ -46,7 +45,6 @@ noinst_HEADERS = \
fire_crc.h \
gsmstack.h \
interleave.h \
- tun.h \
system.h \
gsmtap.h \
a5-1-2.h
diff --git a/gsm-receiver/src/lib/decoder/gsmstack.h b/gsm-receiver/src/lib/decoder/gsmstack.h
index 5fceb45..67c7bbf 100644
--- a/gsm-receiver/src/lib/decoder/gsmstack.h
+++ b/gsm-receiver/src/lib/decoder/gsmstack.h
@@ -6,7 +6,7 @@
extern "C" {
#endif
-#include <linux/if_ether.h>
+//#include <linux/if_ether.h>
#include "interleave.h"
enum BURST_TYPE {
@@ -52,9 +52,6 @@ typedef struct
struct gs_ts_ctx ts_ctx[8];
- int tun_fd;
- unsigned char ether_addr[ETH_ALEN];
-
int gsmtap_fd;
} GS_CTX;
diff --git a/gsm-receiver/src/lib/decoder/tun.c b/gsm-receiver/src/lib/decoder/tun.c
deleted file mode 100644
index 2abda90..0000000
--- a/gsm-receiver/src/lib/decoder/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-receiver/src/lib/decoder/tun.h b/gsm-receiver/src/lib/decoder/tun.h
deleted file mode 100644
index a7868c4..0000000
--- a/gsm-receiver/src/lib/decoder/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 *);
personal git repositories of Harald Welte. Your mileage may vary