aboutsummaryrefslogtreecommitdiffstats
path: root/sgsnemu
diff options
context:
space:
mode:
authorjjako <jjako>2002-12-16 13:33:51 +0000
committerjjako <jjako>2002-12-16 13:33:51 +0000
commit52c2414f6cabefb0427475756e8ac4856180bc59 (patch)
tree5ecb31a74c392c36a7d7c802f18d37349973bf00 /sgsnemu
Initial revision
Diffstat (limited to 'sgsnemu')
-rw-r--r--sgsnemu/.deps/cmdline.P33
-rw-r--r--sgsnemu/.deps/pptpstuff.P107
-rw-r--r--sgsnemu/.deps/sgsnemu.P157
-rw-r--r--sgsnemu/.deps/sgsnemuopt.P33
-rw-r--r--sgsnemu/.deps/tun.P108
-rw-r--r--sgsnemu/Makefile343
-rw-r--r--sgsnemu/Makefile.am11
-rw-r--r--sgsnemu/Makefile.in343
-rw-r--r--sgsnemu/cmdline.c776
-rw-r--r--sgsnemu/cmdline.ggo37
-rw-r--r--sgsnemu/cmdline.h77
-rw-r--r--sgsnemu/ggsn_restart1
-rw-r--r--sgsnemu/sgsnemu.c754
-rw-r--r--sgsnemu/sgsnemu.pid1
-rw-r--r--sgsnemu/tun.c128
-rw-r--r--sgsnemu/tun.h48
16 files changed, 2957 insertions, 0 deletions
diff --git a/sgsnemu/.deps/cmdline.P b/sgsnemu/.deps/cmdline.P
new file mode 100644
index 0000000..f8c0fb9
--- /dev/null
+++ b/sgsnemu/.deps/cmdline.P
@@ -0,0 +1,33 @@
+cmdline.o: cmdline.c /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h \
+ /usr/include/bits/types.h /usr/include/libio.h /usr/include/_G_config.h \
+ /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stdarg.h \
+ /usr/include/bits/stdio_lim.h /usr/include/bits/stdio.h \
+ /usr/include/stdlib.h /usr/include/string.h /usr/include/bits/string.h \
+ /usr/include/bits/string2.h /usr/include/endian.h \
+ /usr/include/bits/endian.h /usr/include/getopt.h cmdline.h
+cmdline.c :
+/usr/include/stdio.h :
+/usr/include/features.h :
+/usr/include/sys/cdefs.h :
+/usr/include/gnu/stubs.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h :
+/usr/include/bits/types.h :
+/usr/include/libio.h :
+/usr/include/_G_config.h :
+/usr/include/wchar.h :
+/usr/include/bits/wchar.h :
+/usr/include/gconv.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stdarg.h :
+/usr/include/bits/stdio_lim.h :
+/usr/include/bits/stdio.h :
+/usr/include/stdlib.h :
+/usr/include/string.h :
+/usr/include/bits/string.h :
+/usr/include/bits/string2.h :
+/usr/include/endian.h :
+/usr/include/bits/endian.h :
+/usr/include/getopt.h :
+cmdline.h :
diff --git a/sgsnemu/.deps/pptpstuff.P b/sgsnemu/.deps/pptpstuff.P
new file mode 100644
index 0000000..4699f4f
--- /dev/null
+++ b/sgsnemu/.deps/pptpstuff.P
@@ -0,0 +1,107 @@
+pptpstuff.o: pptpstuff.c /usr/include/syslog.h /usr/include/sys/syslog.h \
+ /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/gnu/stubs.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stdarg.h \
+ /usr/include/ctype.h /usr/include/bits/types.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h \
+ /usr/include/endian.h /usr/include/bits/endian.h /usr/include/netdb.h \
+ /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/bits/wchar.h /usr/include/bits/wordsize.h \
+ /usr/include/bits/socket.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/limits.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/syslimits.h \
+ /usr/include/limits.h /usr/include/sys/types.h /usr/include/time.h \
+ /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \
+ /usr/include/asm/sockios.h /usr/include/bits/in.h \
+ /usr/include/bits/byteswap.h /usr/include/bits/netdb.h \
+ /usr/include/signal.h /usr/include/bits/sigset.h \
+ /usr/include/bits/signum.h /usr/include/stdio.h /usr/include/libio.h \
+ /usr/include/_G_config.h /usr/include/wchar.h /usr/include/gconv.h \
+ /usr/include/bits/stdio_lim.h /usr/include/bits/stdio.h \
+ /usr/include/string.h /usr/include/bits/string.h \
+ /usr/include/bits/string2.h /usr/include/stdlib.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/arpa/inet.h \
+ /usr/include/sys/wait.h /usr/include/sys/resource.h \
+ /usr/include/bits/resource.h /usr/include/bits/time.h \
+ /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
+ /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/unistd.h \
+ /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \
+ /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h \
+ /usr/include/asm/ioctls.h /usr/include/asm/ioctl.h \
+ /usr/include/bits/ioctl-types.h /usr/include/sys/ttydefaults.h \
+ /usr/include/net/if.h /usr/include/errno.h /usr/include/bits/errno.h \
+ /usr/include/linux/errno.h /usr/include/asm/errno.h \
+ /usr/include/asm/types.h /usr/include/linux/netlink.h pptpstuff.h
+pptpstuff.c :
+/usr/include/syslog.h :
+/usr/include/sys/syslog.h :
+/usr/include/features.h :
+/usr/include/sys/cdefs.h :
+/usr/include/gnu/stubs.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stdarg.h :
+/usr/include/ctype.h :
+/usr/include/bits/types.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h :
+/usr/include/endian.h :
+/usr/include/bits/endian.h :
+/usr/include/netdb.h :
+/usr/include/netinet/in.h :
+/usr/include/stdint.h :
+/usr/include/bits/wchar.h :
+/usr/include/bits/wordsize.h :
+/usr/include/bits/socket.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/limits.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/syslimits.h :
+/usr/include/limits.h :
+/usr/include/sys/types.h :
+/usr/include/time.h :
+/usr/include/bits/sockaddr.h :
+/usr/include/asm/socket.h :
+/usr/include/asm/sockios.h :
+/usr/include/bits/in.h :
+/usr/include/bits/byteswap.h :
+/usr/include/bits/netdb.h :
+/usr/include/signal.h :
+/usr/include/bits/sigset.h :
+/usr/include/bits/signum.h :
+/usr/include/stdio.h :
+/usr/include/libio.h :
+/usr/include/_G_config.h :
+/usr/include/wchar.h :
+/usr/include/gconv.h :
+/usr/include/bits/stdio_lim.h :
+/usr/include/bits/stdio.h :
+/usr/include/string.h :
+/usr/include/bits/string.h :
+/usr/include/bits/string2.h :
+/usr/include/stdlib.h :
+/usr/include/sys/socket.h :
+/usr/include/sys/uio.h :
+/usr/include/bits/uio.h :
+/usr/include/arpa/inet.h :
+/usr/include/sys/wait.h :
+/usr/include/sys/resource.h :
+/usr/include/bits/resource.h :
+/usr/include/bits/time.h :
+/usr/include/bits/waitflags.h :
+/usr/include/bits/waitstatus.h :
+/usr/include/sys/stat.h :
+/usr/include/bits/stat.h :
+/usr/include/unistd.h :
+/usr/include/bits/posix_opt.h :
+/usr/include/bits/confname.h :
+/usr/include/sys/ioctl.h :
+/usr/include/bits/ioctls.h :
+/usr/include/asm/ioctls.h :
+/usr/include/asm/ioctl.h :
+/usr/include/bits/ioctl-types.h :
+/usr/include/sys/ttydefaults.h :
+/usr/include/net/if.h :
+/usr/include/errno.h :
+/usr/include/bits/errno.h :
+/usr/include/linux/errno.h :
+/usr/include/asm/errno.h :
+/usr/include/asm/types.h :
+/usr/include/linux/netlink.h :
+pptpstuff.h :
diff --git a/sgsnemu/.deps/sgsnemu.P b/sgsnemu/.deps/sgsnemu.P
new file mode 100644
index 0000000..f96d1c6
--- /dev/null
+++ b/sgsnemu/.deps/sgsnemu.P
@@ -0,0 +1,157 @@
+sgsnemu.o: sgsnemu.c /usr/include/syslog.h /usr/include/sys/syslog.h \
+ /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/gnu/stubs.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stdarg.h \
+ /usr/include/ctype.h /usr/include/bits/types.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h \
+ /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \
+ /usr/include/endian.h /usr/include/bits/endian.h /usr/include/xlocale.h \
+ /usr/include/netdb.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/bits/wchar.h /usr/include/bits/wordsize.h \
+ /usr/include/bits/socket.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/limits.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/syslimits.h \
+ /usr/include/limits.h /usr/include/bits/posix1_lim.h \
+ /usr/include/bits/local_lim.h /usr/include/linux/limits.h \
+ /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \
+ /usr/include/bits/stdio_lim.h /usr/include/sys/types.h \
+ /usr/include/time.h /usr/include/sys/select.h \
+ /usr/include/bits/select.h /usr/include/bits/sigset.h \
+ /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+ /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \
+ /usr/include/asm/sockios.h /usr/include/bits/in.h \
+ /usr/include/bits/byteswap.h /usr/include/rpc/netdb.h \
+ /usr/include/bits/siginfo.h /usr/include/bits/netdb.h \
+ /usr/include/signal.h /usr/include/bits/signum.h \
+ /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \
+ /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \
+ /usr/include/ucontext.h /usr/include/sys/ucontext.h \
+ /usr/include/bits/sigthread.h /usr/include/stdio.h /usr/include/libio.h \
+ /usr/include/_G_config.h /usr/include/wchar.h /usr/include/gconv.h \
+ /usr/include/bits/stdio.h /usr/include/string.h \
+ /usr/include/bits/string.h /usr/include/bits/string2.h \
+ /usr/include/stdlib.h /usr/include/bits/waitflags.h \
+ /usr/include/bits/waitstatus.h /usr/include/alloca.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/arpa/inet.h \
+ /usr/include/sys/wait.h /usr/include/sys/resource.h \
+ /usr/include/bits/resource.h /usr/include/sys/stat.h \
+ /usr/include/bits/stat.h /usr/include/unistd.h \
+ /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \
+ /usr/include/bits/confname.h /usr/include/getopt.h \
+ /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h \
+ /usr/include/asm/ioctls.h /usr/include/asm/ioctl.h \
+ /usr/include/bits/ioctl-types.h /usr/include/sys/ttydefaults.h \
+ /usr/include/net/if.h /usr/include/errno.h /usr/include/bits/errno.h \
+ /usr/include/linux/errno.h /usr/include/asm/errno.h \
+ /usr/include/asm/types.h /usr/include/linux/netlink.h \
+ /usr/include/resolv.h /usr/include/sys/param.h \
+ /usr/include/linux/param.h /usr/include/asm/param.h \
+ /usr/include/sys/bitypes.h /usr/include/arpa/nameser.h \
+ /usr/include/arpa/nameser_compat.h tun.h ../gtp/pdp.h ../gtp/gtp.h \
+ cmdline.h
+sgsnemu.c :
+/usr/include/syslog.h :
+/usr/include/sys/syslog.h :
+/usr/include/features.h :
+/usr/include/sys/cdefs.h :
+/usr/include/gnu/stubs.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stdarg.h :
+/usr/include/ctype.h :
+/usr/include/bits/types.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h :
+/usr/include/bits/pthreadtypes.h :
+/usr/include/bits/sched.h :
+/usr/include/endian.h :
+/usr/include/bits/endian.h :
+/usr/include/xlocale.h :
+/usr/include/netdb.h :
+/usr/include/netinet/in.h :
+/usr/include/stdint.h :
+/usr/include/bits/wchar.h :
+/usr/include/bits/wordsize.h :
+/usr/include/bits/socket.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/limits.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/syslimits.h :
+/usr/include/limits.h :
+/usr/include/bits/posix1_lim.h :
+/usr/include/bits/local_lim.h :
+/usr/include/linux/limits.h :
+/usr/include/bits/posix2_lim.h :
+/usr/include/bits/xopen_lim.h :
+/usr/include/bits/stdio_lim.h :
+/usr/include/sys/types.h :
+/usr/include/time.h :
+/usr/include/sys/select.h :
+/usr/include/bits/select.h :
+/usr/include/bits/sigset.h :
+/usr/include/bits/time.h :
+/usr/include/sys/sysmacros.h :
+/usr/include/bits/sockaddr.h :
+/usr/include/asm/socket.h :
+/usr/include/asm/sockios.h :
+/usr/include/bits/in.h :
+/usr/include/bits/byteswap.h :
+/usr/include/rpc/netdb.h :
+/usr/include/bits/siginfo.h :
+/usr/include/bits/netdb.h :
+/usr/include/signal.h :
+/usr/include/bits/signum.h :
+/usr/include/bits/sigaction.h :
+/usr/include/bits/sigcontext.h :
+/usr/include/asm/sigcontext.h :
+/usr/include/bits/sigstack.h :
+/usr/include/ucontext.h :
+/usr/include/sys/ucontext.h :
+/usr/include/bits/sigthread.h :
+/usr/include/stdio.h :
+/usr/include/libio.h :
+/usr/include/_G_config.h :
+/usr/include/wchar.h :
+/usr/include/gconv.h :
+/usr/include/bits/stdio.h :
+/usr/include/string.h :
+/usr/include/bits/string.h :
+/usr/include/bits/string2.h :
+/usr/include/stdlib.h :
+/usr/include/bits/waitflags.h :
+/usr/include/bits/waitstatus.h :
+/usr/include/alloca.h :
+/usr/include/sys/socket.h :
+/usr/include/sys/uio.h :
+/usr/include/bits/uio.h :
+/usr/include/arpa/inet.h :
+/usr/include/sys/wait.h :
+/usr/include/sys/resource.h :
+/usr/include/bits/resource.h :
+/usr/include/sys/stat.h :
+/usr/include/bits/stat.h :
+/usr/include/unistd.h :
+/usr/include/bits/posix_opt.h :
+/usr/include/bits/environments.h :
+/usr/include/bits/confname.h :
+/usr/include/getopt.h :
+/usr/include/sys/ioctl.h :
+/usr/include/bits/ioctls.h :
+/usr/include/asm/ioctls.h :
+/usr/include/asm/ioctl.h :
+/usr/include/bits/ioctl-types.h :
+/usr/include/sys/ttydefaults.h :
+/usr/include/net/if.h :
+/usr/include/errno.h :
+/usr/include/bits/errno.h :
+/usr/include/linux/errno.h :
+/usr/include/asm/errno.h :
+/usr/include/asm/types.h :
+/usr/include/linux/netlink.h :
+/usr/include/resolv.h :
+/usr/include/sys/param.h :
+/usr/include/linux/param.h :
+/usr/include/asm/param.h :
+/usr/include/sys/bitypes.h :
+/usr/include/arpa/nameser.h :
+/usr/include/arpa/nameser_compat.h :
+tun.h :
+../gtp/pdp.h :
+../gtp/gtp.h :
+cmdline.h :
diff --git a/sgsnemu/.deps/sgsnemuopt.P b/sgsnemu/.deps/sgsnemuopt.P
new file mode 100644
index 0000000..233a15f
--- /dev/null
+++ b/sgsnemu/.deps/sgsnemuopt.P
@@ -0,0 +1,33 @@
+sgsnemuopt.o: sgsnemuopt.c /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h \
+ /usr/include/bits/types.h /usr/include/libio.h /usr/include/_G_config.h \
+ /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stdarg.h \
+ /usr/include/bits/stdio_lim.h /usr/include/bits/stdio.h \
+ /usr/include/stdlib.h /usr/include/string.h /usr/include/bits/string.h \
+ /usr/include/bits/string2.h /usr/include/endian.h \
+ /usr/include/bits/endian.h /usr/include/getopt.h sgsnemuopt.h
+sgsnemuopt.c :
+/usr/include/stdio.h :
+/usr/include/features.h :
+/usr/include/sys/cdefs.h :
+/usr/include/gnu/stubs.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h :
+/usr/include/bits/types.h :
+/usr/include/libio.h :
+/usr/include/_G_config.h :
+/usr/include/wchar.h :
+/usr/include/bits/wchar.h :
+/usr/include/gconv.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stdarg.h :
+/usr/include/bits/stdio_lim.h :
+/usr/include/bits/stdio.h :
+/usr/include/stdlib.h :
+/usr/include/string.h :
+/usr/include/bits/string.h :
+/usr/include/bits/string2.h :
+/usr/include/endian.h :
+/usr/include/bits/endian.h :
+/usr/include/getopt.h :
+sgsnemuopt.h :
diff --git a/sgsnemu/.deps/tun.P b/sgsnemu/.deps/tun.P
new file mode 100644
index 0000000..29f9cf4
--- /dev/null
+++ b/sgsnemu/.deps/tun.P
@@ -0,0 +1,108 @@
+tun.o: tun.c /usr/include/syslog.h /usr/include/sys/syslog.h \
+ /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/gnu/stubs.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stdarg.h \
+ /usr/include/stdio.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h \
+ /usr/include/bits/types.h /usr/include/libio.h /usr/include/_G_config.h \
+ /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \
+ /usr/include/bits/stdio_lim.h /usr/include/bits/stdio.h \
+ /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/limits.h \
+ /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/syslimits.h \
+ /usr/include/limits.h /usr/include/bits/sockaddr.h \
+ /usr/include/asm/socket.h /usr/include/asm/sockios.h \
+ /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/bits/wordsize.h /usr/include/bits/in.h \
+ /usr/include/endian.h /usr/include/bits/endian.h \
+ /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \
+ /usr/include/sys/stat.h /usr/include/bits/stat.h \
+ /usr/include/sys/time.h /usr/include/bits/time.h \
+ /usr/include/sys/select.h /usr/include/bits/select.h \
+ /usr/include/bits/sigset.h /usr/include/unistd.h \
+ /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \
+ /usr/include/string.h /usr/include/bits/string.h \
+ /usr/include/bits/string2.h /usr/include/errno.h \
+ /usr/include/bits/errno.h /usr/include/linux/errno.h \
+ /usr/include/asm/errno.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \
+ /usr/include/sys/ioctl.h /usr/include/bits/ioctls.h \
+ /usr/include/asm/ioctls.h /usr/include/asm/ioctl.h \
+ /usr/include/bits/ioctl-types.h /usr/include/sys/ttydefaults.h \
+ /usr/include/linux/if.h /usr/include/linux/types.h \
+ /usr/include/linux/posix_types.h /usr/include/linux/stddef.h \
+ /usr/include/asm/posix_types.h /usr/include/asm/types.h \
+ /usr/include/linux/socket.h /usr/include/linux/if_tun.h tun.h
+tun.c :
+/usr/include/syslog.h :
+/usr/include/sys/syslog.h :
+/usr/include/features.h :
+/usr/include/sys/cdefs.h :
+/usr/include/gnu/stubs.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stdarg.h :
+/usr/include/stdio.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h :
+/usr/include/bits/types.h :
+/usr/include/libio.h :
+/usr/include/_G_config.h :
+/usr/include/wchar.h :
+/usr/include/bits/wchar.h :
+/usr/include/gconv.h :
+/usr/include/bits/stdio_lim.h :
+/usr/include/bits/stdio.h :
+/usr/include/stdlib.h :
+/usr/include/sys/types.h :
+/usr/include/time.h :
+/usr/include/sys/socket.h :
+/usr/include/sys/uio.h :
+/usr/include/bits/uio.h :
+/usr/include/bits/socket.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/limits.h :
+/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/syslimits.h :
+/usr/include/limits.h :
+/usr/include/bits/sockaddr.h :
+/usr/include/asm/socket.h :
+/usr/include/asm/sockios.h :
+/usr/include/netinet/in.h :
+/usr/include/stdint.h :
+/usr/include/bits/wordsize.h :
+/usr/include/bits/in.h :
+/usr/include/endian.h :
+/usr/include/bits/endian.h :
+/usr/include/bits/byteswap.h :
+/usr/include/arpa/inet.h :
+/usr/include/sys/stat.h :
+/usr/include/bits/stat.h :
+/usr/include/sys/time.h :
+/usr/include/bits/time.h :
+/usr/include/sys/select.h :
+/usr/include/bits/select.h :
+/usr/include/bits/sigset.h :
+/usr/include/unistd.h :
+/usr/include/bits/posix_opt.h :
+/usr/include/bits/confname.h :
+/usr/include/string.h :
+/usr/include/bits/string.h :
+/usr/include/bits/string2.h :
+/usr/include/errno.h :
+/usr/include/bits/errno.h :
+/usr/include/linux/errno.h :
+/usr/include/asm/errno.h :
+/usr/include/fcntl.h :
+/usr/include/bits/fcntl.h :
+/usr/include/sys/ioctl.h :
+/usr/include/bits/ioctls.h :
+/usr/include/asm/ioctls.h :
+/usr/include/asm/ioctl.h :
+/usr/include/bits/ioctl-types.h :
+/usr/include/sys/ttydefaults.h :
+/usr/include/linux/if.h :
+/usr/include/linux/types.h :
+/usr/include/linux/posix_types.h :
+/usr/include/linux/stddef.h :
+/usr/include/asm/posix_types.h :
+/usr/include/asm/types.h :
+/usr/include/linux/socket.h :
+/usr/include/linux/if_tun.h :
+tun.h :
diff --git a/sgsnemu/Makefile b/sgsnemu/Makefile
new file mode 100644
index 0000000..24a2b1c
--- /dev/null
+++ b/sgsnemu/Makefile
@@ -0,0 +1,343 @@
+# Generated automatically from Makefile.in by configure.
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = /bin/sh
+
+srcdir = .
+top_srcdir = ..
+prefix = /usr/local
+exec_prefix = ${prefix}
+
+bindir = ${exec_prefix}/bin
+sbindir = ${exec_prefix}/sbin
+libexecdir = ${exec_prefix}/libexec
+datadir = ${prefix}/share
+sysconfdir = ${prefix}/etc
+sharedstatedir = ${prefix}/com
+localstatedir = ${prefix}/var
+libdir = ${exec_prefix}/lib
+infodir = ${prefix}/info
+mandir = ${prefix}/man
+includedir = ${prefix}/include
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/OpenGGSN
+pkglibdir = $(libdir)/OpenGGSN
+pkgincludedir = $(includedir)/OpenGGSN
+
+top_builddir = ..
+
+ACLOCAL = aclocal
+AUTOCONF = autoconf
+AUTOMAKE = automake
+AUTOHEADER = autoheader
+
+INSTALL = /usr/bin/install -c
+INSTALL_PROGRAM = ${INSTALL} $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_SCRIPT = ${INSTALL_PROGRAM}
+transform = s,x,x,
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_alias = i686-pc-linux
+host_triplet = i686-pc-linux-gnu
+AS = @AS@
+AWK = gawk
+CC = gcc
+DLLTOOL = @DLLTOOL@
+LIBTOOL = $(SHELL) $(top_builddir)/libtool
+LN_S = ln -s
+MAKEINFO = makeinfo
+OBJDUMP = @OBJDUMP@
+PACKAGE = OpenGGSN
+RANLIB = ranlib
+VERSION = 0.5
+
+bin_PROGRAMS = sgsnemu
+
+CFLAGS = -O2 -fno-builtin -Wall -ansi -DSBINDIR='"$(sbindir)"' -lgtp
+
+sgsnemu_SOURCES = sgsnemu.c tun.c tun.h cmdline.c cmdline.h
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_CLEAN_FILES =
+PROGRAMS = $(bin_PROGRAMS)
+
+
+DEFS = -DSTDC_HEADERS=1 -DHAVE_SYS_WAIT_H=1 -DHAVE_FCNTL_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_IOCTL_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYSLOG_H=1 -DHAVE_UNISTD_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_SELECT=1 -DHAVE_SOCKET=1 -DHAVE_STRDUP=1 -DHAVE_STRERROR=1 -DHAVE_STRTOUL=1 -DPACKAGE=\"OpenGGSN\" -DVERSION=\"0.5\" -I. -I$(srcdir)
+CPPFLAGS =
+LDFLAGS =
+LIBS =
+sgsnemu_OBJECTS = sgsnemu.o tun.o cmdline.o
+sgsnemu_LDADD = $(LDADD)
+sgsnemu_DEPENDENCIES =
+sgsnemu_LDFLAGS =
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+DIST_COMMON = Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = gtar
+GZIP_ENV = --best
+DEP_FILES = .deps/cmdline.P .deps/sgsnemu.P .deps/tun.P
+SOURCES = $(sgsnemu_SOURCES)
+OBJECTS = $(sgsnemu_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .lo .o .s
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --gnu sgsnemu/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-binPROGRAMS:
+
+clean-binPROGRAMS:
+ -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+
+distclean-binPROGRAMS:
+
+maintainer-clean-binPROGRAMS:
+
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
+ $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ list='$(bin_PROGRAMS)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ done
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+.s.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.S.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+
+maintainer-clean-libtool:
+
+sgsnemu: $(sgsnemu_OBJECTS) $(sgsnemu_DEPENDENCIES)
+ @rm -f sgsnemu
+ $(LINK) $(sgsnemu_LDFLAGS) $(sgsnemu_OBJECTS) $(sgsnemu_LDADD) $(LIBS)
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = sgsnemu
+
+distdir: $(DISTFILES)
+ here=`cd $(top_builddir) && pwd`; \
+ top_distdir=`cd $(top_distdir) && pwd`; \
+ distdir=`cd $(distdir) && pwd`; \
+ cd $(top_srcdir) \
+ && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu sgsnemu/Makefile
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$d/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+
+DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
+
+-include $(DEP_FILES)
+
+mostlyclean-depend:
+
+clean-depend:
+
+distclean-depend:
+ -rm -rf .deps
+
+maintainer-clean-depend:
+
+%.o: %.c
+ @echo '$(COMPILE) -c $<'; \
+ $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-cp .deps/$(*F).pp .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm .deps/$(*F).pp
+
+%.lo: %.c
+ @echo '$(LTCOMPILE) -c $<'; \
+ $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
+ < .deps/$(*F).pp > .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm -f .deps/$(*F).pp
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am: install-binPROGRAMS
+install-exec: install-exec-am
+
+install-data-am:
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am: uninstall-binPROGRAMS
+uninstall: uninstall-am
+all-am: Makefile $(PROGRAMS)
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \
+ mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
+ mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-binPROGRAMS clean-compile clean-libtool clean-tags \
+ clean-depend clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-binPROGRAMS distclean-compile distclean-libtool \
+ distclean-tags distclean-depend distclean-generic \
+ clean-am
+ -rm -f libtool
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-binPROGRAMS \
+ maintainer-clean-compile maintainer-clean-libtool \
+ maintainer-clean-tags maintainer-clean-depend \
+ maintainer-clean-generic distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
+maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile mostlyclean-libtool distclean-libtool \
+clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
+distclean-tags clean-tags maintainer-clean-tags distdir \
+mostlyclean-depend distclean-depend clean-depend \
+maintainer-clean-depend info-am info dvi-am dvi check check-am \
+installcheck-am installcheck install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
+
+
+cmdline.c: cmdline.ggo
+ gengetopt < cmdline.ggo --unamed-opts --conf-parser
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/sgsnemu/Makefile.am b/sgsnemu/Makefile.am
new file mode 100644
index 0000000..064f91f
--- /dev/null
+++ b/sgsnemu/Makefile.am
@@ -0,0 +1,11 @@
+bin_PROGRAMS = sgsnemu
+
+CFLAGS = -O2 -fno-builtin -Wall -ansi -DSBINDIR='"$(sbindir)"' -lgtp
+
+sgsnemu_SOURCES = sgsnemu.c tun.c tun.h cmdline.c cmdline.h
+
+cmdline.c: cmdline.ggo
+ gengetopt < cmdline.ggo --unamed-opts --conf-parser
+
+
+
diff --git a/sgsnemu/Makefile.in b/sgsnemu/Makefile.in
new file mode 100644
index 0000000..b99ad73
--- /dev/null
+++ b/sgsnemu/Makefile.in
@@ -0,0 +1,343 @@
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_alias = @host_alias@
+host_triplet = @host@
+AS = @AS@
+AWK = @AWK@
+CC = @CC@
+DLLTOOL = @DLLTOOL@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+MAKEINFO = @MAKEINFO@
+OBJDUMP = @OBJDUMP@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+VERSION = @VERSION@
+
+bin_PROGRAMS = sgsnemu
+
+CFLAGS = -O2 -fno-builtin -Wall -ansi -DSBINDIR='"$(sbindir)"' -lgtp
+
+sgsnemu_SOURCES = sgsnemu.c tun.c tun.h cmdline.c cmdline.h
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_CLEAN_FILES =
+PROGRAMS = $(bin_PROGRAMS)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir)
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+sgsnemu_OBJECTS = sgsnemu.o tun.o cmdline.o
+sgsnemu_LDADD = $(LDADD)
+sgsnemu_DEPENDENCIES =
+sgsnemu_LDFLAGS =
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+DIST_COMMON = Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = gtar
+GZIP_ENV = --best
+DEP_FILES = .deps/cmdline.P .deps/sgsnemu.P .deps/tun.P
+SOURCES = $(sgsnemu_SOURCES)
+OBJECTS = $(sgsnemu_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .lo .o .s
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --gnu sgsnemu/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-binPROGRAMS:
+
+clean-binPROGRAMS:
+ -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+
+distclean-binPROGRAMS:
+
+maintainer-clean-binPROGRAMS:
+
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
+ $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ list='$(bin_PROGRAMS)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ done
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+.s.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+.S.lo:
+ $(LIBTOOL) --mode=compile $(COMPILE) -c $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+
+maintainer-clean-libtool:
+
+sgsnemu: $(sgsnemu_OBJECTS) $(sgsnemu_DEPENDENCIES)
+ @rm -f sgsnemu
+ $(LINK) $(sgsnemu_LDFLAGS) $(sgsnemu_OBJECTS) $(sgsnemu_LDADD) $(LIBS)
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ here=`pwd` && cd $(srcdir) \
+ && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = sgsnemu
+
+distdir: $(DISTFILES)
+ here=`cd $(top_builddir) && pwd`; \
+ top_distdir=`cd $(top_distdir) && pwd`; \
+ distdir=`cd $(distdir) && pwd`; \
+ cd $(top_srcdir) \
+ && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu sgsnemu/Makefile
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$d/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+
+DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
+
+-include $(DEP_FILES)
+
+mostlyclean-depend:
+
+clean-depend:
+
+distclean-depend:
+ -rm -rf .deps
+
+maintainer-clean-depend:
+
+%.o: %.c
+ @echo '$(COMPILE) -c $<'; \
+ $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-cp .deps/$(*F).pp .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm .deps/$(*F).pp
+
+%.lo: %.c
+ @echo '$(LTCOMPILE) -c $<'; \
+ $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
+ < .deps/$(*F).pp > .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm -f .deps/$(*F).pp
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am: install-binPROGRAMS
+install-exec: install-exec-am
+
+install-data-am:
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am: uninstall-binPROGRAMS
+uninstall: uninstall-am
+all-am: Makefile $(PROGRAMS)
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \
+ mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
+ mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-binPROGRAMS clean-compile clean-libtool clean-tags \
+ clean-depend clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-binPROGRAMS distclean-compile distclean-libtool \
+ distclean-tags distclean-depend distclean-generic \
+ clean-am
+ -rm -f libtool
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-binPROGRAMS \
+ maintainer-clean-compile maintainer-clean-libtool \
+ maintainer-clean-tags maintainer-clean-depend \
+ maintainer-clean-generic distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
+maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile mostlyclean-libtool distclean-libtool \
+clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
+distclean-tags clean-tags maintainer-clean-tags distdir \
+mostlyclean-depend distclean-depend clean-depend \
+maintainer-clean-depend info-am info dvi-am dvi check check-am \
+installcheck-am installcheck install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
+
+
+cmdline.c: cmdline.ggo
+ gengetopt < cmdline.ggo --unamed-opts --conf-parser
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/sgsnemu/cmdline.c b/sgsnemu/cmdline.c
new file mode 100644
index 0000000..ede48bf
--- /dev/null
+++ b/sgsnemu/cmdline.c
@@ -0,0 +1,776 @@
+/*
+ File autogenerated by gengetopt version 2.8rc
+ generated with the following command:
+ ../../gengetopt-2.8rc/src/gengetopt --conf-parser
+
+ The developers of gengetopt consider the fixed text that goes in all
+ gengetopt output files to be in the public domain:
+ we make no copyright claims on it.
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+/* If we use autoconf. */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+/* Check for configure's getopt check result. */
+#ifndef HAVE_GETOPT_LONG
+#include "getopt.h"
+#else
+#include <getopt.h>
+#endif
+
+#ifndef HAVE_STRDUP
+#define strdup gengetopt_strdup
+#endif /* HAVE_STRDUP */
+
+#include "cmdline.h"
+
+
+void
+cmdline_parser_print_version (void)
+{
+ printf ("%s %s\n", PACKAGE, VERSION);
+}
+
+void
+cmdline_parser_print_help (void)
+{
+ cmdline_parser_print_version ();
+ printf("\n"
+ "Usage: %s [OPTIONS]...\n", PACKAGE);
+ printf(" -h --help Print help and exit\n");
+ printf(" -V --version Print version and exit\n");
+ printf(" -f --fg Run in foreground (default=off)\n");
+ printf(" -d --debug Run in debug mode (default=off)\n");
+ printf(" -cSTRING --conf=STRING Read configuration file\n");
+ printf(" --pidfile=STRING Filename of process id file (default='./sgsnemu.pid')\n");
+ printf(" --statedir=STRING Directory of nonvolatile data (default='./')\n");
+ printf(" --dns=STRING DNS Server to use\n");
+ printf(" -lSTRING --listen=STRING Local interface\n");
+ printf(" -rSTRING --remote=STRING Remote host\n");
+ printf(" -nSTRING --net=STRING Network (default='192.168.0.0')\n");
+ printf(" --mask=STRING Network mask (default='255.255.255.0')\n");
+ printf(" --contexts=INT Number of contexts (default='1')\n");
+ printf(" --static Allocate static tun ifterface (default=off)\n");
+ printf(" --timelimit=INT Exit after timelimit seconds (default='0')\n");
+ printf(" -aSTRING --apn=STRING Access point name (default='internet')\n");
+ printf(" -iSTRING --imsi=STRING IMSI (default='240010123456789')\n");
+ printf(" -mSTRING --msisdn=STRING Mobile Station ISDN number (default='46702123456')\n");
+ printf(" -qINT --qos=INT Requested quality of service (default='0x0b921f')\n");
+ printf(" -uSTRING --uid=STRING Login user ID (default='mig')\n");
+ printf(" -pSTRING --pwd=STRING Login password (default='hemmelig')\n");
+}
+
+
+#ifndef HAVE_STRDUP
+/* gengetopt_strdup(): automatically generated from strdup.c. */
+/* strdup.c replacement of strdup, which is not standard */
+static char *
+gengetopt_strdup (const char *s)
+{
+ char *result = (char*)malloc(strlen(s) + 1);
+ if (result == (char*)0)
+ return (char*)0;
+ strcpy(result, s);
+ return result;
+}
+#endif /* HAVE_STRDUP */
+
+int
+cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
+{
+ int c; /* Character of the parsed option. */
+ int missing_required_options = 0;
+
+ args_info->help_given = 0 ;
+ args_info->version_given = 0 ;
+ args_info->fg_given = 0 ;
+ args_info->debug_given = 0 ;
+ args_info->conf_given = 0 ;
+ args_info->pidfile_given = 0 ;
+ args_info->statedir_given = 0 ;
+ args_info->dns_given = 0 ;
+ args_info->listen_given = 0 ;
+ args_info->remote_given = 0 ;
+ args_info->net_given = 0 ;
+ args_info->mask_given = 0 ;
+ args_info->contexts_given = 0 ;
+ args_info->static_given = 0 ;
+ args_info->timelimit_given = 0 ;
+ args_info->apn_given = 0 ;
+ args_info->imsi_given = 0 ;
+ args_info->msisdn_given = 0 ;
+ args_info->qos_given = 0 ;
+ args_info->uid_given = 0 ;
+ args_info->pwd_given = 0 ;
+#define clear_args() { \
+ args_info->fg_flag = 0;\
+ args_info->debug_flag = 0;\
+ args_info->conf_arg = NULL; \
+ args_info->pidfile_arg = strdup("./sgsnemu.pid") ;\
+ args_info->statedir_arg = strdup("./") ;\
+ args_info->dns_arg = NULL; \
+ args_info->listen_arg = NULL; \
+ args_info->remote_arg = NULL; \
+ args_info->net_arg = strdup("192.168.0.0") ;\
+ args_info->mask_arg = strdup("255.255.255.0") ;\
+ args_info->contexts_arg = 1 ;\
+ args_info->static_flag = 0;\
+ args_info->timelimit_arg = 0 ;\
+ args_info->apn_arg = strdup("internet") ;\
+ args_info->imsi_arg = strdup("240010123456789") ;\
+ args_info->msisdn_arg = strdup("46702123456") ;\
+ args_info->qos_arg = 0x0b921f ;\
+ args_info->uid_arg = strdup("mig") ;\
+ args_info->pwd_arg = strdup("hemmelig") ;\
+}
+
+ clear_args();
+
+ optarg = 0;
+ optind = 1;
+ opterr = 1;
+ optopt = '?';
+
+ while (1)
+ {
+ int option_index = 0;
+ char *stop_char;
+ static struct option long_options[] = {
+ { "help", 0, NULL, 'h' },
+ { "version", 0, NULL, 'V' },
+ { "fg", 0, NULL, 'f' },
+ { "debug", 0, NULL, 'd' },
+ { "conf", 1, NULL, 'c' },
+ { "pidfile", 1, NULL, 0 },
+ { "statedir", 1, NULL, 0 },
+ { "dns", 1, NULL, 0 },
+ { "listen", 1, NULL, 'l' },
+ { "remote", 1, NULL, 'r' },
+ { "net", 1, NULL, 'n' },
+ { "mask", 1, NULL, 0 },
+ { "contexts", 1, NULL, 0 },
+ { "static", 0, NULL, 0 },
+ { "timelimit", 1, NULL, 0 },
+ { "apn", 1, NULL, 'a' },
+ { "imsi", 1, NULL, 'i' },
+ { "msisdn", 1, NULL, 'm' },
+ { "qos", 1, NULL, 'q' },
+ { "uid", 1, NULL, 'u' },
+ { "pwd", 1, NULL, 'p' },
+ { NULL, 0, NULL, 0 }
+ };
+
+ c = getopt_long (argc, argv, "hVfdc:l:r:n:a:i:m:q:u:p:", long_options, &option_index);
+
+ if (c == -1) break; /* Exit from `while (1)' loop. */
+
+ switch (c)
+ {
+ case 'h': /* Print help and exit. */
+ clear_args ();
+ cmdline_parser_print_help ();
+ exit (EXIT_SUCCESS);
+
+ case 'V': /* Print version and exit. */
+ clear_args ();
+ cmdline_parser_print_version ();
+ exit (EXIT_SUCCESS);
+
+ case 'f': /* Run in foreground. */
+ if (args_info->fg_given)
+ {
+ fprintf (stderr, "%s: `--fg' (`-f') option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->fg_given = 1;
+ args_info->fg_flag = !(args_info->fg_flag);
+ break;
+
+ case 'd': /* Run in debug mode. */
+ if (args_info->debug_given)
+ {
+ fprintf (stderr, "%s: `--debug' (`-d') option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->debug_given = 1;
+ args_info->debug_flag = !(args_info->debug_flag);
+ break;
+
+ case 'c': /* Read configuration file. */
+ if (args_info->conf_given)
+ {
+ fprintf (stderr, "%s: `--conf' (`-c') option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->conf_given = 1;
+ args_info->conf_arg = strdup (optarg);
+ break;
+
+ case 'l': /* Local interface. */
+ if (args_info->listen_given)
+ {
+ fprintf (stderr, "%s: `--listen' (`-l') option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->listen_given = 1;
+ args_info->listen_arg = strdup (optarg);
+ break;
+
+ case 'r': /* Remote host. */
+ if (args_info->remote_given)
+ {
+ fprintf (stderr, "%s: `--remote' (`-r') option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->remote_given = 1;
+ args_info->remote_arg = strdup (optarg);
+ break;
+
+ case 'n': /* Network. */
+ if (args_info->net_given)
+ {
+ fprintf (stderr, "%s: `--net' (`-n') option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->net_given = 1;
+ args_info->net_arg = strdup (optarg);
+ break;
+
+ case 'a': /* Access point name. */
+ if (args_info->apn_given)
+ {
+ fprintf (stderr, "%s: `--apn' (`-a') option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->apn_given = 1;
+ args_info->apn_arg = strdup (optarg);
+ break;
+
+ case 'i': /* IMSI. */
+ if (args_info->imsi_given)
+ {
+ fprintf (stderr, "%s: `--imsi' (`-i') option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->imsi_given = 1;
+ args_info->imsi_arg = strdup (optarg);
+ break;
+
+ case 'm': /* Mobile Station ISDN number. */
+ if (args_info->msisdn_given)
+ {
+ fprintf (stderr, "%s: `--msisdn' (`-m') option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->msisdn_given = 1;
+ args_info->msisdn_arg = strdup (optarg);
+ break;
+
+ case 'q': /* Requested quality of service. */
+ if (args_info->qos_given)
+ {
+ fprintf (stderr, "%s: `--qos' (`-q') option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->qos_given = 1;
+ args_info->qos_arg = strtol (optarg,&stop_char,0);
+ break;
+
+ case 'u': /* Login user ID. */
+ if (args_info->uid_given)
+ {
+ fprintf (stderr, "%s: `--uid' (`-u') option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->uid_given = 1;
+ args_info->uid_arg = strdup (optarg);
+ break;
+
+ case 'p': /* Login password. */
+ if (args_info->pwd_given)
+ {
+ fprintf (stderr, "%s: `--pwd' (`-p') option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->pwd_given = 1;
+ args_info->pwd_arg = strdup (optarg);
+ break;
+
+
+ case 0: /* Long option with no short option */
+ /* Filename of process id file. */
+ if (strcmp (long_options[option_index].name, "pidfile") == 0)
+ {
+ if (args_info->pidfile_given)
+ {
+ fprintf (stderr, "%s: `--pidfile' option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->pidfile_given = 1;
+ args_info->pidfile_arg = strdup (optarg);
+ break;
+ }
+ /* Directory of nonvolatile data. */
+ else if (strcmp (long_options[option_index].name, "statedir") == 0)
+ {
+ if (args_info->statedir_given)
+ {
+ fprintf (stderr, "%s: `--statedir' option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->statedir_given = 1;
+ args_info->statedir_arg = strdup (optarg);
+ break;
+ }
+ /* DNS Server to use. */
+ else if (strcmp (long_options[option_index].name, "dns") == 0)
+ {
+ if (args_info->dns_given)
+ {
+ fprintf (stderr, "%s: `--dns' option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->dns_given = 1;
+ args_info->dns_arg = strdup (optarg);
+ break;
+ }
+ /* Network mask. */
+ else if (strcmp (long_options[option_index].name, "mask") == 0)
+ {
+ if (args_info->mask_given)
+ {
+ fprintf (stderr, "%s: `--mask' option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->mask_given = 1;
+ args_info->mask_arg = strdup (optarg);
+ break;
+ }
+ /* Number of contexts. */
+ else if (strcmp (long_options[option_index].name, "contexts") == 0)
+ {
+ if (args_info->contexts_given)
+ {
+ fprintf (stderr, "%s: `--contexts' option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->contexts_given = 1;
+ args_info->contexts_arg = strtol (optarg,&stop_char,0);
+ break;
+ }
+ /* Allocate static tun ifterface. */
+ else if (strcmp (long_options[option_index].name, "static") == 0)
+ {
+ if (args_info->static_given)
+ {
+ fprintf (stderr, "%s: `--static' option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->static_given = 1;
+ args_info->static_flag = !(args_info->static_flag);
+ break;
+ }
+ /* Exit after timelimit seconds. */
+ else if (strcmp (long_options[option_index].name, "timelimit") == 0)
+ {
+ if (args_info->timelimit_given)
+ {
+ fprintf (stderr, "%s: `--timelimit' option given more than once\n", PACKAGE);
+ clear_args ();
+ exit (EXIT_FAILURE);
+ }
+ args_info->timelimit_given = 1;
+ args_info->timelimit_arg = strtol (optarg,&stop_char,0);
+ break;
+ }
+
+ case '?': /* Invalid option. */
+ /* `getopt_long' already printed an error message. */
+ exit (EXIT_FAILURE);
+
+ default: /* bug: option not considered. */
+ fprintf (stderr, "%s: option unknown: %c\n", PACKAGE, c);
+ abort ();
+ } /* switch */
+ } /* while */
+
+
+ if ( missing_required_options )
+ exit (EXIT_FAILURE);
+
+ return 0;
+}
+
+#define CONFIGPARSERBUFSIZE 1024
+
+int
+cmdline_parser_configfile (char * const filename, struct gengetopt_args_info *args_info, int override)
+{
+ FILE* file;
+ char linebuf[CONFIGPARSERBUFSIZE];
+ int line_num = 0;
+ int len;
+ int fnum;
+ char fopt[CONFIGPARSERBUFSIZE], farg[CONFIGPARSERBUFSIZE];
+ char *stop_char;
+
+ if ((file = fopen(filename, "r")) == NULL)
+ {
+ fprintf (stderr, "%s: Error opening configuration file '%s'\n",
+ PACKAGE, filename);
+ exit (EXIT_FAILURE);
+ }
+
+ while ((fgets(linebuf, CONFIGPARSERBUFSIZE, file)) != NULL)
+ {
+ ++line_num;
+ len = strlen(linebuf);
+ if (len == CONFIGPARSERBUFSIZE-1)
+ {
+ fprintf (stderr, "%s: Line longer than %d characters found in configuration file '%s'\n",
+ PACKAGE, CONFIGPARSERBUFSIZE, filename);
+ exit (EXIT_FAILURE);
+ }
+
+ if (linebuf[0] == '#')
+ continue; /* Line was a comment */
+
+ /* Get the option */
+ if ((fnum = sscanf(linebuf, "%s %s", fopt, farg)) > 0)
+ {
+ if (!strcmp(fopt, "help"))
+ {
+ if (override || !args_info->help_given)
+ {
+ args_info->help_given = 1;
+
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "version"))
+ {
+ if (override || !args_info->version_given)
+ {
+ args_info->version_given = 1;
+
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "fg"))
+ {
+ if (override || !args_info->fg_given)
+ {
+ args_info->fg_given = 1;
+ args_info->fg_flag = !(args_info->fg_flag);
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "debug"))
+ {
+ if (override || !args_info->debug_given)
+ {
+ args_info->debug_given = 1;
+ args_info->debug_flag = !(args_info->debug_flag);
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "conf"))
+ {
+ if (override || !args_info->conf_given)
+ {
+ args_info->conf_given = 1;
+ if (fnum == 2)
+ args_info->conf_arg = strdup (farg);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "pidfile"))
+ {
+ if (override || !args_info->pidfile_given)
+ {
+ args_info->pidfile_given = 1;
+ if (fnum == 2)
+ args_info->pidfile_arg = strdup (farg);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "statedir"))
+ {
+ if (override || !args_info->statedir_given)
+ {
+ args_info->statedir_given = 1;
+ if (fnum == 2)
+ args_info->statedir_arg = strdup (farg);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "dns"))
+ {
+ if (override || !args_info->dns_given)
+ {
+ args_info->dns_given = 1;
+ if (fnum == 2)
+ args_info->dns_arg = strdup (farg);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "listen"))
+ {
+ if (override || !args_info->listen_given)
+ {
+ args_info->listen_given = 1;
+ if (fnum == 2)
+ args_info->listen_arg = strdup (farg);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "remote"))
+ {
+ if (override || !args_info->remote_given)
+ {
+ args_info->remote_given = 1;
+ if (fnum == 2)
+ args_info->remote_arg = strdup (farg);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "net"))
+ {
+ if (override || !args_info->net_given)
+ {
+ args_info->net_given = 1;
+ if (fnum == 2)
+ args_info->net_arg = strdup (farg);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "mask"))
+ {
+ if (override || !args_info->mask_given)
+ {
+ args_info->mask_given = 1;
+ if (fnum == 2)
+ args_info->mask_arg = strdup (farg);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "contexts"))
+ {
+ if (override || !args_info->contexts_given)
+ {
+ args_info->contexts_given = 1;
+ if (fnum == 2)
+ args_info->contexts_arg = strtol (farg,&stop_char,0);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "static"))
+ {
+ if (override || !args_info->static_given)
+ {
+ args_info->static_given = 1;
+ args_info->static_flag = !(args_info->static_flag);
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "timelimit"))
+ {
+ if (override || !args_info->timelimit_given)
+ {
+ args_info->timelimit_given = 1;
+ if (fnum == 2)
+ args_info->timelimit_arg = strtol (farg,&stop_char,0);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "apn"))
+ {
+ if (override || !args_info->apn_given)
+ {
+ args_info->apn_given = 1;
+ if (fnum == 2)
+ args_info->apn_arg = strdup (farg);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "imsi"))
+ {
+ if (override || !args_info->imsi_given)
+ {
+ args_info->imsi_given = 1;
+ if (fnum == 2)
+ args_info->imsi_arg = strdup (farg);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "msisdn"))
+ {
+ if (override || !args_info->msisdn_given)
+ {
+ args_info->msisdn_given = 1;
+ if (fnum == 2)
+ args_info->msisdn_arg = strdup (farg);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "qos"))
+ {
+ if (override || !args_info->qos_given)
+ {
+ args_info->qos_given = 1;
+ if (fnum == 2)
+ args_info->qos_arg = strtol (farg,&stop_char,0);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "uid"))
+ {
+ if (override || !args_info->uid_given)
+ {
+ args_info->uid_given = 1;
+ if (fnum == 2)
+ args_info->uid_arg = strdup (farg);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+ if (!strcmp(fopt, "pwd"))
+ {
+ if (override || !args_info->pwd_given)
+ {
+ args_info->pwd_given = 1;
+ if (fnum == 2)
+ args_info->pwd_arg = strdup (farg);
+ else
+ {
+ fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
+ filename, line_num);
+ exit (EXIT_FAILURE);
+ }
+ }
+ continue;
+ }
+
+
+ /* Tried all known options. This one is unknown! */
+ fprintf (stderr, "%s: Unknown option '%s' found in %s\n",
+ PACKAGE, fopt, filename);
+ exit (EXIT_FAILURE);
+ }
+ } /* while */
+ fclose(file); /* No error checking on close */
+
+ return 0;
+}
diff --git a/sgsnemu/cmdline.ggo b/sgsnemu/cmdline.ggo
new file mode 100644
index 0000000..6b21818
--- /dev/null
+++ b/sgsnemu/cmdline.ggo
@@ -0,0 +1,37 @@
+# OpenGGSN - Gateway GPRS Support Node
+# Copyright (C) 2002 Mondru AB.
+#
+# The contents of this file may be used under the terms of the GNU
+# General Public License Version 2, provided that the above copyright
+# notice and this permission notice is included in all copies or
+# substantial portions of the software.
+#
+# The initial developer of the original code is
+# Jens Jakobsen <jj@openggsn.org>
+#
+# Contributor(s):
+
+option "fg" f "Run in foreground" flag off
+option "debug" d "Run in debug mode" flag off
+
+option "conf" c "Read configuration file" string no
+option "pidfile" - "Filename of process id file" string default="./sgsnemu.pid" no
+option "statedir" - "Directory of nonvolatile data" string default="./" no
+
+option "dns" - "DNS Server to use" string no
+option "listen" l "Local interface" string no
+option "remote" r "Remote host" string no
+option "net" n "Network" string default="192.168.0.0" no
+option "mask" - "Network mask" string default="255.255.255.0" no
+
+option "contexts" - "Number of contexts" int default="1" no
+option "static" - "Allocate static tun ifterface" flag off
+option "timelimit" - "Exit after timelimit seconds" int default="0" no
+
+option "apn" a "Access point name" string default="internet" no
+option "imsi" i "IMSI" string default="240010123456789" no
+option "msisdn" m "Mobile Station ISDN number" string default="46702123456" no
+option "qos" q "Requested quality of service" int default="0x0b921f" no
+option "uid" u "Login user ID" string default="mig" no
+option "pwd" p "Login password" string default="hemmelig" no
+
diff --git a/sgsnemu/cmdline.h b/sgsnemu/cmdline.h
new file mode 100644
index 0000000..cd4ac6e
--- /dev/null
+++ b/sgsnemu/cmdline.h
@@ -0,0 +1,77 @@
+/* cmdline.h */
+
+/* File autogenerated by gengetopt version 2.8rc */
+
+#ifndef _cmdline_h
+#define _cmdline_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Don't define PACKAGE and VERSION if we use automake. */
+#ifndef PACKAGE
+#define PACKAGE ""
+#endif
+
+#ifndef VERSION
+#define VERSION ""
+#endif
+
+struct gengetopt_args_info
+{
+ int fg_flag; /* Run in foreground (default=off). */
+ int debug_flag; /* Run in debug mode (default=off). */
+ char * conf_arg; /* Read configuration file. */
+ char * pidfile_arg; /* Filename of process id file (default='./sgsnemu.pid'). */
+ char * statedir_arg; /* Directory of nonvolatile data (default='./'). */
+ char * dns_arg; /* DNS Server to use. */
+ char * listen_arg; /* Local interface. */
+ char * remote_arg; /* Remote host. */
+ char * net_arg; /* Network (default='192.168.0.0'). */
+ char * mask_arg; /* Network mask (default='255.255.255.0'). */
+ int contexts_arg; /* Number of contexts (default='1'). */
+ int static_flag; /* Allocate static tun ifterface (default=off). */
+ int timelimit_arg; /* Exit after timelimit seconds (default='0'). */
+ char * apn_arg; /* Access point name (default='internet'). */
+ char * imsi_arg; /* IMSI (default='240010123456789'). */
+ char * msisdn_arg; /* Mobile Station ISDN number (default='46702123456'). */
+ int qos_arg; /* Requested quality of service (default='0x0b921f'). */
+ char * uid_arg; /* Login user ID (default='mig'). */
+ char * pwd_arg; /* Login password (default='hemmelig'). */
+
+ int help_given ; /* Whether help was given. */
+ int version_given ; /* Whether version was given. */
+ int fg_given ; /* Whether fg was given. */
+ int debug_given ; /* Whether debug was given. */
+ int conf_given ; /* Whether conf was given. */
+ int pidfile_given ; /* Whether pidfile was given. */
+ int statedir_given ; /* Whether statedir was given. */
+ int dns_given ; /* Whether dns was given. */
+ int listen_given ; /* Whether listen was given. */
+ int remote_given ; /* Whether remote was given. */
+ int net_given ; /* Whether net was given. */
+ int mask_given ; /* Whether mask was given. */
+ int contexts_given ; /* Whether contexts was given. */
+ int static_given ; /* Whether static was given. */
+ int timelimit_given ; /* Whether timelimit was given. */
+ int apn_given ; /* Whether apn was given. */
+ int imsi_given ; /* Whether imsi was given. */
+ int msisdn_given ; /* Whether msisdn was given. */
+ int qos_given ; /* Whether qos was given. */
+ int uid_given ; /* Whether uid was given. */
+ int pwd_given ; /* Whether pwd was given. */
+
+} ;
+
+int cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info);
+
+void cmdline_parser_print_help(void);
+void cmdline_parser_print_version(void);
+
+int cmdline_parser_configfile (char * const filename, struct gengetopt_args_info *args_info, int override);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* _cmdline_h */
diff --git a/sgsnemu/ggsn_restart b/sgsnemu/ggsn_restart
new file mode 100644
index 0000000..82cced2
--- /dev/null
+++ b/sgsnemu/ggsn_restart
@@ -0,0 +1 @@
+51
diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c
new file mode 100644
index 0000000..b25fe87
--- /dev/null
+++ b/sgsnemu/sgsnemu.c
@@ -0,0 +1,754 @@
+/*
+ * OpenGGSN - Gateway GPRS Support Node
+ * Copyright (C) 2002 Mondru AB.
+ *
+ * The contents of this file may be used under the terms of the GNU
+ * General Public License Version 2, provided that the above copyright
+ * notice and this permission notice is included in all copies or
+ * substantial portions of the software.
+ *
+ * The initial developer of the original code is
+ * Jens Jakobsen <jj@openggsn.org>
+ *
+ * Contributor(s):
+ *
+ */
+
+/*
+ * sgsnemu.c
+ *
+ */
+
+
+#ifdef __linux__
+#define _GNU_SOURCE 1 /* strdup() prototype, broken arpa/inet.h */
+#endif
+
+
+#include <syslog.h>
+#include <ctype.h>
+#include <netdb.h>
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <features.h>
+#include <errno.h>
+#include <asm/types.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <resolv.h>
+#include <time.h>
+
+#include "tun.h"
+#include "../gtp/pdp.h"
+#include "../gtp/gtp.h"
+#include "cmdline.h"
+
+/* State variable */
+/* 0: Idle */
+/* 1: Wait_connect */
+/* 2: Connected */
+/* 3: Wait_disconnect */
+int state = 0;
+
+int maxfd = 0; /* For select() */
+int tun_fd = -1; /* Network file descriptor */
+struct tun_t *tun; /* TUN instance */
+struct tun_t *tun1, *tun2; /* TUN instance for client */
+int tun_fd1 = -1; /* Network file descriptor */
+int tun_fd2 = -1; /* Network file descriptor */
+struct in_addr net, mask; /* Network interface */
+int stattun; /* Allocate static tun */
+
+int debug; /* Print debug messages */
+
+int encaps_printf(void *p, void *packet, unsigned len)
+{
+ int i;
+ printf("The packet looks like this:\n");
+ for( i=0; i<len; i++) {
+ printf("%02x ", (unsigned char)*(char *)(packet+i));
+ if (!((i+1)%16)) printf("\n");
+ };
+ printf("\n");
+}
+
+/* Used to write process ID to file. Assume someone else will delete */
+void log_pid(char *pidfile) {
+ FILE *file;
+ mode_t oldmask;
+
+ oldmask = umask(022);
+ file = fopen(pidfile, "w");
+ umask(oldmask);
+ if(!file)
+ return;
+ fprintf(file, "%d\n", getpid());
+ fclose(file);
+}
+
+
+int create_tun() {
+ char buf[1024];
+ char snet[100], smask[100];
+
+ if ((tun_fd = tun_newtun((struct tun_t**) &tun)) > maxfd)
+ maxfd = tun_fd;
+
+ if (tun_fd == -1) {
+ printf("Failed to open tun\n");
+ exit(1);
+ }
+
+ strncpy(snet, inet_ntoa(net), 100);
+ strncpy(smask, inet_ntoa(mask), 100);
+
+ sprintf(buf, "ifconfig %s %s mtu 1450 netmask %s",
+ tun->devname, snet, smask);
+ if (debug) printf("%s\n", buf);
+ system(buf);
+
+ system("echo 1 > /proc/sys/net/ipv4/ip_forward");
+
+ return 0;
+}
+
+int getip(struct pdp_t *pdp, void* ipif, struct ul66_t *eua,
+ struct in_addr *net, struct in_addr *mask) {
+ struct in_addr addr;
+ uint32_t ip_start, ip_end, ip_cur;
+ struct pdp_t *pdp_;
+ struct ul66_t eua_;
+
+ printf("Begin getip %d %d %2x%2x%2x%2x\n", (unsigned)ipif, eua->l,
+ eua->v[2],eua->v[3],eua->v[4],eua->v[5]);
+
+ ip_start = ntoh32(net->s_addr & mask->s_addr);
+ ip_end = ntoh32(hton32(ip_start) | ~mask->s_addr);
+
+ /* By convention the first address is the network address, and the last */
+ /* address is the broadcast address. This way two IP addresses are "lost" */
+ ip_start++;
+
+ if (eua->l == 0) { /* No address supplied. Find one that is available! */
+ /* This routine does linear search. In order to support millions of
+ * addresses we should instead keep a linked list of available adresses */
+ for (ip_cur = ip_start; ip_cur < ip_end; ip_cur++) {
+ addr.s_addr = hton32(ip_cur);
+ pdp_ntoeua(&addr, &eua_);
+ if (pdp_ipget(&pdp_, ipif, &eua_) == -1) {
+ pdp_ntoeua(&addr, &pdp->eua);
+ pdp->ipif = ipif;
+ return 0;
+ };
+ }
+ return EOF; /* No addresses available */
+ }
+ else { /* Address supplied */
+ if (pdp_ipget(&pdp_, ipif, eua) == -1) {
+ pdp->ipif = ipif;
+ pdp->eua.l = eua->l;
+ memcpy(pdp->eua.v, eua->v, eua->l);
+ return 0;
+ }
+ else return EOF; /* Specified address not available */
+ }
+}
+
+int delete_context(struct pdp_t *pdp) {
+
+ if (!stattun) {
+ tun_freetun((struct tun_t*) pdp->ipif);
+
+ /* Clean up locally */
+ if (pdp->ipif == tun1) {
+ printf("Deleting tun interface\n");
+ tun_fd1=-1;
+ }
+ if (pdp->ipif == tun2) {
+ printf("Deleting tun interface\n");
+ tun_fd2=-1;
+ }
+ }
+
+ pdp_ipdel(pdp);
+ return 0;
+}
+
+int create_pdp_conf(struct pdp_t *pdp, int cause) {
+ char buf[1024];
+
+ printf("Received create PDP context response. Cause value: %d\n", cause);
+ if ((cause == 128) && (pdp->eua.l == 6)) {
+
+
+ if (stattun) {
+ pdp->ipif = tun1;
+ }
+ else {
+ printf("Setting up interface and routing\n");
+ if ((tun_fd = tun_newtun((struct tun_t**) &pdp->ipif)) > maxfd)
+ maxfd = tun_fd;
+
+ /* HACK: Only support select of up to two tun interfaces */
+ if (NULL == tun1) {
+ tun1 = pdp->ipif;
+ tun_fd1 = tun1->fd;
+ }
+ else {
+ tun2 = pdp->ipif;
+ tun_fd2 = tun2->fd;
+ }
+
+ /*system("ifconfig tun0 192.168.0.10");*/
+ sprintf(buf, "ifconfig %s %hu.%hu.%hu.%hu",
+ ((struct tun_t*) pdp->ipif)->devname,
+ pdp->eua.v[2], pdp->eua.v[3], pdp->eua.v[4], pdp->eua.v[5]);
+ printf(buf); printf("\n");
+ system(buf);
+
+
+ /*system("route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.10");*/
+ sprintf(buf, "route add -net %hu.%hu.%hu.0 netmask 255.255.255.0 gw %hu.%hu.%hu.%hu",
+ pdp->eua.v[2], pdp->eua.v[3], pdp->eua.v[4],
+ pdp->eua.v[2], pdp->eua.v[3], pdp->eua.v[4], pdp->eua.v[5]);
+ printf(buf); printf("\n");
+ system(buf);
+
+ system("echo 1 > /proc/sys/net/ipv4/ip_forward");
+ }
+
+ pdp_ipset(pdp, pdp->ipif, &pdp->eua);
+
+ state = 2; /* Connected */
+ }
+ else {
+ state = 0;
+ }
+
+ printf("\n");
+
+ return 0;
+}
+
+
+int create_pdp_ind(struct pdp_t *pdp) {
+
+ printf("Received create PDP context request\n");
+
+ pdp->eua.l=0; /* TODO: Indicates dynamic IP */
+
+ /* ulcpy(&pdp->qos_neg, &pdp->qos_req, sizeof(pdp->qos_req.v)); */
+ memcpy(pdp->qos_neg0, pdp->qos_req0, sizeof(pdp->qos_neg));
+
+ getip(pdp, &tun, &pdp->eua, &net, &mask);
+ pdp_ipset(pdp, pdp->ipif, &pdp->eua);
+
+ return 0; /* Success */
+}
+
+
+int delete_pdp_conf(struct pdp_t *pdp, int cause) {
+ printf("Received delete PDP context response. Cause value: %d\n", cause);
+ return 0;
+}
+
+int echo_conf(struct pdp_t *pdp, int cause) {
+ printf("Received echo response. Cause value: %d\n", cause);
+ return 0;
+}
+
+int conf(int type, int cause, struct pdp_t* pdp, void *aid) {
+ /* if (cause < 0) return 0; Some error occurred. We don't care */
+ switch (type) {
+ case GTP_ECHO_REQ:
+ return echo_conf(pdp, cause);
+ case GTP_CREATE_PDP_REQ:
+ if (cause !=128) return 0; /* Request not accepted. We don't care */
+ return create_pdp_conf(pdp, cause);
+ case GTP_DELETE_PDP_REQ:
+ if (cause !=128) return 0; /* Request not accepted. We don't care */
+ return delete_pdp_conf(pdp, cause);
+ default:
+ return 0;
+ }
+}
+
+int encaps_gtp_client(void *gsn, struct tun_t *tun, void *pack, unsigned len) {
+ /* Special client version which checks for source address instead */
+ struct pdp_t *pdp;
+ struct in_addr addr;
+ struct ul66_t eua;
+ /*printf("encaps_gtp. Packet received: forwarding to gtp.\n");*/
+ /* First we need to extract the IP destination address */
+ memcpy(&addr.s_addr, pack+12, 4); /* This ought to be dest addr */
+ pdp_ntoeua(&addr, &eua);
+ if (pdp_ipget(&pdp, tun, &eua) == 0) {
+ return gtp_gpdu((struct gsn_t*) gsn, pdp, pack, len);
+ }
+ else {
+ printf("Received packet with no destination!!!\n");
+ return 0;
+ }
+}
+
+int encaps_tun(struct pdp_t *pdp, void *pack, unsigned len) {
+ /* printf("encaps_tun. Packet received: forwarding to tun\n");*/
+ return tun_encaps((struct tun_t*) pdp->ipif, pack, len);
+}
+
+int main(int argc, char **argv)
+{
+ /* gengeopt declarations */
+ struct gengetopt_args_info args_info;
+
+ /* function-local options */
+
+ struct hostent *host;
+
+ struct in_addr listen, remote;
+ struct in_addr dns;
+
+ int gtpfd = -1; /* Network file descriptor */
+ struct gsn_t *gsn; /* GSN instance */
+
+ fd_set fds; /* For select() */
+ struct timeval idleTime; /* How long to select() */
+
+ struct pdp_t *pdp[2];
+
+ int n; /* For counter */
+
+ int contexts; /* Number of contexts to create */
+ int timelimit; /* Number of seconds to be connected */
+ int starttime; /* Time program was started */
+
+ struct ul_t imsi, qos, apn, msisdn;
+ unsigned char qosh[3], imsih[8], apnh[256], msisdnh[256];
+ struct ul255_t pco;
+ uint64_t imsi3;
+
+ /* open a connection to the syslog daemon */
+ /*openlog(PACKAGE, LOG_PID, LOG_DAEMON);*/
+ openlog(PACKAGE, (LOG_PID | LOG_PERROR), LOG_DAEMON);
+
+ if (cmdline_parser (argc, argv, &args_info) != 0)
+ exit(1);
+ if (args_info.debug_flag) {
+ printf("remote: %s\n", args_info.remote_arg);
+ printf("listen: %s\n", args_info.listen_arg);
+ printf("conf: %s\n", args_info.conf_arg);
+ printf("fg: %d\n", args_info.fg_flag);
+ printf("debug: %d\n", args_info.debug_flag);
+ printf("imsi: %s\n", args_info.imsi_arg);
+ printf("qos: %#08x\n", args_info.qos_arg);
+ printf("apn: %s\n", args_info.apn_arg);
+ printf("msisdn: %s\n", args_info.msisdn_arg);
+ printf("uid: %s\n", args_info.uid_arg);
+ printf("pwd: %s\n", args_info.pwd_arg);
+ printf("static: %d\n", args_info.static_flag);
+ printf("net: %s\n", args_info.net_arg);
+ printf("mask: %s\n", args_info.mask_arg);
+ printf("pidfile: %s\n", args_info.pidfile_arg);
+ printf("statedir: %s\n", args_info.statedir_arg);
+ printf("dns: %s\n", args_info.dns_arg);
+ printf("contexts: %d\n", args_info.contexts_arg);
+ printf("timelimit: %d\n", args_info.timelimit_arg);
+ }
+
+ /* Try out our new parser */
+
+ if (args_info.conf_arg) {
+ if (cmdline_parser_configfile (args_info.conf_arg, &args_info, 0) != 0)
+ exit(1);
+ if (args_info.debug_flag) {
+ printf("cmdline_parser_configfile\n");
+ printf("remote: %s\n", args_info.remote_arg);
+ printf("listen: %s\n", args_info.listen_arg);
+ printf("conf: %s\n", args_info.conf_arg);
+ printf("fg: %d\n", args_info.fg_flag);
+ printf("debug: %d\n", args_info.debug_flag);
+ printf("imsi: %s\n", args_info.imsi_arg);
+ printf("qos: %#08x\n", args_info.qos_arg);
+ printf("apn: %s\n", args_info.apn_arg);
+ printf("msisdn: %s\n", args_info.msisdn_arg);
+ printf("uid: %s\n", args_info.uid_arg);
+ printf("pwd: %s\n", args_info.pwd_arg);
+ printf("static: %d\n", args_info.static_flag);
+ printf("net: %s\n", args_info.net_arg);
+ printf("mask: %s\n", args_info.mask_arg);
+ printf("pidfile: %s\n", args_info.pidfile_arg);
+ printf("statedir: %s\n", args_info.statedir_arg);
+ printf("dns: %s\n", args_info.dns_arg);
+ printf("contexts: %d\n", args_info.contexts_arg);
+ printf("timelimit: %d\n", args_info.timelimit_arg);
+ }
+ }
+
+ /* Handle each option */
+
+ /* foreground */
+ /* If flag not given run as a daemon */
+ if (!args_info.fg_flag)
+ {
+ closelog();
+ /* Close the standard file descriptors. Why? */
+ freopen("/dev/null", "w", stdout);
+ freopen("/dev/null", "w", stderr);
+ freopen("/dev/null", "r", stdin);
+ daemon(0, 0);
+ /* Open log again. This time with new pid */
+ openlog(PACKAGE, LOG_PID, LOG_DAEMON);
+ }
+
+ /* debug */
+ debug = args_info.debug_flag;
+
+ /* pidfile */
+ /* This has to be done after we have our final pid */
+ if (args_info.pidfile_arg) {
+ log_pid(args_info.pidfile_arg);
+ }
+
+ /* dns */
+ /* If no dns option is given use system default */
+ /* Do hostname lookup to translate hostname to IP address */
+ printf("\n");
+ if (args_info.dns_arg) {
+ if (!(host = gethostbyname(args_info.dns_arg))) {
+ fprintf(stderr, "%s: Invalid dns address: %s!\n",
+ PACKAGE, args_info.dns_arg);
+ syslog(LOG_ERR, "Invalid dns address: %s!",
+ args_info.dns_arg);
+ exit(1);
+ }
+ else {
+ memcpy(&dns.s_addr, host->h_addr, host->h_length);
+ _res.nscount = 1;
+ _res.nsaddr_list[0].sin_addr = dns;
+ printf("Using DNS server: %s (%s)\n", args_info.dns_arg, inet_ntoa(dns));
+ }
+ }
+ else {
+ dns.s_addr= 0;
+ printf("Using default DNS server\n");
+ }
+
+ /* listen */
+ /* If no listen option is specified listen to any local port */
+ /* Do hostname lookup to translate hostname to IP address */
+ if (args_info.listen_arg) {
+ if (!(host = gethostbyname(args_info.listen_arg))) {
+ fprintf(stderr, "%s: Invalid listening address: %s!\n",
+ PACKAGE, args_info.listen_arg);
+ syslog(LOG_ERR, "Invalid listening address: %s!",
+ args_info.listen_arg);
+ exit(1);
+ }
+ else {
+ memcpy(&listen.s_addr, host->h_addr, host->h_length);
+ printf("Local IP address is: %s (%s)\n", args_info.listen_arg, inet_ntoa(listen));
+ }
+ }
+ else {
+ fprintf(stderr, "%s: Listening address must be specified: %s!\n",
+ PACKAGE, args_info.listen_arg);
+ syslog(LOG_ERR, "Listening address must be specified: %s!",
+ args_info.listen_arg);
+ exit(1);
+ }
+
+
+ /* remote */
+ /* If no remote option is specified terminate */
+ /* Do hostname lookup to translate hostname to IP address */
+ if (args_info.remote_arg) {
+ if (!(host = gethostbyname(args_info.remote_arg))) {
+ fprintf(stderr, "%s: Invalid remote address: %s!\n",
+ PACKAGE, args_info.remote_arg);
+ syslog(LOG_ERR, "Invalid remote address: %s!",
+ args_info.remote_arg);
+ exit(1);
+ }
+ else {
+ memcpy(&remote.s_addr, host->h_addr, host->h_length);
+ printf("Remote IP address is: %s (%s)\n", args_info.remote_arg, inet_ntoa(remote));
+ }
+ }
+ else {
+ fprintf(stderr, "%s: No remote address given!\n",
+ PACKAGE);
+ syslog(LOG_ERR, "No remote address given!");
+ exit(1);
+ }
+
+
+ /* net */
+ /* Store net as in_addr */
+ if (args_info.net_arg) {
+ if (!inet_aton(args_info.net_arg, &net)) {
+ fprintf(stderr, "%s: Invalid network address: %s!\n",
+ PACKAGE, args_info.net_arg);
+ syslog(LOG_ERR, "Invalid network address: %s!",
+ args_info.net_arg);
+ exit(1);
+ }
+ }
+
+ /* mask */
+ /* Store mask as in_addr */
+ if (args_info.mask_arg) {
+ if (!inet_aton(args_info.mask_arg, &mask)) {
+ fprintf(stderr, "%s: Invalid network mask: %s!\n",
+ PACKAGE, args_info.mask_arg);
+ syslog(LOG_ERR, "Invalid network mask: %s!",
+ args_info.mask_arg);
+ exit(1);
+ }
+ }
+
+ /* imsi */
+ if (strlen(args_info.imsi_arg)!=15) {
+ printf("Invalid IMSI\n");
+ exit(1);
+ }
+ imsi.l = 8;
+ imsi.v = imsih;
+ imsi.v[0] = args_info.imsi_arg[0]-48 + (args_info.imsi_arg[1]-48)*16;
+ imsi.v[1] = args_info.imsi_arg[2]-48 + (args_info.imsi_arg[3]-48)*16;
+ imsi.v[2] = args_info.imsi_arg[4]-48 + (args_info.imsi_arg[5]-48)*16;
+ imsi.v[3] = args_info.imsi_arg[6]-48 + (args_info.imsi_arg[7]-48)*16;
+ imsi.v[4] = args_info.imsi_arg[8]-48 + (args_info.imsi_arg[9]-48)*16;
+ imsi.v[5] = args_info.imsi_arg[10]-48 + (args_info.imsi_arg[11]-48)*16;
+ imsi.v[6] = args_info.imsi_arg[12]-48 + (args_info.imsi_arg[13]-48)*16;
+ imsi.v[7] = args_info.imsi_arg[14]-48 + 0*16;
+
+ if (imsi.l > sizeof(imsi3)) {
+ printf("Invalid IMSI\n");
+ exit(1);
+ }
+ else {
+ memcpy(&imsi3, imsi.v, imsi.l);
+ printf("IMSI is: %s (%#08llx)\n", args_info.imsi_arg, imsi3);
+ }
+
+ /* qos */
+ qos.l = 3;
+ qos.v = qosh;
+ qos.v[2] = (args_info.qos_arg) & 0xff;
+ qos.v[1] = ((args_info.qos_arg) >> 8) & 0xff;
+ qos.v[0] = ((args_info.qos_arg) >> 16) & 0xff;
+
+ /* contexts */
+ contexts = args_info.contexts_arg;
+
+ /* Timelimit */
+ timelimit = args_info.timelimit_arg;
+ starttime = time(NULL);
+
+ /* apn */
+ if (strlen(args_info.apn_arg)>255) {
+ printf("Invalid APN\n");
+ exit(1);
+ }
+ apn.l = strlen(args_info.apn_arg) + 1;
+ apn.v = apnh;
+ apn.v[0] = (char) strlen(args_info.apn_arg);
+ strncpy(&apn.v[1], args_info.apn_arg, 255);
+ printf("Using APN: %s\n", args_info.apn_arg);
+
+ /* msisdn */
+ if (strlen(args_info.msisdn_arg)>255) {
+ printf("Invalid MSISDN\n");
+ exit(1);
+ }
+ msisdn.l = 1;
+ msisdn.v = msisdnh;
+ msisdn.v[0] = 0x91; /* International format */
+ for(n=0; n<strlen(args_info.msisdn_arg); n++) {
+ if ((n%2) == 0) {
+ msisdn.v[((int)n/2)+1] = args_info.msisdn_arg[n] - 48 + 0xf0;
+ msisdn.l += 1;
+ }
+ else {
+ msisdn.v[((int)n/2)+1] = (msisdn.v[((int)n/2)+1] & 0x0f) + (args_info.msisdn_arg[n] - 48) * 16;
+ }
+ }
+ printf("Using MSISDN: %s\n", args_info.msisdn_arg);
+
+ /* UID and PWD */
+ /* Might need to also insert stuff like DNS etc. */
+ if ((strlen(args_info.uid_arg) + strlen(args_info.pwd_arg) + 10)>255) {
+ printf("invalid UID and PWD\n");
+ exit(1);
+ }
+ pco.l = strlen(args_info.uid_arg) + strlen(args_info.pwd_arg) + 10;
+ pco.v[0] = 0x80; /* PPP */
+ pco.v[1] = 0xc0;
+ pco.v[2] = 0x23; /* PAP */
+ pco.v[3] = 0x12;
+ pco.v[4] = 0x01; /* Authenticate request */
+ pco.v[5] = 0x01;
+ pco.v[6] = 0x00; /* MSB of length */
+ pco.v[7] = strlen(args_info.uid_arg) + strlen(args_info.pwd_arg) + 6;
+ pco.v[8] = strlen(args_info.uid_arg);
+ memcpy(&pco.v[9], args_info.uid_arg, strlen(args_info.uid_arg));
+ pco.v[9+strlen(args_info.uid_arg)] = strlen(args_info.pwd_arg);
+ memcpy(&pco.v[10+strlen(args_info.uid_arg)], args_info.pwd_arg, strlen(args_info.pwd_arg));
+
+ /* static */
+ stattun = args_info.static_flag;
+
+ printf("\nInitialising GTP library\n");
+ if ((gtpfd = gtp_new(&gsn, args_info.statedir_arg, &listen)) > maxfd)
+ maxfd = gtpfd;
+
+ if ((gtpfd = gtp_fd(gsn)) > maxfd)
+ maxfd = gtpfd;
+
+ gtp_set_cb_gpdu(gsn, encaps_tun);
+ gtp_set_cb_delete_context(gsn, delete_context);
+
+ gtp_set_cb_conf(gsn, conf);
+ printf("Done initialising GTP library\n\n");
+
+ if (stattun) {
+ create_tun();
+ tun1 = tun;
+ tun_fd1 = tun1->fd;
+ }
+
+ /* See if anybody is there */
+ printf("Sending off echo request\n");
+ if (gtpfd != -1) gtp_echo_req(gsn, &remote); /* See if remote is alive ? */
+
+ for(n=0; n<contexts; n++) {
+ printf("Setting up PDP context #%d\n", n);
+
+ pdp_newpdp(&pdp[n], imsi3, n, NULL); /* Allocated here. Cleaned up in gtp.c: TODO Should be statically allocated! */
+
+ /*
+ if (qos.l > sizeof(pdp[n]->qos_req.v)) {
+ exit(1);
+ }
+ else {
+ pdp[n]->qos_req.l = qos.l;
+ memcpy(pdp[n]->qos_req.v, qos.v, qos.l);
+ }
+ */
+ memcpy(pdp[n]->qos_req0, qos.v, qos.l); /* TODO range check */
+
+ pdp[n]->selmode = 0x01; /* MS provided APN, subscription not verified */
+
+ if (apn.l > sizeof(pdp[n]->apn_use.v)) {
+ exit(1);
+ }
+ else {
+ pdp[n]->apn_use.l = apn.l;
+ memcpy(pdp[n]->apn_use.v, apn.v, apn.l);
+ }
+
+ pdp[n]->gsnlc.l = 4;
+ memcpy(pdp[n]->gsnlc.v, &listen, 4);
+ pdp[n]->gsnlu.l = 4;
+ memcpy(pdp[n]->gsnlu.v, &listen, 4);
+
+ if (msisdn.l > sizeof(pdp[n]->msisdn.v)) {
+ exit(1);
+ }
+ else {
+ pdp[n]->msisdn.l = msisdn.l;
+ memcpy(pdp[n]->msisdn.v, msisdn.v, msisdn.l);
+ }
+
+ ipv42eua(&pdp[n]->eua, NULL); /* Request dynamic IP address */
+
+ if (pco.l > sizeof(pdp[n]->pco_req.v)) {
+ exit(1);
+ }
+ else {
+ pdp[n]->pco_req.l = pco.l;
+ memcpy(pdp[n]->pco_req.v, pco.v, pco.l);
+ }
+
+ /* Create context */
+ /* We send this of once. Retransmissions are handled by gtplib */
+ if (gtpfd != -1) gtp_create_context(gsn, pdp[n], NULL, &remote);
+ }
+
+ state = 1; /* Enter wait_connection state */
+
+ printf("Waiting for response from ggsn........\n\n");
+
+
+ /******************************************************************/
+ /* Main select loop */
+ /******************************************************************/
+
+ while (((starttime + timelimit + 10) > time(NULL)) || (0 == timelimit)) {
+
+ /* Take down client connections at some stage */
+ if (((starttime + timelimit) <= time(NULL)) && (0 != timelimit) && (2 == state)) {
+ state = 3;
+ for(n=0; n<contexts; n++) {
+ /* Delete context */
+ printf("Disconnecting PDP context #%d\n", n);
+ if (gtpfd != -1) gtp_delete_context(gsn, pdp[n], NULL);
+ }
+ }
+
+ FD_ZERO(&fds);
+ if (tun_fd1 != -1) FD_SET(tun_fd1, &fds);
+ if (tun_fd2 != -1) FD_SET(tun_fd2, &fds);
+ if (gtpfd != -1) FD_SET(gtpfd, &fds);
+
+ gtp_retranstimeout(gsn, &idleTime);
+
+ switch (select(maxfd + 1, &fds, NULL, NULL, &idleTime)) {
+ case -1:
+ syslog(LOG_ERR, "sgsnemu: select = -1");
+ break;
+ case 0:
+ gtp_retrans(gsn); /* Only retransmit if nothing else */
+ break;
+ default:
+ break;
+ }
+
+ if (tun_fd1 != -1 &&
+ FD_ISSET(tun_fd1, &fds) &&
+ tun_decaps(tun1, encaps_gtp_client, gsn) < 0) {
+ syslog(LOG_ERR, "TUN read failed (fd)=(%d)", tun_fd1);
+ }
+
+ if (tun_fd2 != -1 &&
+ FD_ISSET(tun_fd2, &fds) &&
+ tun_decaps(tun2, encaps_gtp_client, gsn) < 0) {
+ syslog(LOG_ERR, "TUN read failed (fd)=(%d)", tun_fd2);
+ }
+
+ if (gtpfd != -1 && FD_ISSET(gtpfd, &fds) &&
+ gtp_decaps(gsn) < 0) {
+ syslog(LOG_ERR, "GTP read failed (gre)=(%d)", gtpfd);
+ }
+
+
+ }
+
+ gtp_free(gsn); /* Clean up the gsn instance */
+
+ return 1;
+
+}
+
diff --git a/sgsnemu/sgsnemu.pid b/sgsnemu/sgsnemu.pid
new file mode 100644
index 0000000..6673415
--- /dev/null
+++ b/sgsnemu/sgsnemu.pid
@@ -0,0 +1 @@
+14305
diff --git a/sgsnemu/tun.c b/sgsnemu/tun.c
new file mode 100644
index 0000000..72ea264
--- /dev/null
+++ b/sgsnemu/tun.c
@@ -0,0 +1,128 @@
+/*
+ * OpenGGSN - Gateway GPRS Support Node
+ * Copyright (C) 2002 Mondru AB.
+ *
+ * The contents of this file may be used under the terms of the GNU
+ * General Public License Version 2, provided that the above copyright
+ * notice and this permission notice is included in all copies or
+ * substantial portions of the software.
+ *
+ * The initial developer of the original code is
+ * Jens Jakobsen <jj@openggsn.org>
+ *
+ * Contributor(s):
+ *
+ */
+
+/*
+ * tun.c: Contains all TUN functionality. Should be able to handle multiple
+ * tunnels in the same program. Each tunnel is identified by the socket.
+ * I suppose that no other state information than the socket is needed.
+ *
+ * - tun_newtun: Initialise TUN tunnel.
+ * - tun_freetun: Free a device previously created with tun_newtun.
+ * - tun_encaps: Encapsulate packet in TUN tunnel and send off
+ * - tun_decaps: Extract packet from TUN tunnel and call function to
+ * ship it off as GTP encapsulated packet.
+ *
+ * TODO:
+ * - Do we need to handle fragmentation?
+ */
+
+
+#include <syslog.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <errno.h>
+#include <linux/if_tun.h>
+
+
+#include "tun.h"
+
+
+int tun_newtun(struct tun_t **tun)
+{
+ struct ifreq ifr;
+
+ if (!(*tun = calloc(1, sizeof(struct tun_t)))) {
+ syslog(LOG_ERR, "%s %d. calloc(nmemb=%d, size=%d) failed: Error = %s(%d)",
+ __FILE__, __LINE__, 1, sizeof(struct tun_t),
+ strerror(errno), errno);
+ return EOF;
+ }
+
+ if (((*tun)->fd = open("/dev/net/tun", O_RDWR)) < 0) {
+ syslog(LOG_ERR, "TUN: open() failed");
+ return -1;
+ }
+
+ memset(&ifr, 0, sizeof(ifr));
+ ifr.ifr_flags = IFF_TUN | IFF_NO_PI; /* Tun device, no packet info */
+ strncpy(ifr.ifr_name, (*tun)->devname, IFNAMSIZ);
+
+ if (ioctl((*tun)->fd, TUNSETIFF, (void *) &ifr) < 0) {
+ syslog(LOG_ERR, "TUN: ioctl() failed");
+ close((*tun)->fd);
+ return -1;
+ }
+
+ ioctl((*tun)->fd, TUNSETNOCSUM, 1); /* Disable checksums */
+
+ strncpy((*tun)->devname, ifr.ifr_name, IFNAMSIZ);
+
+ return (*tun)->fd;
+}
+
+int tun_freetun(struct tun_t *tun)
+{
+ if (close(tun->fd)) {
+ syslog(LOG_ERR, "%s %d. close(fd=%d) failed: Error = %s",
+ __FILE__, __LINE__, tun->fd, strerror(errno));
+ return EOF;
+ }
+ free(tun);
+ return 0;
+}
+
+
+int tun_decaps(struct tun_t *tun,
+ int (*cb) (void *cl, struct tun_t*, void *pack, unsigned len),
+ void *cl)
+{
+ unsigned char buffer[PACKET_MAX + 64 /*TODO: ip header */ ];
+ int status;
+
+
+ if ((status = read(tun->fd, buffer, sizeof(buffer))) <= 0) {
+ syslog(LOG_ERR, "TUN: read(fd=%d,buffer=%lx,len=%d) from network failed: status = %d error = %s",
+ tun->fd, (unsigned long) buffer, sizeof(buffer), status, status ? strerror(errno) : "No error");
+ return -1;
+ }
+
+ /* Need to include code to verify packet src and dest addresses */
+ return cb(cl, tun, buffer, status);
+}
+
+int tun_encaps(struct tun_t *tun, void *pack, unsigned len)
+{
+ return write(tun->fd, pack, len);
+}
diff --git a/sgsnemu/tun.h b/sgsnemu/tun.h
new file mode 100644
index 0000000..03dc7df
--- /dev/null
+++ b/sgsnemu/tun.h
@@ -0,0 +1,48 @@
+/*
+ * OpenGGSN - Gateway GPRS Support Node
+ * Copyright (C) 2002 Mondru AB.
+ *
+ * The contents of this file may be used under the terms of the GNU
+ * General Public License Version 2, provided that the above copyright
+ * notice and this permission notice is included in all copies or
+ * substantial portions of the software.
+ *
+ * The initial developer of the original code is
+ * Jens Jakobsen <jj@openggsn.org>
+ *
+ * Contributor(s):
+ *
+ */
+
+#ifndef _TUN_H
+#define _TUN_H
+
+#define hton8(x) (x)
+#define ntoh8(x) (x)
+#define hton16(x) htons(x)
+#define ntoh16(x) ntohs(x)
+#define hton32(x) htonl(x)
+#define ntoh32(x) ntohl(x)
+
+#define PACKET_MAX 8196 /* TODO */
+
+/* ***********************************************************
+ * Information storage for each tun instance
+ *************************************************************/
+
+struct tun_t {
+ int fd; /* File descriptor to network interface */
+ struct in_addr addr; /* IP address of tun interface */
+ char devname[IFNAMSIZ];/* Name of the tun device */
+};
+
+
+extern int tun_newtun(struct tun_t **tun);
+extern int tun_freetun(struct tun_t *tun);
+extern int tun_decaps(struct tun_t *tun,
+ int (*cb) (void *cl, struct tun_t*, void *pack, unsigned len),
+ void *cl);
+extern int tun_encaps(struct tun_t *tun, void *pack, unsigned len);
+
+
+#endif /* !_TUN_H */