Initial revision

This commit is contained in:
jjako 2002-12-16 13:33:51 +00:00
commit 52c2414f6c
74 changed files with 19548 additions and 0 deletions

0
AUTHORS Normal file
View File

339
COPYING Normal file
View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

0
ChangeLog Normal file
View File

330
Makefile Normal file
View File

@ -0,0 +1,330 @@
# 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
SUBDIRS = gtp ggsn sgsnemu
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES =
DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \
Makefile.in NEWS aclocal.m4 config.guess config.sub configure \
configure.in install-sh ltconfig ltmain.sh missing mkinstalldirs
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
$(ACLOCAL_M4): configure.in
cd $(srcdir) && $(ACLOCAL)
config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
all-recursive install-data-recursive install-exec-recursive \
installdirs-recursive install-recursive uninstall-recursive \
check-recursive installcheck-recursive info-recursive dvi-recursive:
@set fnord $(MAKEFLAGS); amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $(MAKEFLAGS); amf=$$2; \
dot_seen=no; \
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
rev="$$subdir $$rev"; \
test "$$subdir" = "." && dot_seen=yes; \
done; \
test "$$dot_seen" = "no" && rev=". $$rev"; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
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: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
fi; \
done; \
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 = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
-rm -rf $(distdir)
GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
mkdir $(distdir)/=build
mkdir $(distdir)/=inst
dc_install_base=`cd $(distdir)/=inst && pwd`; \
cd $(distdir)/=build \
&& ../configure --srcdir=.. --prefix=$$dc_install_base \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) dist
-rm -rf $(distdir)
@banner="$(distdir).tar.gz is ready for distribution"; \
dashes=`echo "$$banner" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
echo "$$dashes"
dist: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
dist-all: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
distdir: $(DISTFILES)
-rm -rf $(distdir)
mkdir $(distdir)
-chmod 777 $(distdir)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu 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
for subdir in $(SUBDIRS); do \
if test "$$subdir" = .; then :; else \
test -d $(distdir)/$$subdir \
|| mkdir $(distdir)/$$subdir \
|| exit 1; \
chmod 777 $(distdir)/$$subdir; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \
|| exit 1; \
fi; \
done
info-am:
info: info-recursive
dvi-am:
dvi: dvi-recursive
check-am: all-am
check: check-recursive
installcheck-am:
installcheck: installcheck-recursive
install-exec-am:
install-exec: install-exec-recursive
install-data-am:
install-data: install-data-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-recursive
uninstall-am:
uninstall: uninstall-recursive
all-am: Makefile
all-redirect: all-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs: installdirs-recursive
installdirs-am:
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-tags mostlyclean-generic
mostlyclean: mostlyclean-recursive
clean-am: clean-tags clean-generic mostlyclean-am
clean: clean-recursive
distclean-am: distclean-tags distclean-generic clean-am
-rm -f libtool
distclean: distclean-recursive
-rm -f config.status
maintainer-clean-am: maintainer-clean-tags 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-recursive
-rm -f config.status
.PHONY: install-data-recursive uninstall-data-recursive \
install-exec-recursive uninstall-exec-recursive installdirs-recursive \
uninstalldirs-recursive all-recursive check-recursive \
installcheck-recursive info-recursive dvi-recursive \
mostlyclean-recursive distclean-recursive clean-recursive \
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir 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-am \
installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# 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:

2
Makefile.am Normal file
View File

@ -0,0 +1,2 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = gtp ggsn sgsnemu

330
Makefile.in Normal file
View File

@ -0,0 +1,330 @@
# 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@
SUBDIRS = gtp ggsn sgsnemu
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES =
DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \
Makefile.in NEWS aclocal.m4 config.guess config.sub configure \
configure.in install-sh ltconfig ltmain.sh missing mkinstalldirs
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
$(ACLOCAL_M4): configure.in
cd $(srcdir) && $(ACLOCAL)
config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
@SET_MAKE@
all-recursive install-data-recursive install-exec-recursive \
installdirs-recursive install-recursive uninstall-recursive \
check-recursive installcheck-recursive info-recursive dvi-recursive:
@set fnord $(MAKEFLAGS); amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $(MAKEFLAGS); amf=$$2; \
dot_seen=no; \
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
rev="$$subdir $$rev"; \
test "$$subdir" = "." && dot_seen=yes; \
done; \
test "$$dot_seen" = "no" && rev=". $$rev"; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
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: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
fi; \
done; \
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 = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
-rm -rf $(distdir)
GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
mkdir $(distdir)/=build
mkdir $(distdir)/=inst
dc_install_base=`cd $(distdir)/=inst && pwd`; \
cd $(distdir)/=build \
&& ../configure --srcdir=.. --prefix=$$dc_install_base \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) dist
-rm -rf $(distdir)
@banner="$(distdir).tar.gz is ready for distribution"; \
dashes=`echo "$$banner" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
echo "$$dashes"
dist: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
dist-all: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
distdir: $(DISTFILES)
-rm -rf $(distdir)
mkdir $(distdir)
-chmod 777 $(distdir)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu 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
for subdir in $(SUBDIRS); do \
if test "$$subdir" = .; then :; else \
test -d $(distdir)/$$subdir \
|| mkdir $(distdir)/$$subdir \
|| exit 1; \
chmod 777 $(distdir)/$$subdir; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \
|| exit 1; \
fi; \
done
info-am:
info: info-recursive
dvi-am:
dvi: dvi-recursive
check-am: all-am
check: check-recursive
installcheck-am:
installcheck: installcheck-recursive
install-exec-am:
install-exec: install-exec-recursive
install-data-am:
install-data: install-data-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-recursive
uninstall-am:
uninstall: uninstall-recursive
all-am: Makefile
all-redirect: all-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs: installdirs-recursive
installdirs-am:
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-tags mostlyclean-generic
mostlyclean: mostlyclean-recursive
clean-am: clean-tags clean-generic mostlyclean-am
clean: clean-recursive
distclean-am: distclean-tags distclean-generic clean-am
-rm -f libtool
distclean: distclean-recursive
-rm -f config.status
maintainer-clean-am: maintainer-clean-tags 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-recursive
-rm -f config.status
.PHONY: install-data-recursive uninstall-data-recursive \
install-exec-recursive uninstall-exec-recursive installdirs-recursive \
uninstalldirs-recursive all-recursive check-recursive \
installcheck-recursive info-recursive dvi-recursive \
mostlyclean-recursive distclean-recursive clean-recursive \
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir 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-am \
installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# 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:

0
NEWS Normal file
View File

144
README Normal file
View File

@ -0,0 +1,144 @@
*** QuickStart ***
REQUIREMENTS
Linux
OpenGGSN was developed and tested using Redhat 7.1 and Redhat
7.2. It should run also on other Linux distributions as well as
FreeBSD and Solaris, but this is untested. Please tell me of any
testing results.
Tun
Both ggsn and sgsnemu uses the tun package. You need at least tun
version 1.1. See http://vtun.sourceforge.net/tun/ for instructions on
installation. Tun should be included from linux kernel version 2.4, so
you might not need to manually install tun.
COMPILATION
./configure
make clean
make
INSTALLATION
Need to be root to do this
make install
Add /usr/local/lib to /etc/ld.so.conf
Run ldconfig
RUNNING
sgsnemu
Edit the configuration file sgsnemu.conf found under
openggsn/examples.
Start the emulator using the command:
sgsnemu -c examples/sgsnemu.conf -l 10.20.30.50 -r 10.20.30.40 --apn internet
This will cause the sgsn emulator to bind to local address 10.20.30.50
and connect to the ggsn found at 10.20.30.40. It will first send off
an ECHO_REQUEST message. After this it will attemt to establish a pdp
context. If successful it will create a local interface and set up
routing. Now you should be able to ping through the connection. Use a
network analysator such as ethereal to monitor the traffic.
ggsn
Edit the configuration file ggsn.conf found under openggsn/examples.
Start the ggsn using the command:
ggsn --fg -c examples/ggsn.conf -l 10.20.30.40
This will run the ggsn in foreground using the local interface
10.20.30.40
*** Features ***
OpenGGSN is an open source implementation of GPRS Support Nodes
(GSNs). It implements the GPRS tunneling protocol (GTP) version 0.
OpenGGSN provides 3 components:
* gtplib
* ggsn
* sgsnemu
gtplib
This library contain all functionality retating to the GTP
protocol. Use this libraty if you want to implement your own
GSN. Currently gtplib supports GTPv0.
ggsn
The ggsn implements a Gateway GPRS Support Node. The GGSN is a
small application which is provided in order to test and demonstrate
the use of gtplib. It is fully compliant to the 3GPP standards, but
lack important functionality such as charging and management. Use this
application as a starting point if you want to build your own GGSN
with your own fancy VPN, management and charging functionality.
sgsnemu This application emulates a Serving GPRS Support Node. sgsnemu
enable you to test your 3GPP core network without the need to invest
in a 3G radio access network. An important application of sgsnemu is
the testing of roaming connectivity through a GPRS roaming exchange.
*** Required software ***
TUN
http://vtun.sourceforge.net/tun/
Both ggsn and sgsnemu uses the tun package. You need at least tun
version 1.1. See the above web page for instructions on installation.
GENGETOPT
http://www.gnu.org/software/gengetopt/gengetopt.html
Gengetopt is required if you want to change the options defined in the
cmdline.ggo source file. You need at least gengetopt version 2.8 (Not
released yet 2002-12-12).
If you are just going to compile the programs you don't need
gengetopt.
To use gengetopt do the following:
cd ggsn
../../gengetopt-2.8rc/src/gengetopt < cmdline.ggo --conf-parser
insert #define _GNU_SOURCE in the top of cmdline.c to get rid of warnings.
To use gengetopt do the following:
cd sgsnemu
../../gengetopt-2.8rc/src/gengetopt < cmdline.ggo --conf-parser
insert #define _GNU_SOURCE in the top of cmdline.c to get rid of warnings.
libPropList-0.10.1 (??? I can't remember if I use this???)
ftp://ftp.windowmaker.org/pub/libs
*** Compilation and Installation ***
To generate everything:
See http://sources.redhat.com/autobook/autobook/autobook_25.html#SEC25
1 edit configure.in
2 run aclocal
3 run autoheader
(run automake --add-missing)
4 run automake
5 run autoconf
6 run ./configure
7 rin make clean
8 run make
9 run make install
10 Add /usr/local/lib to /etc/ld.so.conf
11 run ldconfig
*** Installation of libraries
cd gtp
make install
Add /usr/local/lib to /etc/ld.so.conf
run ldconfig
On RedHat add /usr/local/lib to /etc/ld.so.conf
http://www.dwheeler.com/program-library/Program-Library-HOWTO/shared-libraries.html
*** Running ggsn ***
Use ggsn -h for a list of available options.
*** Running sgsnemu ***
Use sgsnemu -h for a list of available options.

522
aclocal.m4 vendored Normal file
View File

@ -0,0 +1,522 @@
dnl aclocal.m4 generated automatically by aclocal 1.4
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
dnl PARTICULAR PURPOSE.
# serial 40 AC_PROG_LIBTOOL
AC_DEFUN(AC_PROG_LIBTOOL,
[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
# Save cache, so that ltconfig can load it
AC_CACHE_SAVE
# Actually configure libtool. ac_aux_dir is where install-sh is found.
CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
|| AC_MSG_ERROR([libtool configure failed])
# Reload cache, that may have been modified by ltconfig
AC_CACHE_LOAD
# This can be used to rebuild libtool when needed
LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
# Always use our own libtool.
LIBTOOL='$(SHELL) $(top_builddir)/libtool'
AC_SUBST(LIBTOOL)dnl
# Redirect the config.log output again, so that the ltconfig log is not
# clobbered by the next message.
exec 5>>./config.log
])
AC_DEFUN(AC_LIBTOOL_SETUP,
[AC_PREREQ(2.13)dnl
AC_REQUIRE([AC_ENABLE_SHARED])dnl
AC_REQUIRE([AC_ENABLE_STATIC])dnl
AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_REQUIRE([AC_CANONICAL_BUILD])dnl
AC_REQUIRE([AC_PROG_RANLIB])dnl
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_PROG_LD])dnl
AC_REQUIRE([AC_PROG_NM])dnl
AC_REQUIRE([AC_PROG_LN_S])dnl
dnl
case "$target" in
NONE) lt_target="$host" ;;
*) lt_target="$target" ;;
esac
# Check for any special flags to pass to ltconfig.
#
# the following will cause an existing older ltconfig to fail, so
# we ignore this at the expense of the cache file... Checking this
# will just take longer ... bummer!
#libtool_flags="--cache-file=$cache_file"
#
test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
[libtool_flags="$libtool_flags --enable-dlopen"])
ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
[libtool_flags="$libtool_flags --enable-win32-dll"])
AC_ARG_ENABLE(libtool-lock,
[ --disable-libtool-lock avoid locking (might break parallel builds)])
test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
# Some flags need to be propagated to the compiler or linker for good
# libtool support.
case "$lt_target" in
*-*-irix6*)
# Find out which ABI we are using.
echo '[#]line __oline__ "configure"' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
case "`/usr/bin/file conftest.o`" in
*32-bit*)
LD="${LD-ld} -32"
;;
*N32*)
LD="${LD-ld} -n32"
;;
*64-bit*)
LD="${LD-ld} -64"
;;
esac
fi
rm -rf conftest*
;;
*-*-sco3.2v5*)
# On SCO OpenServer 5, we need -belf to get full-featured binaries.
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -belf"
AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
[AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
if test x"$lt_cv_cc_needs_belf" != x"yes"; then
# this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
CFLAGS="$SAVE_CFLAGS"
fi
;;
ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
[*-*-cygwin* | *-*-mingw*)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false)
;;
])
esac
])
# AC_LIBTOOL_DLOPEN - enable checks for dlopen support
AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
# AC_ENABLE_SHARED - implement the --enable-shared flag
# Usage: AC_ENABLE_SHARED[(DEFAULT)]
# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
# `yes'.
AC_DEFUN(AC_ENABLE_SHARED, [dnl
define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
AC_ARG_ENABLE(shared,
changequote(<<, >>)dnl
<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
changequote([, ])dnl
[p=${PACKAGE-default}
case "$enableval" in
yes) enable_shared=yes ;;
no) enable_shared=no ;;
*)
enable_shared=no
# Look at the argument we got. We use all the common list separators.
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
for pkg in $enableval; do
if test "X$pkg" = "X$p"; then
enable_shared=yes
fi
done
IFS="$ac_save_ifs"
;;
esac],
enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
])
# AC_DISABLE_SHARED - set the default shared flag to --disable-shared
AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
AC_ENABLE_SHARED(no)])
# AC_ENABLE_STATIC - implement the --enable-static flag
# Usage: AC_ENABLE_STATIC[(DEFAULT)]
# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
# `yes'.
AC_DEFUN(AC_ENABLE_STATIC, [dnl
define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
AC_ARG_ENABLE(static,
changequote(<<, >>)dnl
<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
changequote([, ])dnl
[p=${PACKAGE-default}
case "$enableval" in
yes) enable_static=yes ;;
no) enable_static=no ;;
*)
enable_static=no
# Look at the argument we got. We use all the common list separators.
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
for pkg in $enableval; do
if test "X$pkg" = "X$p"; then
enable_static=yes
fi
done
IFS="$ac_save_ifs"
;;
esac],
enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
])
# AC_DISABLE_STATIC - set the default static flag to --disable-static
AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
AC_ENABLE_STATIC(no)])
# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
# `yes'.
AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
AC_ARG_ENABLE(fast-install,
changequote(<<, >>)dnl
<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
changequote([, ])dnl
[p=${PACKAGE-default}
case "$enableval" in
yes) enable_fast_install=yes ;;
no) enable_fast_install=no ;;
*)
enable_fast_install=no
# Look at the argument we got. We use all the common list separators.
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
for pkg in $enableval; do
if test "X$pkg" = "X$p"; then
enable_fast_install=yes
fi
done
IFS="$ac_save_ifs"
;;
esac],
enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
])
# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
AC_ENABLE_FAST_INSTALL(no)])
# AC_PROG_LD - find the path to the GNU or non-GNU linker
AC_DEFUN(AC_PROG_LD,
[AC_ARG_WITH(gnu-ld,
[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_REQUIRE([AC_CANONICAL_BUILD])dnl
ac_prog=ld
if test "$ac_cv_prog_gcc" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
AC_MSG_CHECKING([for ld used by GCC])
ac_prog=`($CC -print-prog-name=ld) 2>&5`
case "$ac_prog" in
# Accept absolute paths.
changequote(,)dnl
[\\/]* | [A-Za-z]:[\\/]*)
re_direlt='/[^/][^/]*/\.\./'
changequote([,])dnl
# Canonicalize the path of ld
ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
done
test -z "$LD" && LD="$ac_prog"
;;
"")
# If it fails, then pretend we aren't using GCC.
ac_prog=ld
;;
*)
# If it is relative, then search for the first ld in PATH.
with_gnu_ld=unknown
;;
esac
elif test "$with_gnu_ld" = yes; then
AC_MSG_CHECKING([for GNU ld])
else
AC_MSG_CHECKING([for non-GNU ld])
fi
AC_CACHE_VAL(ac_cv_path_LD,
[if test -z "$LD"; then
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
for ac_dir in $PATH; do
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
ac_cv_path_LD="$ac_dir/$ac_prog"
# Check to see if the program is GNU ld. I'd rather use --version,
# but apparently some GNU ld's only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
test "$with_gnu_ld" != no && break
else
test "$with_gnu_ld" != yes && break
fi
fi
done
IFS="$ac_save_ifs"
else
ac_cv_path_LD="$LD" # Let the user override the test with a path.
fi])
LD="$ac_cv_path_LD"
if test -n "$LD"; then
AC_MSG_RESULT($LD)
else
AC_MSG_RESULT(no)
fi
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
AC_PROG_LD_GNU
])
AC_DEFUN(AC_PROG_LD_GNU,
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
ac_cv_prog_gnu_ld=yes
else
ac_cv_prog_gnu_ld=no
fi])
])
# AC_PROG_NM - find the path to a BSD-compatible name lister
AC_DEFUN(AC_PROG_NM,
[AC_MSG_CHECKING([for BSD-compatible nm])
AC_CACHE_VAL(ac_cv_path_NM,
[if test -n "$NM"; then
# Let the user override the test.
ac_cv_path_NM="$NM"
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
# Check to see if the nm accepts a BSD-compat flag.
# Adding the `sed 1q' prevents false positives on HP-UX, which says:
# nm: unknown option "B" ignored
if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
ac_cv_path_NM="$ac_dir/nm -B"
break
elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
ac_cv_path_NM="$ac_dir/nm -p"
break
else
ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
continue # so that we can try to find one that supports BSD flags
fi
fi
done
IFS="$ac_save_ifs"
test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
fi])
NM="$ac_cv_path_NM"
AC_MSG_RESULT([$NM])
])
# AC_CHECK_LIBM - check for math library
AC_DEFUN(AC_CHECK_LIBM,
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
LIBM=
case "$lt_target" in
*-*-beos* | *-*-cygwin*)
# These system don't have libm
;;
*-ncr-sysv4.3*)
AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
;;
*)
AC_CHECK_LIB(m, main, LIBM="-lm")
;;
esac
])
# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
# the libltdl convenience library and INCLTDL to the include flags for
# the libltdl header and adds --enable-ltdl-convenience to the
# configure arguments. Note that LIBLTDL and INCLTDL are not
# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not
# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed
# with '${top_builddir}/' and INCLTDL will be prefixed with
# '${top_srcdir}/' (note the single quotes!). If your package is not
# flat and you're not using automake, define top_builddir and
# top_srcdir appropriately in the Makefiles.
AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
case "$enable_ltdl_convenience" in
no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
"") enable_ltdl_convenience=yes
ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
esac
LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
])
# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
# the libltdl installable library and INCLTDL to the include flags for
# the libltdl header and adds --enable-ltdl-install to the configure
# arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is
# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed
# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will
# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed
# with '${top_srcdir}/' (note the single quotes!). If your package is
# not flat and you're not using automake, define top_builddir and
# top_srcdir appropriately in the Makefiles.
# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
AC_CHECK_LIB(ltdl, main,
[test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
[if test x"$enable_ltdl_install" = xno; then
AC_MSG_WARN([libltdl not installed, but installation disabled])
else
enable_ltdl_install=yes
fi
])
if test x"$enable_ltdl_install" = x"yes"; then
ac_configure_args="$ac_configure_args --enable-ltdl-install"
LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
else
ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
LIBLTDL="-lltdl"
INCLTDL=
fi
])
dnl old names
AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
dnl This is just to silence aclocal about the macro not being used
ifelse([AC_DISABLE_FAST_INSTALL])dnl
# Do all the work for Automake. This macro actually does too much --
# some checks are only needed if your package does certain things.
# But this isn't really a big deal.
# serial 1
dnl Usage:
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
AC_DEFUN(AM_INIT_AUTOMAKE,
[AC_REQUIRE([AC_PROG_INSTALL])
PACKAGE=[$1]
AC_SUBST(PACKAGE)
VERSION=[$2]
AC_SUBST(VERSION)
dnl test to see if srcdir already configured
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
ifelse([$3],,
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
AC_REQUIRE([AM_SANITY_CHECK])
AC_REQUIRE([AC_ARG_PROGRAM])
dnl FIXME This is truly gross.
missing_dir=`cd $ac_aux_dir && pwd`
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
AC_REQUIRE([AC_PROG_MAKE_SET])])
#
# Check to make sure that the build environment is sane.
#
AC_DEFUN(AM_SANITY_CHECK,
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftestfile
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
if test "[$]*" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftestfile`
fi
if test "[$]*" != "X $srcdir/configure conftestfile" \
&& test "[$]*" != "X conftestfile $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "[$]2" = conftestfile
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
rm -f conftest*
AC_MSG_RESULT(yes)])
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
dnl The program must properly implement --version.
AC_DEFUN(AM_MISSING_PROG,
[AC_MSG_CHECKING(for working $2)
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if ($2 --version) < /dev/null > /dev/null 2>&1; then
$1=$2
AC_MSG_RESULT(found)
else
$1="$3/missing $2"
AC_MSG_RESULT(missing)
fi
AC_SUBST($1)])

48
config.cache Normal file
View File

@ -0,0 +1,48 @@
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs. It is not useful on other systems.
# If it contains results you don't want to keep, you may remove or edit it.
#
# By default, configure uses ./config.cache as the cache file,
# creating it if it does not exist already. You can give configure
# the --cache-file=FILE option to use a different cache file; that is
# what configure does when it calls configure scripts in
# subdirectories, so they share the cache.
# Giving --cache-file=/dev/null disables caching, for debugging configure.
# config.status only pays attention to the cache file if you give it the
# --recheck option to rerun configure.
#
ac_cv_c_const=${ac_cv_c_const=yes}
ac_cv_func_select=${ac_cv_func_select=yes}
ac_cv_func_socket=${ac_cv_func_socket=yes}
ac_cv_func_strdup=${ac_cv_func_strdup=yes}
ac_cv_func_strerror=${ac_cv_func_strerror=yes}
ac_cv_func_strtoul=${ac_cv_func_strtoul=yes}
ac_cv_func_vfork_works=${ac_cv_func_vfork_works=yes}
ac_cv_header_fcntl_h=${ac_cv_header_fcntl_h=yes}
ac_cv_header_stdc=${ac_cv_header_stdc=yes}
ac_cv_header_strings_h=${ac_cv_header_strings_h=yes}
ac_cv_header_sys_ioctl_h=${ac_cv_header_sys_ioctl_h=yes}
ac_cv_header_sys_time_h=${ac_cv_header_sys_time_h=yes}
ac_cv_header_sys_wait_h=${ac_cv_header_sys_wait_h=yes}
ac_cv_header_syslog_h=${ac_cv_header_syslog_h=yes}
ac_cv_header_time=${ac_cv_header_time=yes}
ac_cv_header_unistd_h=${ac_cv_header_unistd_h=yes}
ac_cv_header_vfork_h=${ac_cv_header_vfork_h=no}
ac_cv_path_LD=${ac_cv_path_LD=/usr/bin/ld}
ac_cv_path_NM=${ac_cv_path_NM='/usr/bin/nm -B'}
ac_cv_path_install=${ac_cv_path_install='/usr/bin/install -c'}
ac_cv_prog_AWK=${ac_cv_prog_AWK=gawk}
ac_cv_prog_CC=${ac_cv_prog_CC=gcc}
ac_cv_prog_CPP=${ac_cv_prog_CPP='gcc -E'}
ac_cv_prog_LN_S=${ac_cv_prog_LN_S='ln -s'}
ac_cv_prog_RANLIB=${ac_cv_prog_RANLIB=ranlib}
ac_cv_prog_cc_cross=${ac_cv_prog_cc_cross=no}
ac_cv_prog_cc_g=${ac_cv_prog_cc_g=yes}
ac_cv_prog_cc_works=${ac_cv_prog_cc_works=yes}
ac_cv_prog_gcc=${ac_cv_prog_gcc=yes}
ac_cv_prog_gcc_traditional=${ac_cv_prog_gcc_traditional=no}
ac_cv_prog_gnu_ld=${ac_cv_prog_gnu_ld=yes}
ac_cv_prog_make_make_set=${ac_cv_prog_make_make_set=yes}
ac_cv_type_pid_t=${ac_cv_type_pid_t=yes}
ac_cv_type_size_t=${ac_cv_type_size_t=yes}

65
config.h.in Normal file
View File

@ -0,0 +1,65 @@
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* Define to empty if the keyword does not work. */
#undef const
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
/* Define if you have <vfork.h>. */
#undef HAVE_VFORK_H
/* Define to `int' if <sys/types.h> doesn't define. */
#undef pid_t
/* Define to `unsigned' if <sys/types.h> doesn't define. */
#undef size_t
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define vfork as fork if vfork does not work. */
#undef vfork
/* Define if you have the select function. */
#undef HAVE_SELECT
/* Define if you have the socket function. */
#undef HAVE_SOCKET
/* Define if you have the strdup function. */
#undef HAVE_STRDUP
/* Define if you have the strerror function. */
#undef HAVE_STRERROR
/* Define if you have the strtoul function. */
#undef HAVE_STRTOUL
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H
/* Define if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define if you have the <syslog.h> header file. */
#undef HAVE_SYSLOG_H
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Name of package */
#undef PACKAGE
/* Version number of package */
#undef VERSION

84
config.log Normal file
View File

@ -0,0 +1,84 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
configure:541: checking for gawk
configure:573: checking for gcc
configure:686: checking whether the C compiler (gcc ) works
configure:702: gcc -o conftest conftest.c 1>&5
configure:728: checking whether the C compiler (gcc ) is a cross-compiler
configure:733: checking whether we are using GNU C
configure:761: checking whether gcc accepts -g
configure:823: checking for a BSD compatible install
configure:876: checking whether ln -s works
configure:973: checking host system type
configure:994: checking build system type
configure:1014: checking for ranlib
configure:1053: checking for ld used by GCC
configure:1115: checking if the linker (/usr/bin/ld) is GNU ld
configure:1131: checking for BSD-compatible nm
ltconfig:603: checking for object suffix
ltconfig:604: gcc -c -g -O2 conftest.c 1>&5
ltconfig:629: checking for executable suffix
ltconfig:630: gcc -o conftest -g -O2 conftest.c 1>&5
ltconfig:776: checking if gcc PIC flag -fPIC works
ltconfig:777: gcc -c -g -O2 -fPIC -DPIC conftest.c 1>&5
ltconfig:829: checking if gcc supports -c -o file.o
ltconfig:830: gcc -c -g -O2 -o out/conftest2.o conftest.c 1>&5
ltconfig:862: checking if gcc supports -c -o file.lo
ltconfig:863: gcc -c -g -O2 -c -o conftest.lo conftest.c 1>&5
ltconfig:914: checking if gcc supports -fno-rtti -fno-exceptions
ltconfig:915: gcc -c -g -O2 -fno-rtti -fno-exceptions -c conftest.c conftest.c 1>&5
ltconfig:958: checking if gcc static flag -static works
ltconfig:959: gcc -o conftest -g -O2 -static conftest.c 1>&5
GNU ld version 2.10.91 (with BFD 2.10.91.0.2)
ltconfig:1653: checking if global_symbol_pipe works
ltconfig:1654: gcc -c -g -O2 conftest.c 1>&5
ltconfig:1657: eval "/usr/bin/nm -B conftest.o | sed -n -e 's/^.*[ ]\([ABCDGISTW]\)[ ][ ]*\(\)\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2\3 \3/p' > conftest.nm"
ltconfig:1709: gcc -o conftest -g -O2 -fno-builtin -fno-rtti -fno-exceptions conftest.c conftstm.o 1>&5
ltconfig:603: checking for object suffix
ltconfig:604: gcc -c -g -O2 conftest.c 1>&5
ltconfig:629: checking for executable suffix
ltconfig:630: gcc -o conftest -g -O2 conftest.c 1>&5
ltconfig:776: checking if gcc PIC flag -fPIC works
ltconfig:777: gcc -c -g -O2 -fPIC -DPIC conftest.c 1>&5
ltconfig:829: checking if gcc supports -c -o file.o
ltconfig:830: gcc -c -g -O2 -o out/conftest2.o conftest.c 1>&5
ltconfig:862: checking if gcc supports -c -o file.lo
ltconfig:863: gcc -c -g -O2 -c -o conftest.lo conftest.c 1>&5
ltconfig:914: checking if gcc supports -fno-rtti -fno-exceptions
ltconfig:915: gcc -c -g -O2 -fno-rtti -fno-exceptions -c conftest.c conftest.c 1>&5
ltconfig:958: checking if gcc static flag -static works
ltconfig:959: gcc -o conftest -g -O2 -static conftest.c 1>&5
GNU ld version 2.10.91 (with BFD 2.10.91.0.2)
ltconfig:1653: checking if global_symbol_pipe works
ltconfig:1654: gcc -c -g -O2 conftest.c 1>&5
ltconfig:1657: eval "/usr/bin/nm -B conftest.o | sed -n -e 's/^.*[ ]\([ABCDGISTW]\)[ ][ ]*\(\)\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2\3 \3/p' > conftest.nm"
ltconfig:1709: gcc -o conftest -g -O2 -fno-builtin -fno-rtti -fno-exceptions conftest.c conftstm.o 1>&5
configure:1417: checking how to run the C preprocessor
configure:1497: checking for ANSI C header files
configure:1601: checking for sys/wait.h that is POSIX.1 compatible
configure:1646: checking for fcntl.h
configure:1646: checking for strings.h
configure:1646: checking for sys/ioctl.h
configure:1646: checking for sys/time.h
configure:1646: checking for syslog.h
configure:1646: checking for unistd.h
configure:1684: checking for working const
configure:1759: checking for size_t
configure:1792: checking whether time.h and sys/time.h may both be included
configure:1829: checking whether gcc needs -traditional
configure:1875: checking for pid_t
configure:1909: checking for vfork.h
configure:1944: checking for working vfork
configure:2120: checking for select
configure:2120: checking for socket
configure:2120: checking for strdup
configure:2120: checking for strerror
configure:2120: checking for strtoul
configure:2174: checking whether build environment is sane
configure:2231: checking whether make sets ${MAKE}
configure:2277: checking for working aclocal
configure:2290: checking for working autoconf
configure:2303: checking for working automake
configure:2316: checking for working autoheader
configure:2329: checking for working makeinfo

182
config.status Executable file
View File

@ -0,0 +1,182 @@
#! /bin/sh
# Generated automatically by configure.
# Run this file to recreate the current configuration.
# This directory was configured as follows,
# on host oslo:
#
# ./configure
#
# Compiler output produced by configure, useful for debugging
# configure, is in ./config.log if it exists.
ac_cs_usage="Usage: ./config.status [--recheck] [--version] [--help]"
for ac_option
do
case "$ac_option" in
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
echo "running ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion"
exec ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion ;;
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
echo "./config.status generated by autoconf version 2.13"
exit 0 ;;
-help | --help | --hel | --he | --h)
echo "$ac_cs_usage"; exit 0 ;;
*) echo "$ac_cs_usage"; exit 1 ;;
esac
done
ac_given_srcdir=.
ac_given_INSTALL="/usr/bin/install -c"
trap 'rm -fr doc/Makefile po/Makefile intl/Makefile Makefile tests/Makefile src/Makefile gtp/Makefile ggsn/Makefile sgsnemu/Makefile conftest*; exit 1' 1 2 15
# Protect against being on the right side of a sed subst in config.status.
sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\&%]/\\&/g;
s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF
/^[ ]*VPATH[ ]*=[^:]*$/d
s%@SHELL@%/bin/sh%g
s%@CFLAGS@%-g -O2%g
s%@CPPFLAGS@%%g
s%@CXXFLAGS@%%g
s%@FFLAGS@%%g
s%@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\" %g
s%@LDFLAGS@%%g
s%@LIBS@%%g
s%@exec_prefix@%${prefix}%g
s%@prefix@%/usr/local%g
s%@program_transform_name@%s,x,x,%g
s%@bindir@%${exec_prefix}/bin%g
s%@sbindir@%${exec_prefix}/sbin%g
s%@libexecdir@%${exec_prefix}/libexec%g
s%@datadir@%${prefix}/share%g
s%@sysconfdir@%${prefix}/etc%g
s%@sharedstatedir@%${prefix}/com%g
s%@localstatedir@%${prefix}/var%g
s%@libdir@%${exec_prefix}/lib%g
s%@includedir@%${prefix}/include%g
s%@oldincludedir@%/usr/include%g
s%@infodir@%${prefix}/info%g
s%@mandir@%${prefix}/man%g
s%@AWK@%gawk%g
s%@CC@%gcc%g
s%@INSTALL_PROGRAM@%${INSTALL}%g
s%@INSTALL_SCRIPT@%${INSTALL_PROGRAM}%g
s%@INSTALL_DATA@%${INSTALL} -m 644%g
s%@LN_S@%ln -s%g
s%@host@%i686-pc-linux-gnu%g
s%@host_alias@%i686-pc-linux%g
s%@host_cpu@%i686%g
s%@host_vendor@%pc%g
s%@host_os@%linux-gnu%g
s%@build@%i686-pc-linux-gnu%g
s%@build_alias@%i686-pc-linux%g
s%@build_cpu@%i686%g
s%@build_vendor@%pc%g
s%@build_os@%linux-gnu%g
s%@RANLIB@%ranlib%g
s%@LIBTOOL@%$(SHELL) $(top_builddir)/libtool%g
s%@CPP@%gcc -E%g
s%@PACKAGE@%OpenGGSN%g
s%@VERSION@%0.5%g
s%@ACLOCAL@%aclocal%g
s%@AUTOCONF@%autoconf%g
s%@AUTOMAKE@%automake%g
s%@AUTOHEADER@%autoheader%g
s%@MAKEINFO@%makeinfo%g
s%@SET_MAKE@%%g
CEOF
# Split the substitutions into bite-sized pieces for seds with
# small command number limits, like on Digital OSF/1 and HP-UX.
ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
ac_file=1 # Number of current file.
ac_beg=1 # First line for current file.
ac_end=$ac_max_sed_cmds # Line after last line for current file.
ac_more_lines=:
ac_sed_cmds=""
while $ac_more_lines; do
if test $ac_beg -gt 1; then
sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
else
sed "${ac_end}q" conftest.subs > conftest.s$ac_file
fi
if test ! -s conftest.s$ac_file; then
ac_more_lines=false
rm -f conftest.s$ac_file
else
if test -z "$ac_sed_cmds"; then
ac_sed_cmds="sed -f conftest.s$ac_file"
else
ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
fi
ac_file=`expr $ac_file + 1`
ac_beg=$ac_end
ac_end=`expr $ac_end + $ac_max_sed_cmds`
fi
done
if test -z "$ac_sed_cmds"; then
ac_sed_cmds=cat
fi
CONFIG_FILES=${CONFIG_FILES-"doc/Makefile po/Makefile intl/Makefile Makefile tests/Makefile src/Makefile gtp/Makefile ggsn/Makefile sgsnemu/Makefile"}
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case "$ac_file" in
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
*) ac_file_in="${ac_file}.in" ;;
esac
# Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
# Remove last slash and all that follows it. Not all systems have dirname.
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
# The file is in a subdirectory.
test ! -d "$ac_dir" && mkdir "$ac_dir"
ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
# A "../" for each directory in $ac_dir_suffix.
ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
else
ac_dir_suffix= ac_dots=
fi
case "$ac_given_srcdir" in
.) srcdir=.
if test -z "$ac_dots"; then top_srcdir=.
else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
/*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
*) # Relative path.
srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
top_srcdir="$ac_dots$ac_given_srcdir" ;;
esac
case "$ac_given_INSTALL" in
[/$]*) INSTALL="$ac_given_INSTALL" ;;
*) INSTALL="$ac_dots$ac_given_INSTALL" ;;
esac
echo creating "$ac_file"
rm -f "$ac_file"
configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
case "$ac_file" in
*Makefile*) ac_comsub="1i\\
# $configure_input" ;;
*) ac_comsub= ;;
esac
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
sed -e "$ac_comsub
s%@configure_input@%$configure_input%g
s%@srcdir@%$srcdir%g
s%@top_srcdir@%$top_srcdir%g
s%@INSTALL@%$INSTALL%g
" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
fi; done
rm -f conftest.s*
exit 0

2625
configure vendored Executable file

File diff suppressed because it is too large Load Diff

32
configure.in Normal file
View File

@ -0,0 +1,32 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(gtp/gtp.c ggsn/ggsn.c sgsnemu/sgsnemu.c)
dnl Checks for programs.
AC_PROG_AWK
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_LIBTOOL
AM_PROG_LIBTOOL
dnl Checks for libraries.
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h strings.h sys/ioctl.h sys/time.h syslog.h unistd.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_HEADER_TIME
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_VFORK
AC_CHECK_FUNCS(select socket strdup strerror strtoul)
AM_INIT_AUTOMAKE(OpenGGSN,0.5)
AC_OUTPUT(doc/Makefile po/Makefile intl/Makefile Makefile tests/Makefile src/Makefile gtp/Makefile ggsn/Makefile sgsnemu/Makefile)

27
configure.scan Normal file
View File

@ -0,0 +1,27 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/cmdline.c)
dnl Checks for programs.
AC_PROG_AWK
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
dnl Checks for libraries.
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h strings.h sys/ioctl.h sys/time.h syslog.h unistd.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_HEADER_TIME
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_VFORK
AC_CHECK_FUNCS(select socket strdup strerror strtoul)
AC_OUTPUT(doc/Makefile po/Makefile intl/Makefile Makefile tests/Makefile src/Makefile)

0
doc/Makefile Normal file
View File

69
examples/ggsn.conf Normal file
View File

@ -0,0 +1,69 @@
##############################################################################
#
# Sample ggsn configuration file
#
##############################################################################
# TAG: fg
# Include this flag if process is to run in the foreground
#
fg
# TAG: debug
# Include this flag to include debug information.
#debug
# TAG: conf
# Configuration file to use. This file is the configuration file,
# so changing this parameter in the configuration file does not make
# sense. Use it on the command line instead.
# TAG: pidfile
# File to store information about the process id of the program.
# The program must have write access to this file/directory.
#pidfile /var/run/ggsn.pid
# TAG: statedir
# Directory to use for nonvolatile storage.
# The program must have write access to this directory.
#pidfile /var/lib/ggsn/
# TAG: listen
# Specifies the local IP address to listen to
listen 10.0.0.240
# TAG: net
# IP network address of external packet data network
# Used to allocate dynamic IP addresses and set up routing.
#net 192.168.0.0
# TAG: mask
# IP network mask of external packet data network
# Used to allocate dynamic IP addresses and set up routing.
#mask 255.255.255.0
# TAG: timelimit
# Exit after timelimit seconds.
# Setting timelimit to zero will cause the program not to exit.
#timelimit 0
# TAG: qos
# Use of this tag is EXPERIMENTAL
# Requested Quality of Service used when run in client mode.
# 3 bytes corresponding to ????
#qos 0x0b921f
# TAG: apn
# Use of this tag is EXPERIMENTAL
# Access point name to connect to when run in client mode.
#apn internet

102
examples/sgsnemu.conf Normal file
View File

@ -0,0 +1,102 @@
##############################################################################
#
# Sample sgsnemu configuration file
#
##############################################################################
# TAG: fg
# Include this flag if process is to run in the foreground
#
fg
# TAG: debug
# Include this flag to include debug information.
#debug
# TAG: conf
# Configuration file to use. This file is the configuration file,
# so changing this parameter in the configuration file does not make
# sense. Use it on the command line instead.
# TAG: pidfile
# File to store information about the pricess id of the program.
# The program must have write access to this file/directory.
#pidfile ./sgsnemu.pid
# TAG: statedir
# Directory to use for nonvolatile storage.
# The program must have write access to this directory.
#pidfile ./sgsnemu.pid
# TAG: dns
# DNS server to use for ns lookups.
# If this tag is not set the system default DNS will be used.
#pidfile ./sgsnemu.pid
# TAG: listen
# Specifies the local IP address to listen to
listen 10.0.0.220
# TAG: remote
# Specifies the remote IP address to connect to
# If DNS is setup correctly it should be possible to specify the
# access point name (APN) as the remote address.
remote 10.0.0.240
# TAG: net
# IP network address of external packet data network
# This tag is used for setting up routing at the emulator
#net 192.168.0.0
# TAG: mask
# IP network mask of external packet data network
# This tag is used for setting up routing at the emulator
#mask 255.255.255.0
# TAG: contexts
# Use of this tag is EXPERIMENTAL
# Number of contexts to establish from the emulator to the ggsn.
# Set this tag to zero to not establish any contexts.
#contexts 1
# TAG: static
# Use of this tag is EXPERIMENTAL
# Use this flag if you do not want to set dynamic tun interfaces.
# If this flag is set a single network interface is established.
#contexts 1
# TAG: timelimit
# Disconnect contexts after timelimit seconds, and exit the program.
# Setting timelimit to zero will cause the program not to disconnect.
#timelimit 0
# TAG: apn
# Access point name to connect to when run in client mode.
#apn internet
# TAG: imsi
# IMSI number used when run in client mode.
#imsi 2400101234567890
# TAG: msisdn
# MSISDN number used when run in client mode.
#msisdn 46702123456
# TAG: qos
# Requested Quality of Service used when run in client mode.
# 3 bytes corresponding to ????
#qos 0x0b921f
# TAG: uid
# User ID used when run in client mode.
#uid mig
# TAG: pwd
# Password used when run in client mode.
#pwd hemlig

33
ggsn/.deps/cmdline.P Normal file
View File

@ -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 :

146
ggsn/.deps/ggsn.P Normal file
View File

@ -0,0 +1,146 @@
ggsn.o: ggsn.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 tun.h \
../gtp/pdp.h ../gtp/gtp.h cmdline.h
ggsn.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 :
tun.h :
../gtp/pdp.h :
../gtp/gtp.h :
cmdline.h :

33
ggsn/.deps/ggsnopt.P Normal file
View File

@ -0,0 +1,33 @@
ggsnopt.o: ggsnopt.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 ggsnopt.h
ggsnopt.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 :
ggsnopt.h :

108
ggsn/.deps/tun.P Normal file
View File

@ -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 :

343
ggsn/Makefile Normal file
View File

@ -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 = ggsn
CFLAGS = -O2 -fno-builtin -Wall -ansi -DSBINDIR='"$(sbindir)"' -lgtp
ggsn_SOURCES = ggsn.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 =
ggsn_OBJECTS = ggsn.o tun.o cmdline.o
ggsn_LDADD = $(LDADD)
ggsn_DEPENDENCIES =
ggsn_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/ggsn.P .deps/tun.P
SOURCES = $(ggsn_SOURCES)
OBJECTS = $(ggsn_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 ggsn/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:
ggsn: $(ggsn_OBJECTS) $(ggsn_DEPENDENCIES)
@rm -f ggsn
$(LINK) $(ggsn_LDFLAGS) $(ggsn_OBJECTS) $(ggsn_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 = ggsn
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 ggsn/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
# 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:

11
ggsn/Makefile.am Normal file
View File

@ -0,0 +1,11 @@
bin_PROGRAMS = ggsn
CFLAGS = -O2 -fno-builtin -Wall -ansi -DSBINDIR='"$(sbindir)"' -lgtp
ggsn_SOURCES = ggsn.c tun.c tun.h cmdline.c cmdline.h
cmdline.c: cmdline.ggo
gengetopt < cmdline.ggo --unamed-opts

343
ggsn/Makefile.in Normal file
View File

@ -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 = ggsn
CFLAGS = -O2 -fno-builtin -Wall -ansi -DSBINDIR='"$(sbindir)"' -lgtp
ggsn_SOURCES = ggsn.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@
ggsn_OBJECTS = ggsn.o tun.o cmdline.o
ggsn_LDADD = $(LDADD)
ggsn_DEPENDENCIES =
ggsn_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/ggsn.P .deps/tun.P
SOURCES = $(ggsn_SOURCES)
OBJECTS = $(ggsn_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 ggsn/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:
ggsn: $(ggsn_OBJECTS) $(ggsn_DEPENDENCIES)
@rm -f ggsn
$(LINK) $(ggsn_LDFLAGS) $(ggsn_OBJECTS) $(ggsn_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 = ggsn
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 ggsn/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
# 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:

529
ggsn/cmdline.c Normal file
View File

@ -0,0 +1,529 @@
/*
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 (default='/etc/ggsn.conf')\n");
printf(" --pidfile=STRING Filename of process id file (default='/var/run/ggsn.pid')\n");
printf(" --statedir=STRING Directory of nonvolatile data (default='/var/lib/ggsn/')\n");
printf(" -lSTRING --listen=STRING Local interface\n");
printf(" -nSTRING --net=STRING Network (default='192.168.0.0')\n");
printf(" --mask=STRING Network mask (default='255.255.255.0')\n");
printf(" --timelimit=INT Exit after timelimit seconds (default='0')\n");
printf(" -aSTRING --apn=STRING Access point name (default='internet')\n");
printf(" -qINT --qos=INT Requested quality of service (default='0x0b921f')\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->listen_given = 0 ;
args_info->net_given = 0 ;
args_info->mask_given = 0 ;
args_info->timelimit_given = 0 ;
args_info->apn_given = 0 ;
args_info->qos_given = 0 ;
#define clear_args() { \
args_info->fg_flag = 0;\
args_info->debug_flag = 0;\
args_info->conf_arg = strdup("/etc/ggsn.conf") ;\
args_info->pidfile_arg = strdup("/var/run/ggsn.pid") ;\
args_info->statedir_arg = strdup("/var/lib/ggsn/") ;\
args_info->listen_arg = NULL; \
args_info->net_arg = strdup("192.168.0.0") ;\
args_info->mask_arg = strdup("255.255.255.0") ;\
args_info->timelimit_arg = 0 ;\
args_info->apn_arg = strdup("internet") ;\
args_info->qos_arg = 0x0b921f ;\
}
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 },
{ "listen", 1, NULL, 'l' },
{ "net", 1, NULL, 'n' },
{ "mask", 1, NULL, 0 },
{ "timelimit", 1, NULL, 0 },
{ "apn", 1, NULL, 'a' },
{ "qos", 1, NULL, 'q' },
{ NULL, 0, NULL, 0 }
};
c = getopt_long (argc, argv, "hVfdc:l:n:a:q:", 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 '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 '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 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;
}
/* 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;
}
/* 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, "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, "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, "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, "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;
}
/* 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;
}

29
ggsn/cmdline.ggo Normal file
View File

@ -0,0 +1,29 @@
# 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 default="/etc/ggsn.conf" no
option "pidfile" - "Filename of process id file" string default="/var/run/ggsn.pid" no
option "statedir" - "Directory of nonvolatile data" string default="/var/lib/ggsn/" no
option "listen" l "Local interface" 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 "timelimit" - "Exit after timelimit seconds" int default="0" no
option "apn" a "Access point name" string default="internet" no
option "qos" q "Requested quality of service" int default="0x0b921f" no

61
ggsn/cmdline.h Normal file
View File

@ -0,0 +1,61 @@
/* 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 (default='/etc/ggsn.conf'). */
char * pidfile_arg; /* Filename of process id file (default='/var/run/ggsn.pid'). */
char * statedir_arg; /* Directory of nonvolatile data (default='/var/lib/ggsn/'). */
char * listen_arg; /* Local interface. */
char * net_arg; /* Network (default='192.168.0.0'). */
char * mask_arg; /* Network mask (default='255.255.255.0'). */
int timelimit_arg; /* Exit after timelimit seconds (default='0'). */
char * apn_arg; /* Access point name (default='internet'). */
int qos_arg; /* Requested quality of service (default='0x0b921f'). */
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 listen_given ; /* Whether listen was given. */
int net_given ; /* Whether net was given. */
int mask_given ; /* Whether mask was given. */
int timelimit_given ; /* Whether timelimit was given. */
int apn_given ; /* Whether apn was given. */
int qos_given ; /* Whether qos 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 */

424
ggsn/ggsn.c Normal file
View File

@ -0,0 +1,424 @@
/*
* 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):
*
*/
/* ggsn.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 <time.h>
#include "tun.h"
#include "../gtp/pdp.h"
#include "../gtp/gtp.h"
#include "cmdline.h"
int maxfd = 0; /* For select() */
int tun_fd = -1; /* Network file descriptor */
struct tun_t *tun; /* TUN instance */
struct in_addr net, mask; /* Network interface */
int debug; /* Print debug output */
/* 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 encaps_printf(void *p, void *packet, unsigned len)
{
int i;
if (debug) {
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");
}
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_;
if (debug) {
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) {
pdp_ipdel(pdp);
return 0;
}
int create_context(struct pdp_t *pdp) {
if (debug) 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 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 encaps_gtp(void *gsn, struct tun_t *tun, void *pack, unsigned len) {
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+16, 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 {
if (debug) 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;
struct hostent *host;
struct in_addr listen;
int gtpfd = -1; /* Network file descriptor */
struct gsn_t *gsn; /* GSN instance */
fd_set fds; /* For select() */
struct timeval idleTime; /* How long to select() */
int i; /* for loop */
struct ul_t qos, apn;
unsigned char qosh[3], apnh[256];
int timelimit; /* Number of seconds to be connected */
int starttime; /* Time program was started */
/* 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("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("qos: %#08x\n", args_info.qos_arg);
printf("apn: %s\n", args_info.apn_arg);
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("timelimit: %d\n", args_info.timelimit_arg);
}
/* Try out our new parser */
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("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("qos: %#08x\n", args_info.qos_arg);
printf("apn: %s\n", args_info.apn_arg);
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("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. */
/* Is this really needed ? */
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);
}
/* 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);
return 1;
}
else {
memcpy(&listen.s_addr, host->h_addr, host->h_length);
}
}
else {
listen.s_addr = htonl(INADDR_ANY);
}
/* 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);
return 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);
return 1;
}
}
/* Timelimit */
timelimit = args_info.timelimit_arg;
starttime = time(NULL);
/* 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;
/* 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);
if (debug) printf("gtpclient: Initialising GTP tunnel\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_create_context(gsn, create_context);
create_tun();
/******************************************************************/
/* Main select loop */
/******************************************************************/
while (((starttime + timelimit) > time(NULL)) || (0 == timelimit)) {
FD_ZERO(&fds);
if (tun_fd != -1) FD_SET(tun_fd, &fds);
if (gtpfd != -1) FD_SET(gtpfd, &fds);
gtp_retranstimeout(gsn, &idleTime);
switch (select(maxfd + 1, &fds, NULL, NULL, &idleTime)) {
case -1: /* Error with select() *
if (errno != EINTR)
syslog(LOG_ERR, "CTRL: Error with select(), quitting");
*goto leave_clear_call;*/
syslog(LOG_ERR, "GGSN: select = -1");
break;
case 0:
gtp_retrans(gsn); /* Only retransmit if nothing else */
break;
default:
break;
}
if (tun_fd != -1 && FD_ISSET(tun_fd, &fds) &&
tun_decaps(tun, encaps_gtp, gsn) < 0) {
syslog(LOG_ERR, "TUN read failed (fd)=(%d)", tun_fd);
}
if (gtpfd != -1 && FD_ISSET(gtpfd, &fds) &&
gtp_decaps(gsn) < 0) {
syslog(LOG_ERR, "GTP read failed (gre)=(%d)", gtpfd);
}
}
gtp_free(gsn);
return 1;
}

128
ggsn/tun.c Normal file
View File

@ -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);
}

48
ggsn/tun.h Normal file
View File

@ -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 */

111
gtp/.deps/gtp.P Normal file
View File

@ -0,0 +1,111 @@
gtp.lo gtp.o : gtp.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/bits/pthreadtypes.h \
/usr/include/bits/sched.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/bits/waitflags.h \
/usr/include/bits/waitstatus.h /usr/include/endian.h \
/usr/include/bits/endian.h /usr/include/xlocale.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/alloca.h /usr/include/sys/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/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/wordsize.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/in.h \
/usr/include/bits/byteswap.h /usr/include/arpa/inet.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/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 \
pdp.h gtp.h gtpie.h queue.h
gtp.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/bits/pthreadtypes.h :
/usr/include/bits/sched.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/bits/waitflags.h :
/usr/include/bits/waitstatus.h :
/usr/include/endian.h :
/usr/include/bits/endian.h :
/usr/include/xlocale.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/alloca.h :
/usr/include/sys/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/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/wordsize.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/in.h :
/usr/include/bits/byteswap.h :
/usr/include/arpa/inet.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/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 :
pdp.h :
gtp.h :
gtpie.h :
queue.h :

52
gtp/.deps/gtpie.P Normal file
View File

@ -0,0 +1,52 @@
gtpie.lo gtpie.o : gtpie.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/sys/types.h /usr/include/time.h /usr/include/netinet/in.h \
/usr/include/stdint.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/sockaddr.h \
/usr/include/asm/socket.h /usr/include/asm/sockios.h \
/usr/include/bits/in.h /usr/include/endian.h /usr/include/bits/endian.h \
/usr/include/bits/byteswap.h /usr/include/string.h \
/usr/include/bits/string.h /usr/include/bits/string2.h gtpie.h
gtpie.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/sys/types.h :
/usr/include/time.h :
/usr/include/netinet/in.h :
/usr/include/stdint.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/sockaddr.h :
/usr/include/asm/socket.h :
/usr/include/asm/sockios.h :
/usr/include/bits/in.h :
/usr/include/endian.h :
/usr/include/bits/endian.h :
/usr/include/bits/byteswap.h :
/usr/include/string.h :
/usr/include/bits/string.h :
/usr/include/bits/string2.h :
gtpie.h :

3
gtp/.deps/lookupa.P Normal file
View File

@ -0,0 +1,3 @@
lookupa.lo lookupa.o : lookupa.c lookupa.h
lookupa.c :
lookupa.h :

53
gtp/.deps/pdp.P Normal file
View File

@ -0,0 +1,53 @@
pdp.lo pdp.o : pdp.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/sys/types.h /usr/include/time.h /usr/include/netinet/in.h \
/usr/include/stdint.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/sockaddr.h \
/usr/include/asm/socket.h /usr/include/asm/sockios.h \
/usr/include/bits/in.h /usr/include/endian.h /usr/include/bits/endian.h \
/usr/include/bits/byteswap.h /usr/include/string.h \
/usr/include/bits/string.h /usr/include/bits/string2.h pdp.h lookupa.h
pdp.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/sys/types.h :
/usr/include/time.h :
/usr/include/netinet/in.h :
/usr/include/stdint.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/sockaddr.h :
/usr/include/asm/socket.h :
/usr/include/asm/sockios.h :
/usr/include/bits/in.h :
/usr/include/endian.h :
/usr/include/bits/endian.h :
/usr/include/bits/byteswap.h :
/usr/include/string.h :
/usr/include/bits/string.h :
/usr/include/bits/string2.h :
pdp.h :
lookupa.h :

64
gtp/.deps/queue.P Normal file
View File

@ -0,0 +1,64 @@
queue.lo queue.o : queue.c /usr/include/stdlib.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/stdio.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/sys/types.h /usr/include/time.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/netinet/in.h /usr/include/stdint.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/sockaddr.h \
/usr/include/asm/socket.h /usr/include/asm/sockios.h \
/usr/include/bits/in.h /usr/include/endian.h /usr/include/bits/endian.h \
/usr/include/bits/byteswap.h /usr/include/string.h \
/usr/include/bits/string.h /usr/include/bits/string2.h pdp.h gtp.h \
queue.h
queue.c :
/usr/include/stdlib.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/stdio.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/sys/types.h :
/usr/include/time.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/netinet/in.h :
/usr/include/stdint.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/sockaddr.h :
/usr/include/asm/socket.h :
/usr/include/asm/sockios.h :
/usr/include/bits/in.h :
/usr/include/endian.h :
/usr/include/bits/endian.h :
/usr/include/bits/byteswap.h :
/usr/include/string.h :
/usr/include/bits/string.h :
/usr/include/bits/string2.h :
pdp.h :
gtp.h :
queue.h :

339
gtp/Makefile Normal file
View File

@ -0,0 +1,339 @@
# 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
lib_LTLIBRARIES = libgtp.la
CFLAGS = -O2 -fno-builtin -Wall -ansi -DSBINDIR='"$(sbindir)"'
libgtp_la_SOURCES = gtp.c gtp.h gtpie.c gtpie.h pdp.c pdp.h lookupa.c lookupa.h queue.c queue.h
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(lib_LTLIBRARIES)
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 =
libgtp_la_LDFLAGS =
libgtp_la_LIBADD =
libgtp_la_OBJECTS = gtp.lo gtpie.lo pdp.lo lookupa.lo queue.lo
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/gtp.P .deps/gtpie.P .deps/lookupa.P .deps/pdp.P \
.deps/queue.P
SOURCES = $(libgtp_la_SOURCES)
OBJECTS = $(libgtp_la_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 gtp/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-libLTLIBRARIES:
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
distclean-libLTLIBRARIES:
maintainer-clean-libLTLIBRARIES:
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(libdir)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
list='$(lib_LTLIBRARIES)'; for p in $$list; do \
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
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:
libgtp.la: $(libgtp_la_OBJECTS) $(libgtp_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libgtp_la_LDFLAGS) $(libgtp_la_OBJECTS) $(libgtp_la_LIBADD) $(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 = gtp
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 gtp/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-libLTLIBRARIES
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-libLTLIBRARIES
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir)
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-libLTLIBRARIES mostlyclean-compile \
mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \
clean-depend clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-libLTLIBRARIES distclean-compile \
distclean-libtool distclean-tags distclean-depend \
distclean-generic clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-libLTLIBRARIES \
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-libLTLIBRARIES distclean-libLTLIBRARIES \
clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
uninstall-libLTLIBRARIES install-libLTLIBRARIES 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
# 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:

9
gtp/Makefile.am Normal file
View File

@ -0,0 +1,9 @@
lib_LTLIBRARIES = libgtp.la
CFLAGS = -O2 -fno-builtin -Wall -ansi -DSBINDIR='"$(sbindir)"'
libgtp_la_SOURCES = gtp.c gtp.h gtpie.c gtpie.h pdp.c pdp.h lookupa.c lookupa.h queue.c queue.h

339
gtp/Makefile.in Normal file
View File

@ -0,0 +1,339 @@
# 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@
lib_LTLIBRARIES = libgtp.la
CFLAGS = -O2 -fno-builtin -Wall -ansi -DSBINDIR='"$(sbindir)"'
libgtp_la_SOURCES = gtp.c gtp.h gtpie.c gtpie.h pdp.c pdp.h lookupa.c lookupa.h queue.c queue.h
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(lib_LTLIBRARIES)
DEFS = @DEFS@ -I. -I$(srcdir)
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
libgtp_la_LDFLAGS =
libgtp_la_LIBADD =
libgtp_la_OBJECTS = gtp.lo gtpie.lo pdp.lo lookupa.lo queue.lo
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/gtp.P .deps/gtpie.P .deps/lookupa.P .deps/pdp.P \
.deps/queue.P
SOURCES = $(libgtp_la_SOURCES)
OBJECTS = $(libgtp_la_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 gtp/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-libLTLIBRARIES:
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
distclean-libLTLIBRARIES:
maintainer-clean-libLTLIBRARIES:
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(libdir)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
list='$(lib_LTLIBRARIES)'; for p in $$list; do \
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
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:
libgtp.la: $(libgtp_la_OBJECTS) $(libgtp_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libgtp_la_LDFLAGS) $(libgtp_la_OBJECTS) $(libgtp_la_LIBADD) $(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 = gtp
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 gtp/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-libLTLIBRARIES
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-libLTLIBRARIES
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir)
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-libLTLIBRARIES mostlyclean-compile \
mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \
clean-depend clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-libLTLIBRARIES distclean-compile \
distclean-libtool distclean-tags distclean-depend \
distclean-generic clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-libLTLIBRARIES \
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-libLTLIBRARIES distclean-libLTLIBRARIES \
clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
uninstall-libLTLIBRARIES install-libLTLIBRARIES 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
# 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:

1917
gtp/gtp.c Normal file

File diff suppressed because it is too large Load Diff

339
gtp/gtp.h Normal file
View File

@ -0,0 +1,339 @@
/*
* 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 _GTP_H
#define _GTP_H
#define GTP0_PORT 3386
#define GTP1C_PORT 2123
#define GTP1U_PORT 2152
#define PACKET_MAX 8196
#define GTP_MAX 0xffff /* TODO: Choose right number */
#define GTP0_HEADER_SIZE 20
#define GTP1_HEADER_SIZE_SHORT 8
#define GTP1_HEADER_SIZE_LONG 12
#define SYSLOG_PRINTSIZE 255
#define ERRMSG_SIZE 255
#define RESTART_FILE "gsn_restart"
#define NAMESIZE 1024
/* GTP version 1 message type definitions. Also covers version 0 except *
* for anonymous PDP context which was superceded in version 1 */
/* 0 For future use. */
#define GTP_ECHO_REQ 1 /* Echo Request */
#define GTP_ECHO_RSP 2 /* Echo Response */
#define GTP_NOT_SUPPORTED 3 /* Version Not Supported */
#define GTP_ALIVE_REQ 4 /* Node Alive Request */
#define GTP_ALIVE_RSP 5 /* Node Alive Response */
#define GTP_REDIR_REQ 6 /* Redirection Request */
#define GTP_REDIR_RSP 7 /* Redirection Response */
/* 8-15 For future use. */
#define GTP_CREATE_PDP_REQ 16 /* Create PDP Context Request */
#define GTP_CREATE_PDP_RSP 17 /* Create PDP Context Response */
#define GTP_UPDATE_PDP_REQ 18 /* Update PDP Context Request */
#define GTP_UPDATE_PDP_RSP 19 /* Update PDP Context Response */
#define GTP_DELETE_PDP_REQ 20 /* Delete PDP Context Request */
#define GTP_DELETE_PDP_RSP 21 /* Delete PDP Context Response */
/* 22-25 For future use. */ /* In version GTP 1 anonomous PDP context */
#define GTP_ERROR 26 /* Error Indication */
#define GTP_PDU_NOT_REQ 27 /* PDU Notification Request */
#define GTP_PDU_NOT_RSP 28 /* PDU Notification Response */
#define GTP_PDU_NOT_REJ_REQ 29 /* PDU Notification Reject Request */
#define GTP_PDU_NOT_REJ_RSP 30 /* PDU Notification Reject Response */
#define GTP_SUPP_EXT_HEADER 31 /* Supported Extension Headers Notification */
#define GTP_SND_ROUTE_REQ 32 /* Send Routeing Information for GPRS Request */
#define GTP_SND_ROUTE_RSP 33 /* Send Routeing Information for GPRS Response */
#define GTP_FAILURE_REQ 34 /* Failure Report Request */
#define GTP_FAILURE_RSP 35 /* Failure Report Response */
#define GTP_MS_PRESENT_REQ 36 /* Note MS GPRS Present Request */
#define GTP_MS_PRESENT_RSP 37 /* Note MS GPRS Present Response */
/* 38-47 For future use. */
#define GTP_IDEN_REQ 48 /* Identification Request */
#define GTP_IDEN_RSP 49 /* Identification Response */
#define GTP_SGSN_CONTEXT_REQ 50 /* SGSN Context Request */
#define GTP_SGSN_CONTEXT_RSP 51 /* SGSN Context Response */
#define GTP_SGSN_CONTEXT_ACK 52 /* SGSN Context Acknowledge */
#define GTP_FWD_RELOC_REQ 53 /* Forward Relocation Request */
#define GTP_FWD_RELOC_RSP 54 /* Forward Relocation Response */
#define GTP_FWD_RELOC_COMPL 55 /* Forward Relocation Complete */
#define GTP_RELOC_CANCEL_REQ 56 /* Relocation Cancel Request */
#define GTP_RELOC_CANCEL_RSP 57 /* Relocation Cancel Response */
#define GTP_FWD_SRNS 58 /* Forward SRNS Context */
#define GTP_FWD_RELOC_ACK 59 /* Forward Relocation Complete Acknowledge */
#define GTP_FWD_SRNS_ACK 60 /* Forward SRNS Context Acknowledge */
/* 61-239 For future use. */
#define GTP_DATA_TRAN_REQ 240 /* Data Record Transfer Request */
#define GTP_DATA_TRAN_RSP 241 /* Data Record Transfer Response */
/* 242-254 For future use. */
#define GTP_GPDU 255 /* G-PDU */
/* GTP 0 header.
* Explanation to some of the fields:
* SNDCP NPDU Number flag = 0 except for inter SGSN handover situations
* SNDCP N-PDU LCC Number 0 = 0xff except for inter SGSN handover situations
* Sequence number. Used for reliable delivery of signalling messages, and
* to discard "illegal" data messages.
* Flow label. Is used to point a particular PDP context. Is used in data
* messages as well as signalling messages related to a particular context.
* Tunnel ID is IMSI+NSAPI. Unique identifier of PDP context. Is somewhat
* redundant because the header also includes flow. */
struct gtp0_header { /* Descriptions from 3GPP 09.60 */
u_int8_t flags; /* 01 bitfield, with typical values */
/* 000..... Version: 1 (0) */
/* ...1111. Spare (7) */
/* .......0 SNDCP N-PDU Number flag (0) */
u_int8_t type; /* 02 Message type. T-PDU = 0xff */
u_int16_t length; /* 03 Length (of G-PDU excluding header) */
u_int16_t seq; /* 05 Sequence Number */
u_int16_t flow; /* 07 Flow Label ( = 0 for signalling) */
u_int8_t number; /* 09 SNDCP N-PDU LCC Number ( 0 = 0xff) */
u_int8_t spare1; /* 10 Spare */
u_int8_t spare2; /* 11 Spare */
u_int8_t spare3; /* 12 Spare */
u_int64_t tid; /* 13 Tunnel ID */
}; /* 20 */
struct gtp1_header_short { /* Descriptions from 3GPP 29060 */
u_int8_t flags; /* 01 bitfield, with typical values */
/* 000..... Version: 1 */
/* ...1.... Protocol Type: GTP=1, GTP'=0 */
/* ....1... Spare = 1 */
/* .....1.. Extension header flag: 1 */
/* ......1. Sequence number flag: 1 */
/* .......0 PN: N-PDU Number flag */
u_int8_t type; /* 02 Message type. T-PDU = 0xff */
u_int16_t length; /* 03 Length (of IP packet or signalling) */
u_int64_t tid; /* 05 - 08 Tunnel ID */
};
struct gtp1_header_long { /* Descriptions from 3GPP 29060 */
u_int8_t flags; /* 01 bitfield, with typical values */
/* 000..... Version: 1 */
/* ...1.... Protocol Type: GTP=1, GTP'=0 */
/* ....1... Spare = 1 */
/* .....1.. Extension header flag: 1 */
/* ......1. Sequence number flag: 1 */
/* .......0 PN: N-PDU Number flag */
u_int8_t type; /* 02 Message type. T-PDU = 0xff */
u_int16_t length; /* 03 Length (of IP packet or signalling) */
u_int64_t tid; /* 05 Tunnel ID */
u_int16_t seq; /* 10 Sequence Number */
u_int8_t npdu; /* 11 N-PDU Number */
u_int8_t next; /* 12 Next extension header type. Empty = 0 */
};
struct gtp0_packet {
struct gtp0_header h;
u_int8_t p[GTP_MAX];
} __attribute__((packed));
struct gtp1_packet_short {
struct gtp1_header_short h;
u_int8_t p[GTP_MAX];
} __attribute__((packed));
struct gtp1_packet_long {
struct gtp1_header_long h;
u_int8_t p[GTP_MAX];
} __attribute__((packed));
union gtp_packet {
u_int8_t flags;
struct gtp0_packet gtp0;
struct gtp1_packet_short gtp1s;
struct gtp1_packet_long gtp1l;
} __attribute__((packed)) h;
/* ***********************************************************
* Information storage for each gsn instance
*
* Normally each instance of the application corresponds to
* one instance of a gsn.
*
* In order to avoid global variables in the application, and
* also in order to allow several instances of a gsn in the same
* application this struct is provided in order to store all
* relevant information related to the gsn.
*
* Note that this does not include information storage for '
* each pdp context. This is stored in another struct.
*************************************************************/
struct gsn_t {
/* Parameters related to the network interface */
int fd; /* File descriptor to network interface */
struct in_addr gsnc; /* IP address of this gsn for signalling */
struct in_addr gsnu; /* IP address of this gsn for user traffic */
/* Parameters related to signalling messages */
uint16_t seq_next; /* Next sequence number to use */
int seq_first; /* First packet in queue (oldest timeout) */
int seq_last; /* Last packet in queue (youngest timeout) */
unsigned char restart_counter; /* Increment on restart. Stored on disk */
char *statedir; /* Disk location for permanent storage */
struct queue_t *queue_req; /* Request queue */
struct queue_t *queue_resp; /* Response queue */
/* Call back functions */
int (*cb_delete_context) (struct pdp_t*);
int (*cb_create_context) (struct pdp_t*);
int (*cb_conf) (int type, int cause, struct pdp_t *pdp, void* aid);
int (*cb_gpdu) (struct pdp_t* pdp, void* pack, unsigned len);
/* Counters */
uint64_t err_socket; /* Number of socket errors */
uint64_t err_readfrom; /* Number of readfrom errors */
uint64_t err_sendto; /* Number of sendto errors */
uint64_t err_memcpy; /* Number of memcpy */
uint64_t err_queuefull; /* Number of times queue was full */
uint64_t err_seq; /* Number of seq out of range */
uint64_t err_address; /* GSN address conversion failed */
uint64_t err_unknownpdp; /* GSN address conversion failed */
uint64_t err_unknowntid; /* Application supplied unknown imsi+nsapi */
uint64_t err_cause; /* Unexpected cause value received */
uint64_t err_outofpdp; /* Out of storage for PDP contexts */
uint64_t empty; /* Number of empty packets */
uint64_t unsup; /* Number of unsupported version 29.60 11.1.1 */
uint64_t tooshort; /* Number of too short headers 29.60 11.1.2 */
uint64_t unknown; /* Number of unknown messages 29.60 11.1.3 */
uint64_t unexpect; /* Number of unexpected messages 29.60 11.1.4 */
uint64_t dublicate; /* Number of dublicate or unsolicited replies */
uint64_t missing; /* Number of missing mandatory field messages */
uint64_t invalid; /* Number of invalid message format messages */
};
/* External API functions */
extern const char* gtp_version();
extern int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen);
extern int gtp_free(struct gsn_t *gsn);
extern int gtp_newpdp(struct gsn_t *gsn, struct pdp_t **pdp,
uint64_t imsi, uint8_t nsapi);
extern int gtp_freepdp(struct gsn_t *gsn, struct pdp_t *pdp);
extern int gtp_create_context(struct gsn_t *gsn, struct pdp_t *pdp, void *aid,
struct in_addr* inetaddr);
extern int gtp_update_context(struct gsn_t *gsn, struct pdp_t *pdp, void *aid,
struct in_addr* inetaddr);
extern int gtp_delete_context(struct gsn_t *gsn, struct pdp_t *pdp, void *aid);
extern int gtp_gpdu(struct gsn_t *gsn, struct pdp_t *pdp,
void *pack, unsigned len);
extern int gtp_fd(struct gsn_t *gsn);
extern int gtp_decaps(struct gsn_t *gsn);
extern int gtp_retrans(struct gsn_t *gsn);
extern int gtp_retranstimeout(struct gsn_t *gsn, struct timeval *timeout);
/*
extern int gtp_set_cb_newpdp(struct gsn_t *gsn,
int (*cb) (struct pdp_t*));
extern int gtp_set_cb_freepdp(struct gsn_t *gsn,
int (*cb) (struct pdp_t*));
extern int gtp_set_cb_create_pdp_ind(struct gsn_t *gsn,
int (*cb) (struct pdp_t*));
extern int gtp_set_cb_create_pdp_conf(struct gsn_t *gsn,
int (*cb) (struct pdp_t*, int));
extern int gtp_set_cb_update_pdp_conf(struct gsn_t *gsn,
int (*cb) (struct pdp_t*, int, int));
extern int gtp_set_cb_delete_pdp_ind(struct gsn_t *gsn,
int (*cb) (struct pdp_t*));
extern int gtp_set_cb_delete_pdp_conf(struct gsn_t *gsn,
int (*cb) (struct pdp_t*, int));
*/
extern int gtp_set_cb_delete_context(struct gsn_t *gsn,
int (*cb_delete_context) (struct pdp_t* pdp));
extern int gtp_set_cb_create_context(struct gsn_t *gsn,
int (*cb_create_context) (struct pdp_t* pdp));
extern int gtp_set_cb_conf(struct gsn_t *gsn,
int (*cb) (int type, int cause, struct pdp_t* pdp, void *aid));
extern int gtp_set_cb_gpdu(struct gsn_t *gsn,
int (*cb_gpdu) (struct pdp_t* pdp, void* pack, unsigned len));
/* Internal functions (not part of the API */
extern int gtp_echo_req(struct gsn_t *gsn, struct in_addr *inetaddrs);
extern int gtp_echo_resp(struct gsn_t *gsn, struct sockaddr_in *peer,
void *pack, unsigned len);
extern int gtp_echo_ind(struct gsn_t *gsn, struct sockaddr_in *peer,
void *pack, unsigned len);
extern int gtp_echo_conf(struct gsn_t *gsn, struct sockaddr_in *peer,
void *pack, unsigned len);
extern int gtp_unsup_resp(struct gsn_t *gsn, struct sockaddr_in *peer,
void *pack, unsigned len);
extern int gtp_unsup_conf(struct gsn_t *gsn, struct sockaddr_in *peer,
void *pack, unsigned len);
extern int gtp_create_pdp_req(struct gsn_t *gsn, int version, void *aid,
struct in_addr* inetaddr, struct pdp_t *pdp);
extern int gtp_create_pdp_resp(struct gsn_t *gsn, int version,
struct sockaddr_in *peer,
void *pack, unsigned len,
struct pdp_t *pdp, uint8_t cause);
extern int gtp_create_pdp_ind(struct gsn_t *gsn, int version,
struct sockaddr_in *peer,
void *pack, unsigned len);
extern int gtp_create_pdp_conf(struct gsn_t *gsn, int version,
struct sockaddr_in *peer,
void *pack, unsigned len);
extern int gtp_update_pdp_req(struct gsn_t *gsn, int version, void *aid,
struct in_addr* inetaddr, struct pdp_t *pdp);
extern int gtp_delete_pdp_req(struct gsn_t *gsn, int version, void *aid,
struct pdp_t *pdp);
extern int gtp_delete_pdp_resp(struct gsn_t *gsn, int version,
struct sockaddr_in *peer,
void *pack, unsigned len,
struct pdp_t *pdp, uint8_t cause);
extern int gtp_delete_pdp_ind(struct gsn_t *gsn, int version,
struct sockaddr_in *peer,
void *pack, unsigned len);
extern int gtp_delete_pdp_conf(struct gsn_t *gsn, int version,
struct sockaddr_in *peer,
void *pack, unsigned len);
extern int ipv42eua(struct ul66_t *eua, struct in_addr *src);
extern int eua2ipv4(struct in_addr *dst, struct ul66_t *eua);
extern int gsna2in_addr(struct in_addr *dst, struct ul16_t *gsna);
extern int in_addr2gsna(struct ul16_t *gsna, struct in_addr *src);
#endif /* !_GTP_H */

513
gtp/gtpie.c Normal file
View File

@ -0,0 +1,513 @@
/*
* 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):
*
*/
/*
* gtpie.c: Contains functions to encapsulate and decapsulate GTP
* information elements
*
*
* Encapsulation
* - gtpie_tlv, gtpie_tv0, gtpie_tv1, gtpie_tv2 ... Adds information
* elements to a buffer.
*
* Decapsulation
* - gtpie_decaps: Returns array with pointers to information elements.
* - getie_getie: Returns the pointer of a particular element.
* - gtpie_gettlv: Copies tlv information element. Return 0 on success.
* - gtpie_gettv: Copies tv information element. Return 0 on success.
*
*/
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <string.h>
#include "gtpie.h"
int gtpie_tlv(void *p, int *length, int size, u_int8_t t, int l, void *v) {
if ((*length + 3 + l) >= size) return 1;
((union gtpie_member*) (p + *length))->tlv.t = hton8(t);
((union gtpie_member*) (p + *length))->tlv.l = hton16(l);
memcpy((void*) (p + *length +3), v, l);
*length += 3 + l;
return 0;
}
int gtpie_tv0(void *p, int *length, int size, u_int8_t t, int l, u_int8_t *v) {
if ((*length + 1 + l) >= size) return 1;
((union gtpie_member*) (p + *length))->tv0.t = hton8(t);
memcpy((void*) (p + *length +1), v, l);
*length += 1 + l;
return 0;
}
int gtpie_tv1(void *p, int *length, int size, u_int8_t t, u_int8_t v) {
if ((*length + 2) >= size) return 1;
((union gtpie_member*) (p + *length))->tv1.t = hton8(t);
((union gtpie_member*) (p + *length))->tv1.v = hton8(v);
*length += 2;
return 0;
}
int gtpie_tv2(void *p, int *length, int size, u_int8_t t, u_int16_t v) {
if ((*length + 3) >= size) return 1;
((union gtpie_member*) (p + *length))->tv2.t = hton8(t);
((union gtpie_member*) (p + *length))->tv2.v = hton16(v);
*length += 3;
return 0;
}
int gtpie_tv4(void *p, int *length, int size, u_int8_t t, u_int32_t v) {
if ((*length + 5) >= size) return 1;
((union gtpie_member*) (p + *length))->tv4.t = hton8(t);
((union gtpie_member*) (p + *length))->tv4.v = hton32(v);
*length += 5;
return 0;
}
int gtpie_getie(union gtpie_member* ie[], int type, int instance) {
int j;
for (j=0; j< GTPIE_SIZE; j++) {
if ((ie[j] != 0) && (ie[j]->t == type)) {
if (instance-- == 0) return j;
}
}
return -1;
}
int gtpie_exist(union gtpie_member* ie[], int type, int instance) {
int j;
for (j=0; j< GTPIE_SIZE; j++) {
if ((ie[j] != 0) && (ie[j]->t == type)) {
if (instance-- == 0) return 1;
}
}
return 0;
}
int gtpie_gettlv(union gtpie_member* ie[], int type, int instance,
int *length, void *dst, int size){
int ien;
ien = gtpie_getie(ie, type, instance);
if (ien>=0) {
*length = ntoh16(ie[ien]->tlv.l);
if (*length <= size)
memcpy(dst, ie[ien]->tlv.v, *length);
else
return EOF;
}
return 0;
}
int gtpie_gettv0(union gtpie_member* ie[], int type, int instance,
void *dst, int size){
int ien;
ien = gtpie_getie(ie, type, instance);
if (ien>=0)
memcpy(dst, ie[ien]->tv0.v, size);
else
return EOF;
return 0;
}
int gtpie_gettv1(union gtpie_member* ie[], int type, int instance,
uint8_t *dst){
int ien;
ien = gtpie_getie(ie, type, instance);
if (ien>=0)
*dst = ntoh8(ie[ien]->tv1.v);
else
return EOF;
return 0;
}
int gtpie_gettv2(union gtpie_member* ie[], int type, int instance,
uint16_t *dst){
int ien;
ien = gtpie_getie(ie, type, instance);
if (ien>=0)
*dst = ntoh16(ie[ien]->tv2.v);
else
return EOF;
return 0;
}
int gtpie_gettv4(union gtpie_member* ie[], int type, int instance,
uint32_t *dst){
int ien;
ien = gtpie_getie(ie, type, instance);
if (ien>=0)
*dst = ntoh32(ie[ien]->tv4.v);
else
return EOF;
return 0;
}
int gtpie_decaps(union gtpie_member* ie[], void *pack, unsigned len) {
int i;
int j = 0;
unsigned char *p;
unsigned char *end;
end = (unsigned char*) pack + len;
p = pack;
memset(ie, 0, 4 * GTPIE_SIZE);
while (p<end) {
if (GTPIE_DEBUG) {
printf("The packet looks like this:\n");
for( i=0; i<(end-p); i++) {
printf("%02x ", (unsigned char)*(char *)(p+i));
if (!((i+1)%16)) printf("\n");
};
printf("\n");
}
switch (*p) {
case GTPIE_CAUSE: /* TV GTPIE types with value length 1 */
case GTPIE_REORDER:
case GTPIE_MAP_CAUSE:
case GTPIE_MS_VALIDATED:
case GTPIE_RECOVERY:
case GTPIE_SELECTION_MODE:
case GTPIE_TEARDOWN:
case GTPIE_NSAPI:
case GTPIE_RANAP_CAUSE:
case GTPIE_RP_SMS:
case GTPIE_RP:
case GTPIE_MS_NOT_REACH:
if (j<GTPIE_SIZE) {
ie[j] = (union gtpie_member*) p;
if (GTPIE_DEBUG) printf("GTPIE TV1 found. Type %d, value %d\n",
ie[j]->tv1.t, ie[j]->tv1.v);
p+= 1 + 1;
j++;
}
break;
case GTPIE_FL_DI: /* TV GTPIE types with value length 2 */
case GTPIE_FL_C:
case GTPIE_PFI:
case GTPIE_CHARGING_C:
case GTPIE_TRACE_REF:
case GTPIE_TRACE_TYPE:
if (j<GTPIE_SIZE) {
ie[j] = (union gtpie_member*) p;
if (GTPIE_DEBUG) printf("GTPIE TV2 found. Type %d, value %d\n",
ie[j]->tv2.t, ie[j]->tv2.v);
p+= 1 + 2;
j++;
}
break;
case GTPIE_QOS_PROFILE0: /* TV GTPIE types with value length 3 */
case GTPIE_P_TMSI_S:
if (j<GTPIE_SIZE) {
ie[j] = (union gtpie_member*) p;
if (GTPIE_DEBUG) printf("GTPIE TV 3 found. Type %d, value %d, %d, %d\n",
ie[j]->tv0.t, ie[j]->tv0.v[0],
ie[j]->tv0.v[1], ie[j]->tv0.v[2]);
p+= 1 + 3;
j++;
}
break;
case GTPIE_TLLI: /* TV GTPIE types with value length 4 */
case GTPIE_P_TMSI:
case GTPIE_CHARGING_ID:
if (j<GTPIE_SIZE) {
/* case GTPIE_TEI_DI: gtp1 */
/* case GTPIE_TEI_C: gtp1 */
ie[j] = (union gtpie_member*) p;
if (GTPIE_DEBUG) printf("GTPIE TV 4 found. Type %d, value %d\n",
ie[j]->tv4.t, ie[j]->tv4.v);
p+= 1 + 4;
j++;
}
break;
case GTPIE_TEI_DII: /* TV GTPIE types with value length 5 */
if (j<GTPIE_SIZE) {
ie[j] = (union gtpie_member*) p;
if (GTPIE_DEBUG) printf("GTPIE TV 5 found. Type %d\n", ie[j]->tv0.t);
p+= 1 + 5;
j++;
}
break;
case GTPIE_RAB_CONTEXT: /* TV GTPIE types with value length 7 */
if (j<GTPIE_SIZE) {
ie[j] = (union gtpie_member*) p;
if (GTPIE_DEBUG) printf("GTPIE TV 7 found. Type %d\n", ie[j]->tv0.t);
p+= 1 + 7;
j++;
}
break;
case GTPIE_IMSI: /* TV GTPIE types with value length 8 */
case GTPIE_RAI:
if (j<GTPIE_SIZE) {
ie[j] = (union gtpie_member*) p;
if (GTPIE_DEBUG) printf("GTPIE TV 8 found. Type %d, value 0x%llx\n",
ie[j]->tv0.t, ie[j]->tv8.v);
p+= 1 + 8;
j++;
}
break;
case GTPIE_AUTH_TRIPLET: /* TV GTPIE types with value length 28 */
if (j<GTPIE_SIZE) {
ie[j] = (union gtpie_member*) p;
if (GTPIE_DEBUG) printf("GTPIE TV 28 found. Type %d\n", ie[j]->tv0.t);
p+= 1 + 28;
j++;
}
break;
case GTPIE_EXT_HEADER_T: /* GTP extension header */
if (j<GTPIE_SIZE) {
ie[j] = (union gtpie_member*) p;
if (GTPIE_DEBUG) printf("GTPIE GTP extension header found. Type %d\n",
ie[j]->ext.t);
p+= 2 + ntoh8(ie[j]->ext.l);
j++;
}
break;
case GTPIE_EUA: /* TLV GTPIE types with variable length */
case GTPIE_MM_CONTEXT:
case GTPIE_PDP_CONTEXT:
case GTPIE_APN:
case GTPIE_PCO:
case GTPIE_GSN_ADDR:
case GTPIE_MSISDN:
case GTPIE_QOS_PROFILE:
case GTPIE_AUTH_QUINTUP:
case GTPIE_TFT:
case GTPIE_TARGET_INF:
case GTPIE_UTRAN_TRANS:
case GTPIE_RAB_SETUP:
case GTPIE_TRIGGER_ID:
case GTPIE_OMC_ID:
case GTPIE_CHARGING_ADDR:
case GTPIE_PRIVATE:
if (j<GTPIE_SIZE) {
ie[j] = (union gtpie_member*) p;
if (GTPIE_DEBUG) printf("GTPIE TLV found. Type %d\n", ie[j]->tlv.t);
p+= 3 + ntoh16(ie[j]->tlv.l);
j++;
}
break;
default:
if (GTPIE_DEBUG) printf("GTPIE something unknown. Type %d\n", *p);
return EOF; /* We received something unknown */
}
}
if (p==end) {
if (GTPIE_DEBUG) printf("GTPIE normal return. %lx %lx\n",
(unsigned long) p, (unsigned long) end);
return 0; /* We landed at the end of the packet: OK */
}
else {
if (GTPIE_DEBUG) printf("GTPIE exceeded end of packet. %lx %lx\n",
(unsigned long) p, (unsigned long) end);
return EOF; /* We exceeded the end of the packet: Error */
}
}
int gtpie_encaps(union gtpie_member *ie[], void *pack, unsigned *len) {
int i;
unsigned char *p;
unsigned char *end;
union gtpie_member *m;
int iesize;
p = pack;
memset(pack, 0, GTPIE_MAX);
end = p + GTPIE_MAX;
for (i=1; i<GTPIE_SIZE; i++) if (ie[i] != 0) {
if (GTPIE_DEBUG) printf("gtpie_encaps. Type %d\n", i);
m=(union gtpie_member *)p;
switch (i) {
case GTPIE_CAUSE: /* TV GTPIE types with value length 1 */
case GTPIE_REORDER:
case GTPIE_MAP_CAUSE:
case GTPIE_MS_VALIDATED:
case GTPIE_RECOVERY:
case GTPIE_SELECTION_MODE:
case GTPIE_TEARDOWN:
case GTPIE_NSAPI:
case GTPIE_RANAP_CAUSE:
case GTPIE_RP_SMS:
case GTPIE_RP:
case GTPIE_MS_NOT_REACH:
iesize = 2;
break;
case GTPIE_FL_DI: /* TV GTPIE types with value length 2 */
case GTPIE_FL_C:
case GTPIE_PFI:
case GTPIE_CHARGING_C:
case GTPIE_TRACE_REF:
case GTPIE_TRACE_TYPE:
iesize = 3;
break;
case GTPIE_QOS_PROFILE0: /* TV GTPIE types with value length 3 */
case GTPIE_P_TMSI_S:
iesize = 4;
break;
case GTPIE_TLLI: /* TV GTPIE types with value length 4 */
case GTPIE_P_TMSI:
/* case GTPIE_TEI_DI: only in gtp1*/
/* case GTPIE_TEI_C: only in gtp1*/
case GTPIE_CHARGING_ID:
iesize = 5;
break;
case GTPIE_TEI_DII: /* TV GTPIE types with value length 5 */
iesize = 6;
break;
case GTPIE_RAB_CONTEXT: /* TV GTPIE types with value length 7 */
iesize = 8;
break;
case GTPIE_IMSI: /* TV GTPIE types with value length 8 */
case GTPIE_RAI:
iesize = 9;
break;
case GTPIE_AUTH_TRIPLET: /* TV GTPIE types with value length 28 */
iesize = 29;
break;
case GTPIE_EXT_HEADER_T: /* GTP extension header */
iesize = 2 + hton8(ie[i]->ext.l);
break;
case GTPIE_EUA: /* TLV GTPIE types with length length 2 */
case GTPIE_MM_CONTEXT:
case GTPIE_PDP_CONTEXT:
case GTPIE_APN:
case GTPIE_PCO:
case GTPIE_GSN_ADDR:
case GTPIE_MSISDN:
case GTPIE_QOS_PROFILE:
case GTPIE_AUTH_QUINTUP:
case GTPIE_TFT:
case GTPIE_TARGET_INF:
case GTPIE_UTRAN_TRANS:
case GTPIE_RAB_SETUP:
case GTPIE_TRIGGER_ID:
case GTPIE_OMC_ID:
case GTPIE_CHARGING_ADDR:
case GTPIE_PRIVATE:
iesize = 3 + hton16(ie[i]->tlv.l);
break;
default:
return 2; /* We received something unknown */
}
if (p+iesize < end) {
memcpy(p, ie[i], iesize);
p += iesize;
*len += iesize;
}
else return 2; /* Out of space */
}
return 0;
}
int gtpie_encaps2(union gtpie_member ie[], int size,
void *pack, unsigned *len) {
int i, j;
unsigned char *p;
unsigned char *end;
union gtpie_member *m;
int iesize;
p = pack;
memset(pack, 0, GTPIE_MAX);
end = p + GTPIE_MAX;
for (j=0; j<GTPIE_SIZE; j++) for (i=0; i<size; i++) if (ie[i].t == j) {
if (GTPIE_DEBUG) printf("gtpie_encaps. Number %d, Type %d\n", i, ie[i].t);
m=(union gtpie_member *)p;
switch (ie[i].t) {
case GTPIE_CAUSE: /* TV GTPIE types with value length 1 */
case GTPIE_REORDER:
case GTPIE_MAP_CAUSE:
case GTPIE_MS_VALIDATED:
case GTPIE_RECOVERY:
case GTPIE_SELECTION_MODE:
case GTPIE_TEARDOWN:
case GTPIE_NSAPI:
case GTPIE_RANAP_CAUSE:
case GTPIE_RP_SMS:
case GTPIE_RP:
case GTPIE_MS_NOT_REACH:
iesize = 2;
break;
case GTPIE_PFI: /* TV GTPIE types with value length 2 */
case GTPIE_CHARGING_C:
case GTPIE_TRACE_REF:
case GTPIE_TRACE_TYPE:
iesize = 3;
break;
case GTPIE_QOS_PROFILE0: /* TV GTPIE types with value length 3 */
case GTPIE_P_TMSI_S:
iesize = 4;
break;
case GTPIE_TLLI: /* TV GTPIE types with value length 4 */
case GTPIE_P_TMSI:
case GTPIE_TEI_DI:
case GTPIE_TEI_C:
iesize = 5;
break;
case GTPIE_TEI_DII: /* TV GTPIE types with value length 5 */
iesize = 6;
break;
case GTPIE_RAB_CONTEXT: /* TV GTPIE types with value length 7 */
iesize = 8;
break;
case GTPIE_IMSI: /* TV GTPIE types with value length 8 */
case GTPIE_RAI:
iesize = 9;
break;
case GTPIE_AUTH_TRIPLET: /* TV GTPIE types with value length 28 */
iesize = 29;
break;
case GTPIE_EXT_HEADER_T: /* GTP extension header */
iesize = 2 + hton8(ie[i].ext.l);
break;
case GTPIE_CHARGING_ID: /* TLV GTPIE types with length length 2 */
case GTPIE_EUA:
case GTPIE_MM_CONTEXT:
case GTPIE_PDP_CONTEXT:
case GTPIE_APN:
case GTPIE_PCO:
case GTPIE_GSN_ADDR:
case GTPIE_MSISDN:
case GTPIE_QOS_PROFILE:
case GTPIE_AUTH_QUINTUP:
case GTPIE_TFT:
case GTPIE_TARGET_INF:
case GTPIE_UTRAN_TRANS:
case GTPIE_RAB_SETUP:
case GTPIE_TRIGGER_ID:
case GTPIE_OMC_ID:
case GTPIE_CHARGING_ADDR:
case GTPIE_PRIVATE:
iesize = 3 + hton16(ie[i].tlv.l);
break;
default:
return 2; /* We received something unknown */
}
if (p+iesize < end) {
memcpy(p, &ie[i], iesize);
p += iesize;
*len += iesize;
}
else return 2; /* Out of space */
}
return 0;
}

279
gtp/gtpie.h Normal file
View File

@ -0,0 +1,279 @@
/*
* 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 _GTPIE_H
#define _GTPIE_H
/* Macroes for conversion between host and network byte order */
#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 GTPIE_SIZE 256 /* Max number of information elements */
#define GTPIE_MAX 0xffff /* Max length of information elements */
#define GTPIE_MAX_TV 28 /* Max length of type value pair */
#define GTPIE_MAX_TLV 0xffff-3 /* Max length of TLV (GTP length is 16 bit) */
#define GTPIE_DEBUG 0 /* Print debug information */
/* GTP Information elements from 29.060 v3.9.0 7.7 Information Elements */
/* Also covers version 0. Note that version 0 6: QOS Profile was superceded *
* by 135: QOS Profile in version 1 */
#define GTPIE_CAUSE 1 /* Cause 1 */
#define GTPIE_IMSI 2 /* International Mobile Subscriber Identity 8 */
#define GTPIE_RAI 3 /* Routing Area Identity (RAI) 8 */
#define GTPIE_TLLI 4 /* Temporary Logical Link Identity (TLLI) 4 */
#define GTPIE_P_TMSI 5 /* Packet TMSI (P-TMSI) 4 */
#define GTPIE_QOS_PROFILE0 6 /* Quality of Service Profile GTP version 0 3*/
/* 6-7 SPARE */ /* 6 is QoS Profile vers 0 */
#define GTPIE_REORDER 8 /* Reordering Required 1 */
#define GTPIE_AUTH_TRIPLET 9 /* Authentication Triplet 28 */
/* 10 SPARE */
#define GTPIE_MAP_CAUSE 11 /* MAP Cause 1 */
#define GTPIE_P_TMSI_S 12 /* P-TMSI Signature 3 */
#define GTPIE_MS_VALIDATED 13 /* MS Validated 1 */
#define GTPIE_RECOVERY 14 /* Recovery 1 */
#define GTPIE_SELECTION_MODE 15 /* Selection Mode 1 */
#define GTPIE_FL_DI 16 /* Flow Label Data I 2 */
#define GTPIE_TEI_DI 16 /* Tunnel Endpoint Identifier Data I 4 */
#define GTPIE_TEI_C 17 /* Tunnel Endpoint Identifier Control Plane 4 */
#define GTPIE_FL_C 17 /* Flow Label Signalling 2 */
#define GTPIE_TEI_DII 18 /* Tunnel Endpoint Identifier Data II 5 */
#define GTPIE_TEARDOWN 19 /* Teardown Ind 1 */
#define GTPIE_NSAPI 20 /* NSAPI 1 */
#define GTPIE_RANAP_CAUSE 21 /* RANAP Cause 1 */
#define GTPIE_RAB_CONTEXT 22 /* RAB Context 7 */
#define GTPIE_RP_SMS 23 /* Radio Priority SMS 1 */
#define GTPIE_RP 24 /* Radio Priority 1 */
#define GTPIE_PFI 25 /* Packet Flow Id 2 */
#define GTPIE_CHARGING_C 26 /* Charging Characteristics 2 */
#define GTPIE_TRACE_REF 27 /* Trace Reference 2 */
#define GTPIE_TRACE_TYPE 28 /* Trace Type 2 */
#define GTPIE_MS_NOT_REACH 29 /* MS Not Reachable Reason 1 */
/* 30-116 UNUSED */
/* 117-126 Reserved for the GPRS charging protocol (see GTP' in GSM 12.15) */
#define GTPIE_CHARGING_ID 127 /* Charging ID 4 */
#define GTPIE_EUA 128 /* End User Address */
#define GTPIE_MM_CONTEXT 129 /* MM Context */
#define GTPIE_PDP_CONTEXT 130 /* PDP Context */
#define GTPIE_APN 131 /* Access Point Name */
#define GTPIE_PCO 132 /* Protocol Configuration Options */
#define GTPIE_GSN_ADDR 133 /* GSN Address */
#define GTPIE_MSISDN 134 /* MS International PSTN/ISDN Number */
#define GTPIE_QOS_PROFILE 135 /* Quality of Service Profile */
#define GTPIE_AUTH_QUINTUP 136 /* Authentication Quintuplet */
#define GTPIE_TFT 137 /* Traffic Flow Template */
#define GTPIE_TARGET_INF 138 /* Target Identification */
#define GTPIE_UTRAN_TRANS 139 /* UTRAN Transparent Container */
#define GTPIE_RAB_SETUP 140 /* RAB Setup Information */
#define GTPIE_EXT_HEADER_T 141 /* Extension Header Type List */
#define GTPIE_TRIGGER_ID 142 /* Trigger Id */
#define GTPIE_OMC_ID 143 /* OMC Identity */
/* 239-250 Reserved for the GPRS charging protocol (see GTP' in GSM 12.15) */
#define GTPIE_CHARGING_ADDR 251 /* Charging Gateway Address */
/* 252-254 Reserved for the GPRS charging protocol (see GTP' in GSM 12.15) */
#define GTPIE_PRIVATE 255 /* Private Extension */
/* GTP information element cause codes from 29.060 v3.9.0 7.7 */
/* */
#define GTPCAUSE_REQ_IMSI 0 /* Request IMSI */
#define GTPCAUSE_REQ_IMEI 1 /* Request IMEI */
#define GTPCAUSE_REQ_IMSI_IMEI 2 /* Request IMSI and IMEI */
#define GTPCAUSE_NO_ID_NEEDED 3 /* No identity needed */
#define GTPCAUSE_MS_REFUSES 4 /* MS refuses */
#define GTPCAUSE_MS_NOT_RESP 5 /* MS is not GPRS responding */
#define GTPCAUSE_006 6 /* For future use 6-48 */
#define GTPCAUSE_049 49 /* Cause values reserved for GPRS charging protocol use (See GTP' in GSM 12.15) 49-63 */
#define GTPCAUSE_064 64 /* For future use 64-127 */
#define GTPCAUSE_ACC_REQ 128 /* Request accepted */
#define GTPCAUSE_129 129 /* For future use 129-176 */
#define GTPCAUSE_177 177 /* Cause values reserved for GPRS charging protocol use (See GTP' In GSM 12.15) 177-191 */
#define GTPCAUSE_NON_EXIST 192 /* Non-existent */
#define GTPCAUSE_INVALID_MESSAGE 193 /* Invalid message format */
#define GTPCAUSE_IMSI_NOT_KNOWN 194 /* IMSI not known */
#define GTPCAUSE_MS_DETACHED 195 /* MS is GPRS detached */
#define GTPCAUSE_MS_NOT_RESP 196 /* MS is not GPRS responding */
#define GTPCAUSE_MS_REFUSES 197 /* MS refuses */
#define GTPCAUSE_198 198 /* For future use */
#define GTPCAUSE_NO_RESOURCES 199 /* No resources available */
#define GTPCAUSE_NOT_SUPPORTED 200 /* Service not supported */
#define GTPCAUSE_MAN_IE_INCORRECT 201 /* Mandatory IE incorrect */
#define GTPCAUSE_MAN_IE_MISSING 202 /* Mandatory IE missing */
#define GTPCAUSE_OPT_IE_INCORRECT 203 /* Optional IE incorrect */
#define GTPCAUSE_SYS_FAIL 204 /* System failure */
#define GTPCAUSE_ROAMING_REST 205 /* Roaming Restriction */
#define GTPCAUSE_PTIMSI_MISMATCH 206 /* P-TMSI signature mismatch */
#define GTPCAUSE_CONN_SUSP 207 /* GPRS connection suspended */
#define GTPCAUSE_AUTH_FAIL 208 /* Authentication failure */
#define GTPCAUSE_USER_AUTH_FAIL 209 /* User authentication failed */
#define GTPCAUSE_CONTEXT_NOT_FOUND 210 /* Context not found */
#define GTPCAUSE_ADDR_OCCUPIED 211 /* All dynamic PDP addresses are occupied */
#define GTPCAUSE_NO_MEMORY 212 /* No memory is available */
#define GTPCAUSE_RELOC_FAIL 213 /* Relocation failure */
#define GTPCAUSE_UNKNOWN_MAN_EXTHEADER 214 /* Unknown mandatory extension header */
#define GTPCAUSE_SEM_ERR_TFT 215 /* Semantic error in the TFT operation */
#define GTPCAUSE_SYN_ERR_TFT 216 /* Syntactic error in the TFT operation */
#define GTPCAUSE_SEM_ERR_FILTER 217 /* Semantic errors in packet filter(s) */
#define GTPCAUSE_SYN_ERR_FILTER 218 /* Syntactic errors in packet filter(s) */
#define GTPCAUSE_MISSING_APN 219 /* Missing or unknown APN*/
#define GTPCAUSE_UNKNOWN_PDP 220 /* Unknown PDP address or PDP type */
#define GTPCAUSE_221 221 /* For Future Use 221-240 */
#define GTPCAUSE_241 241 /* Cause Values Reserved For Gprs Charging Protocol Use (See Gtp' In Gsm 12.15) 241-255 */
/* GTP information element structs in network order */
struct gtpie_ext { /* Extension header */
u_int8_t t; /* Type */
u_int8_t l; /* Length */
u_int8_t *p; /* Value */
} __attribute__((packed));
struct gtpie_tlv { /* Type length value pair */
u_int8_t t; /* Type */
u_int16_t l; /* Length */
u_int8_t v[GTPIE_MAX_TLV]; /* Value */
} __attribute__((packed));
struct gtpie_tv0 { /* 1 byte type value pair */
u_int8_t t; /* Type */
u_int8_t v[GTPIE_MAX_TV]; /* Pointer to value */
}__attribute__((packed));
struct gtpie_tv1 { /* 1 byte type value pair */
u_int8_t t; /* Type */
u_int8_t v; /* Value */
}__attribute__((packed));
struct gtpie_tv2 { /* 2 byte type value pair */
u_int8_t t; /* Type */
u_int16_t v; /* Value */
}__attribute__((packed));
struct gtpie_tv4 { /* 4 byte type value pair */
u_int8_t t; /* Type */
u_int32_t v; /* Value */
}__attribute__((packed));
struct gtpie_tv8 { /* 8 byte type value pair */
u_int8_t t; /* Type */
u_int64_t v; /* Value */
}__attribute__((packed));
union gtpie_member {
u_int8_t t;
struct gtpie_ext ext;
struct gtpie_tlv tlv;
struct gtpie_tv0 tv0;
struct gtpie_tv1 tv1;
struct gtpie_tv2 tv2;
struct gtpie_tv4 tv4;
struct gtpie_tv8 tv8;
}__attribute__((packed));
/*
cause
imsi
rai
tlli
p_tmsi
qos_profile0
reorder
auth
map_cause
p_tmsi_s
ms_validated
recovery
selection_mode
tei_di
tei_c
tei_dii
teardown
nsapi
ranap_cause
rab_context
rp_sms
rp
pfi
charging_c
trace_ref
trace_type
ms_not_reach
charging_id
eua
mm_context
pdp_context
apn
pco
gsn_addr
msisdn
qos_profile
auth
tft
target_inf
utran_trans
rab_setup
ext_header_t
trigger_id
omc_id
charging_addr
private
*/
struct tlv1 {
u_int8_t type;
u_int8_t length;
}__attribute__((packed));
struct tlv2 {
u_int8_t type;
u_int16_t length;
}__attribute__((packed));
extern int gtpie_tlv(void *p, int *length, int size,
u_int8_t t, int l, void *v);
extern int gtpie_tv0(void *p, int *length, int size,
u_int8_t t, int l, u_int8_t *v);
extern int gtpie_tv1(void *p, int *length, int size, u_int8_t t, u_int8_t v);
extern int gtpie_tv2(void *p, int *length, int size, u_int8_t t, u_int16_t v);
extern int gtpie_tv4(void *p, int *length, int size, u_int8_t t, u_int32_t v);
extern int gtpie_tv8(void *p, int *length, int size, u_int8_t t, u_int64_t v);
extern int gtpie_getie(union gtpie_member* ie[], int type, int instance);
extern int gtpie_exist(union gtpie_member* ie[], int type, int instance);
extern int gtpie_gettlv(union gtpie_member* ie[], int type, int instance,
int *length, void *dst, int size);
extern int gtpie_gettv0(union gtpie_member* ie[], int type, int instance,
void *dst, int size);
extern int gtpie_gettv1(union gtpie_member* ie[], int type, int instance,
uint8_t *dst);
extern int gtpie_gettv2(union gtpie_member* ie[], int type, int instance,
uint16_t *dst);
extern int gtpie_gettv4(union gtpie_member* ie[], int type, int instance,
uint32_t *dst);
extern int gtpie_decaps(union gtpie_member* ie[], void *pack, unsigned len);
extern int gtpie_encaps(union gtpie_member* ie[], void *pack, unsigned *len);
extern int gtpie_encaps2(union gtpie_member ie[], int size,
void *pack, unsigned *len);
#endif /* !_GTPIE_H */

246
gtp/lookupa.c Normal file
View File

@ -0,0 +1,246 @@
/*
--------------------------------------------------------------------
lookupa.c, by Bob Jenkins, December 1996. Same as lookup2.c
Use this code however you wish. Public Domain. No warranty.
Source is http://burtleburtle.net/bob/c/lookupa.c
--------------------------------------------------------------------
*/
#ifndef STANDARD
/*
#include "standard.h"
*/
#endif
#ifndef LOOKUPA
#include "lookupa.h"
#endif
/*
--------------------------------------------------------------------
mix -- mix 3 32-bit values reversibly.
For every delta with one or two bit set, and the deltas of all three
high bits or all three low bits, whether the original value of a,b,c
is almost all zero or is uniformly distributed,
* If mix() is run forward or backward, at least 32 bits in a,b,c
have at least 1/4 probability of changing.
* If mix() is run forward, every bit of c will change between 1/3 and
2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.)
mix() was built out of 36 single-cycle latency instructions in a
structure that could supported 2x parallelism, like so:
a -= b;
a -= c; x = (c>>13);
b -= c; a ^= x;
b -= a; x = (a<<8);
c -= a; b ^= x;
c -= b; x = (b>>13);
...
Unfortunately, superscalar Pentiums and Sparcs can't take advantage
of that parallelism. They've also turned some of those single-cycle
latency instructions into multi-cycle latency instructions. Still,
this is the fastest good hash I could find. There were about 2^^68
to choose from. I only looked at a billion or so.
--------------------------------------------------------------------
*/
#define mix(a,b,c) \
{ \
a -= b; a -= c; a ^= (c>>13); \
b -= c; b -= a; b ^= (a<<8); \
c -= a; c -= b; c ^= (b>>13); \
a -= b; a -= c; a ^= (c>>12); \
b -= c; b -= a; b ^= (a<<16); \
c -= a; c -= b; c ^= (b>>5); \
a -= b; a -= c; a ^= (c>>3); \
b -= c; b -= a; b ^= (a<<10); \
c -= a; c -= b; c ^= (b>>15); \
}
/*
--------------------------------------------------------------------
lookup() -- hash a variable-length key into a 32-bit value
k : the key (the unaligned variable-length array of bytes)
len : the length of the key, counting by bytes
level : can be any 4-byte value
Returns a 32-bit value. Every bit of the key affects every bit of
the return value. Every 1-bit and 2-bit delta achieves avalanche.
About 6len+35 instructions.
The best hash table sizes are powers of 2. There is no need to do
mod a prime (mod is sooo slow!). If you need less than 32 bits,
use a bitmask. For example, if you need only 10 bits, do
h = (h & hashmask(10));
In which case, the hash table should have hashsize(10) elements.
If you are hashing n strings (ub1 **)k, do it like this:
for (i=0, h=0; i<n; ++i) h = lookup( k[i], len[i], h);
By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this
code any way you wish, private, educational, or commercial.
See http://burtleburtle.net/bob/hash/evahash.html
Use for hash table lookup, or anything where one collision in 2^32 is
acceptable. Do NOT use for cryptographic purposes.
--------------------------------------------------------------------
*/
ub4 lookup( k, length, level)
register ub1 *k; /* the key */
register ub4 length; /* the length of the key */
register ub4 level; /* the previous hash, or an arbitrary value */
{
register ub4 a,b,c,len;
/* Set up the internal state */
len = length;
a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
c = level; /* the previous hash value */
/*---------------------------------------- handle most of the key */
while (len >= 12)
{
a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24));
b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24));
c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24));
mix(a,b,c);
k += 12; len -= 12;
}
/*------------------------------------- handle the last 11 bytes */
c += length;
switch(len) /* all the case statements fall through */
{
case 11: c+=((ub4)k[10]<<24);
case 10: c+=((ub4)k[9]<<16);
case 9 : c+=((ub4)k[8]<<8);
/* the first byte of c is reserved for the length */
case 8 : b+=((ub4)k[7]<<24);
case 7 : b+=((ub4)k[6]<<16);
case 6 : b+=((ub4)k[5]<<8);
case 5 : b+=k[4];
case 4 : a+=((ub4)k[3]<<24);
case 3 : a+=((ub4)k[2]<<16);
case 2 : a+=((ub4)k[1]<<8);
case 1 : a+=k[0];
/* case 0: nothing left to add */
}
mix(a,b,c);
/*-------------------------------------------- report the result */
return c;
}
/*
--------------------------------------------------------------------
mixc -- mixc 8 4-bit values as quickly and thoroughly as possible.
Repeating mix() three times achieves avalanche.
Repeating mix() four times eliminates all funnels and all
characteristics stronger than 2^{-11}.
--------------------------------------------------------------------
*/
#define mixc(a,b,c,d,e,f,g,h) \
{ \
a^=b<<11; d+=a; b+=c; \
b^=c>>2; e+=b; c+=d; \
c^=d<<8; f+=c; d+=e; \
d^=e>>16; g+=d; e+=f; \
e^=f<<10; h+=e; f+=g; \
f^=g>>4; a+=f; g+=h; \
g^=h<<8; b+=g; h+=a; \
h^=a>>9; c+=h; a+=b; \
}
/*
--------------------------------------------------------------------
checksum() -- hash a variable-length key into a 256-bit value
k : the key (the unaligned variable-length array of bytes)
len : the length of the key, counting by bytes
state : an array of CHECKSTATE 4-byte values (256 bits)
The state is the checksum. Every bit of the key affects every bit of
the state. There are no funnels. About 112+6.875len instructions.
If you are hashing n strings (ub1 **)k, do it like this:
for (i=0; i<8; ++i) state[i] = 0x9e3779b9;
for (i=0, h=0; i<n; ++i) checksum( k[i], len[i], state);
(c) Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this
code any way you wish, private, educational, or commercial, as long
as this whole comment accompanies it.
See http://burtleburtle.net/bob/hash/evahash.html
Use to detect changes between revisions of documents, assuming nobody
is trying to cause collisions. Do NOT use for cryptography.
--------------------------------------------------------------------
*/
void checksum( k, len, state)
register ub1 *k;
register ub4 len;
register ub4 *state;
{
register ub4 a,b,c,d,e,f,g,h,length;
/* Use the length and level; add in the golden ratio. */
length = len;
a=state[0]; b=state[1]; c=state[2]; d=state[3];
e=state[4]; f=state[5]; g=state[6]; h=state[7];
/*---------------------------------------- handle most of the key */
while (len >= 32)
{
a += (k[0] +(k[1]<<8) +(k[2]<<16) +(k[3]<<24));
b += (k[4] +(k[5]<<8) +(k[6]<<16) +(k[7]<<24));
c += (k[8] +(k[9]<<8) +(k[10]<<16)+(k[11]<<24));
d += (k[12]+(k[13]<<8)+(k[14]<<16)+(k[15]<<24));
e += (k[16]+(k[17]<<8)+(k[18]<<16)+(k[19]<<24));
f += (k[20]+(k[21]<<8)+(k[22]<<16)+(k[23]<<24));
g += (k[24]+(k[25]<<8)+(k[26]<<16)+(k[27]<<24));
h += (k[28]+(k[29]<<8)+(k[30]<<16)+(k[31]<<24));
mixc(a,b,c,d,e,f,g,h);
mixc(a,b,c,d,e,f,g,h);
mixc(a,b,c,d,e,f,g,h);
mixc(a,b,c,d,e,f,g,h);
k += 32; len -= 32;
}
/*------------------------------------- handle the last 31 bytes */
h += length;
switch(len)
{
case 31: h+=(k[30]<<24);
case 30: h+=(k[29]<<16);
case 29: h+=(k[28]<<8);
case 28: g+=(k[27]<<24);
case 27: g+=(k[26]<<16);
case 26: g+=(k[25]<<8);
case 25: g+=k[24];
case 24: f+=(k[23]<<24);
case 23: f+=(k[22]<<16);
case 22: f+=(k[21]<<8);
case 21: f+=k[20];
case 20: e+=(k[19]<<24);
case 19: e+=(k[18]<<16);
case 18: e+=(k[17]<<8);
case 17: e+=k[16];
case 16: d+=(k[15]<<24);
case 15: d+=(k[14]<<16);
case 14: d+=(k[13]<<8);
case 13: d+=k[12];
case 12: c+=(k[11]<<24);
case 11: c+=(k[10]<<16);
case 10: c+=(k[9]<<8);
case 9 : c+=k[8];
case 8 : b+=(k[7]<<24);
case 7 : b+=(k[6]<<16);
case 6 : b+=(k[5]<<8);
case 5 : b+=k[4];
case 4 : a+=(k[3]<<24);
case 3 : a+=(k[2]<<16);
case 2 : a+=(k[1]<<8);
case 1 : a+=k[0];
}
mixc(a,b,c,d,e,f,g,h);
mixc(a,b,c,d,e,f,g,h);
mixc(a,b,c,d,e,f,g,h);
mixc(a,b,c,d,e,f,g,h);
/*-------------------------------------------- report the result */
state[0]=a; state[1]=b; state[2]=c; state[3]=d;
state[4]=e; state[5]=f; state[6]=g; state[7]=h;
}

29
gtp/lookupa.h Normal file
View File

@ -0,0 +1,29 @@
/*
------------------------------------------------------------------------------
By Bob Jenkins, September 1996.
lookupa.h, a hash function for table lookup, same function as lookup.c.
Use this code in any way you wish. Public Domain. It has no warranty.
Source is http://burtleburtle.net/bob/c/lookupa.h
------------------------------------------------------------------------------
*/
/* Uncommented by Jens Jakobsen 20020717
#ifndef STANDARD
#include "standard.h"
#endif
*/
#ifndef LOOKUPA
#define LOOKUPA
typedef unsigned long int ub4; /* unsigned 4-byte quantities */
typedef unsigned char ub1;
#define CHECKSTATE 8
#define hashsize(n) ((ub4)1<<(n))
#define hashmask(n) (hashsize(n)-1)
ub4 lookup(/*_ ub1 *k, ub4 length, ub4 level _*/);
void checksum(/*_ ub1 *k, ub4 length, ub4 *state _*/);
#endif /* LOOKUPA */

320
gtp/pdp.c Normal file
View File

@ -0,0 +1,320 @@
/*
* 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):
*
*/
/*
* pdp.c:
*
*/
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <string.h>
#include "pdp.h"
#include "lookupa.h"
/* ***********************************************************
* Global variables TODO: most should be moved to gsn_t
*************************************************************/
struct pdp_t pdpa[PDP_MAX]; /* PDP storage */
struct pdp_t* hashtid[PDP_MAX];/* Hash table for IMSI + NSAPI */
struct pdp_t* haship[PDP_MAX]; /* Hash table for IP and network interface */
/* ***********************************************************
* Functions related to PDP storage
*
* Lifecycle
* For a GGSN pdp context life begins with the reception of a
* create pdp context request. It normally ends with the reception
* of a delete pdp context request, but will also end with the
* reception of an error indication message.
* Provisions should probably be made for terminating pdp contexts
* based on either idle timeout, or by sending downlink probe
* messages (ping?) to see if the MS is still responding.
*
* For an SGSN pdp context life begins with the application just
* before sending off a create pdp context request. It normally
* ends when a delete pdp context response message is received
* from the GGSN, but should also end when with the reception of
* an error indication message.
*
*
* HASH Tables
*
* Downlink packets received in the GGSN are identified only by their
* network interface together with their destination IP address (Two
* network interfaces can use the same private IP address). Each IMSI
* (mobile station) can have several PDP contexts using the same IP
* address. In this case the traffic flow template (TFT) is used to
* determine the correct PDP context for a particular IMSI. Also it
* should be possible for each PDP context to use several IP adresses
* For fixed wireless access a mobile station might need a full class
* C network. Even in the case of several IP adresses the PDP context
* should be determined on the basis of the network IP address.
* Thus we need a hash table based on network interface + IP address.
*
* Uplink packets are for GTP0 identified by their IMSI and NSAPI, which
* is collectively called the tunnel identifier. There is also a 16 bit
* flow label that can be used for identification of uplink packets. This
* however is quite useless as it limits the number of contexts to 65536.
* For GTP1 uplink packets are identified by a Tunnel Endpoint Identifier
* (32 bit), or in some cases by the combination of IMSI and NSAPI.
* For GTP1 delete context requests there is a need to find the PDP
* contexts with the same IP address. This however can be done by using
* the IP hash table.
* Thus we need a hash table based on TID (IMSI and NSAPI). The TEID will
* be used for directly addressing the PDP context.
* pdp_newpdp
* Gives you a pdp context with no hash references In some way
* this should have a limited lifetime.
*
* pdp_freepdp
* Frees a context that was previously allocated with
* pdp_newpdp
*
*
* pdp_getpdpIP
* An incoming IP packet is uniquely identified by a pointer
* to a network connection (void *) and an IP address
* (struct in_addr)
*
* pdp_getpdpGTP
* An incoming GTP packet is uniquely identified by a the
* TID (imsi + nsapi (8 octets)) in or by the Flow Label
* (2 octets) in gtp0 or by the Tunnel Endpoint Identifier
* (4 octets) in gtp1.
*
* This leads to an architecture where the receiving GSN
* chooses a Flow Label or a Tunnel Endpoint Identifier
* when the connection is setup.
* Thus no hash table is needed for GTP lookups.
*
*************************************************************/
int pdp_init() {
memset(&pdpa, 0, sizeof(pdpa));
memset(&hashtid, 0, sizeof(hashtid));
memset(&haship, 0, sizeof(haship));
return 0;
}
int pdp_newpdp(struct pdp_t **pdp, uint64_t imsi, uint8_t nsapi,
struct pdp_t *pdp_old){
int n;
for (n=0; n<PDP_MAX; n++) { /* TODO: Need to do better than linear search */
if (pdpa[n].inuse == 0) {
*pdp = &pdpa[n];
if (NULL != pdp_old) memcpy(*pdp, pdp_old, sizeof(struct pdp_t));
else memset(*pdp, 0, sizeof(struct pdp_t));
(*pdp)->inuse = 1;
(*pdp)->imsi = imsi;
(*pdp)->nsapi = nsapi;
(*pdp)->fllc = (uint16_t) n;
(*pdp)->fllu = (uint16_t) n;
(*pdp)->teic_own = (uint32_t) n;
(*pdp)->teic_own = (uint32_t) n;
pdp_tidset(*pdp, pdp_gettid(imsi, nsapi));
return 0;
}
}
return EOF; /* No more available */
}
int pdp_freepdp(struct pdp_t *pdp){
pdp_tiddel(pdp);
memset(pdp, 0, sizeof(struct pdp_t));
/* Also need to clean up IP hash tables */
return 0;
}
int pdp_getpdp(struct pdp_t **pdp){
*pdp = &pdpa[0];
return 0;
}
int pdp_getgtp0(struct pdp_t **pdp, uint16_t fl){
if (fl>=PDP_MAX) {
return EOF; /* Not found */
}
else {
*pdp = &pdpa[fl];
if ((*pdp)->inuse) return 0;
else return EOF;
/* Context exists. We do no further validity checking. */
}
}
int pdp_getgtp1(struct pdp_t **pdp, uint32_t teid){
if (teid>=PDP_MAX) {
return -1; /* Not found */
}
else {
*pdp = &pdpa[teid];
return 0; /* We do no validity checking. */
}
}
int pdp_tidhash(uint64_t tid) {
return (lookup(&tid, sizeof(tid), 0) % PDP_MAX);
}
int pdp_tidset(struct pdp_t *pdp, uint64_t tid) {
int hash = pdp_tidhash(tid);
struct pdp_t *pdp2;
struct pdp_t *pdp_prev = NULL;
if (PDP_DEBUG) printf("Begin pdp_tidset tid = %llx\n", tid);
pdp->tid = tid;
for (pdp2 = hashtid[hash]; pdp2; pdp2 = pdp2->tidnext)
pdp_prev = pdp2;
if (!pdp_prev)
hashtid[hash] = pdp;
else
pdp_prev->tidnext = pdp;
if (PDP_DEBUG) printf("End pdp_tidset\n");
return 0;
}
int pdp_tiddel(struct pdp_t *pdp) {
int hash = pdp_tidhash(pdp->tid);
struct pdp_t *pdp2;
struct pdp_t *pdp_prev = NULL;
if (PDP_DEBUG) printf("Begin pdp_tiddel tid = %llx\n", pdp->tid);
for (pdp2 = hashtid[hash]; pdp2; pdp2 = pdp2->tidnext) {
if (pdp2 == pdp) {
if (!pdp_prev)
hashtid[hash] = pdp2->tidnext;
else
pdp_prev->tidnext = pdp2->tidnext;
if (PDP_DEBUG) printf("End pdp_tidset: PDP found\n");
return 0;
}
pdp_prev = pdp2;
}
if (PDP_DEBUG) printf("End pdp_tidset: PDP not found\n");
return EOF; /* End of linked list and not found */
}
int pdp_tidget(struct pdp_t **pdp, uint64_t tid) {
int hash = pdp_tidhash(tid);
struct pdp_t *pdp2;
if (PDP_DEBUG) printf("Begin pdp_tidget tid = %llx\n", tid);
for (pdp2 = hashtid[hash]; pdp2; pdp2 = pdp2->tidnext) {
if (pdp2->tid == tid) {
*pdp = pdp2;
if (PDP_DEBUG) printf("Begin pdp_tidget. Found\n");
return 0;
}
}
if (PDP_DEBUG) printf("Begin pdp_tidget. Not found\n");
return EOF; /* End of linked list and not found */
}
int pdp_iphash(void* ipif, struct ul66_t *eua) {
/*printf("IPhash %ld\n", lookup(eua->v, eua->l, ipif) % PDP_MAX);*/
return (lookup(eua->v, eua->l, ipif) % PDP_MAX);
}
int pdp_ipset(struct pdp_t *pdp, void* ipif, struct ul66_t *eua) {
int hash;
struct pdp_t *pdp2;
struct pdp_t *pdp_prev = NULL;
if (PDP_DEBUG) printf("Begin pdp_ipset %d %d %2x%2x%2x%2x\n",
(unsigned) ipif, eua->l,
eua->v[2], eua->v[3],
eua->v[4], eua->v[5]);
pdp->ipif = ipif;
pdp->eua.l = eua->l;
memcpy(pdp->eua.v, eua->v, eua->l);
hash = pdp_iphash(pdp->ipif, &pdp->eua);
for (pdp2 = haship[hash]; pdp2; pdp2 = pdp2->ipnext)
pdp_prev = pdp2;
if (!pdp_prev)
haship[hash] = pdp;
else
pdp_prev->ipnext = pdp;
if (PDP_DEBUG) printf("End pdp_ipset\n");
return 0;
}
int pdp_ipdel(struct pdp_t *pdp) {
int hash = pdp_iphash(pdp->ipif, &pdp->eua);
struct pdp_t *pdp2;
struct pdp_t *pdp_prev = NULL;
if (PDP_DEBUG) printf("Begin pdp_ipdel\n");
for (pdp2 = haship[hash]; pdp2; pdp2 = pdp2->ipnext) {
if (pdp2 == pdp) {
if (!pdp_prev)
haship[hash] = pdp2->ipnext;
else
pdp_prev->ipnext = pdp2->ipnext;
if (PDP_DEBUG) printf("End pdp_ipdel: PDP found\n");
return 0;
}
pdp_prev = pdp2;
}
if (PDP_DEBUG) printf("End pdp_ipdel: PDP not found\n");
return EOF; /* End of linked list and not found */
}
int pdp_ipget(struct pdp_t **pdp, void* ipif, struct ul66_t *eua) {
int hash = pdp_iphash(ipif, eua);
struct pdp_t *pdp2;
/*printf("Begin pdp_ipget %d %d %2x%2x%2x%2x\n", (unsigned)ipif, eua->l,
eua->v[2],eua->v[3],eua->v[4],eua->v[5]);*/
for (pdp2 = haship[hash]; pdp2; pdp2 = pdp2->ipnext) {
if ((pdp2->ipif == ipif) && (pdp2->eua.l == eua->l) &&
(memcmp(&pdp2->eua.v, &eua->v, eua->l) == 0)) {
*pdp = pdp2;
/*printf("End pdp_ipget. Found\n");*/
return 0;
}
}
if (PDP_DEBUG) printf("End pdp_ipget Notfound %d %d %2x%2x%2x%2x\n",
(unsigned)ipif, eua->l, eua->v[2],eua->v[3],eua->v[4],eua->v[5]);
return EOF; /* End of linked list and not found */
}
/* Various conversion functions */
int pdp_ntoeua(struct in_addr *src, struct ul66_t *eua) {
eua->l=6;
eua->v[0]=0xf1; /* IETF */
eua->v[1]=0x21; /* IPv4 */
memcpy(&eua->v[2], src, 4); /* Copy a 4 byte address */
return 0;
}
uint64_t pdp_gettid(uint64_t imsi, uint8_t nsapi) {
return (imsi & 0x0fffffffffffffff) + ((uint64_t)nsapi << 60);
}
int ulcpy(void* dst, void* src, size_t size) {
if (((struct ul255_t*)src)->l <= size) {
((struct ul255_t*)dst)->l = ((struct ul255_t*)src)->l;
memcpy(((struct ul255_t*)dst)->v, ((struct ul255_t*)src)->v,
((struct ul255_t*)dst)->l);
return 0;
}
else return EOF;
}

203
gtp/pdp.h Normal file
View File

@ -0,0 +1,203 @@
/*
* 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 _PDP_H
#define _PDP_H
#define PDP_MAX 1024 /* Max number of PDP contexts */
#define PDP_DEBUG 0 /* Print debug information */
/* GTP Information elements from 29.060 v3.9.0 7.7 Information Elements */
/* Also covers version 0. Note that version 0 6: QOS Profile was superceded *
* by 135: QOS Profile in version 1 */
struct sl_t {
int l;
char *v;
};
struct ul_t {
int l;
unsigned char *v;
};
struct ul16_t {
int l;
unsigned char v[16];
};
struct ul66_t {
int l;
unsigned char v[66];
};
struct ul255_t {
int l;
unsigned char v[255];
};
/* ***********************************************************
* Information storage for each PDP context
*
* Information storage for each PDP context is defined in
* 23.060 section 13.3 and 03.60. Includes IMSI, MSISDN, APN,
* PDP-type, PDP-address (IP address), sequence numbers, charging ID.
* For the SGSN it also includes radio related mobility
* information.
* The following structure is a combination of the storage
* requirements for each PDP context for the GGSN and SGSN.
* It contains both 23.060 as well as 03.60 parameters.
* Information is stored in the format for information elements
* described in 29.060 and 09.60.
* 31 * 4 + 15 structs + = 120 + 15 structs ~ 2k / context
* Structs: IP address 16+4 bytes (6), APN 255 bytes (2)
* QOS: 255 bytes (3), msisdn 16 bytes (1),
*
* TODO: We need to consider who manages the pdp_t hash tables
* Is it gtp_lib, or is it the application?
* I suppose that it will be gtp_lib.
* SGSN will ask gtplib for new pdp_t. Fill out the fields,
* and pass it on to gtp_create_pdp_req.
* GGSN will receive gtp_create_pdp_ind, create new pdp_t and
* send responce to SGSN.
* SGSN will receive response and gtplib will find the
* original pdp_t corresponding to the request. This will be
* passed on to the application.
* Eventually the SGSN will close the connection, and the
* pdp_t will be freed by gtplib in SGSN and GGSN
* This means that gtplib need to have functions to
* allocate, free, sort and find pdp_t
* (newpdp, freepdp, getpdp)
* Hash tables: TID, IMSI, IP etc.)
*************************************************************/
struct pdp_t {
/* Parameter determining if this PDP is in use. */
uint8_t inuse; /* 0=free. 1=used by somebody */
/* Pointers related to hash tables */
struct pdp_t *tidnext;
struct pdp_t *ipnext;
/* Parameters shared by all PDP context belonging to the same MS */
void *ipif; /* IP network interface */
void *asap; /* Application specific service access point */
uint64_t imsi; /* International Mobile Subscriber Identity.*/
struct ul16_t msisdn; /* The basic MSISDN of the MS. */
uint8_t mnrg; /* Indicates whether the MS is marked as not reachable for PS at the HLR. (1 bit, not transmitted) */
uint8_t cch_sub; /* The charging characteristics for the MS, e.g. normal, prepaid, flat-rate, and/or hot billing subscription. (not transmitted) */
uint16_t traceref; /* Identifies a record or a collection of records for a particular trace. */
uint16_t tracetype;/* Indicates the type of trace. */
struct ul_t triggerid;/* Identifies the entity that initiated the trace. */
struct ul_t omcid; /* Identifies the OMC that shall receive the trace record(s). */
uint8_t rec_hlr; /* Indicates if HLR or VLR is performing database recovery. (1 bit, not transmitted) */
/* Parameters specific to each individual PDP context */
uint8_t pdp_id; /* Index of the PDP context. (PDP context identifier) */
uint8_t pdp_state;/* PDP State Packet data protocol state, INACTIVE or ACTIVE. (1 bit, not transmitted) */
/* struct ul_t pdp_type; * PDP type; e.g. PPP or IP. */
/* struct ul_t pdp_addr; * PDP address; e.g. an IP address. */
struct ul66_t eua; /* End user address. PDP type and address combined */
uint8_t pdp_dyn; /* Indicates whether PDP Address is static or dynamic. (1 bit, not transmitted) */
struct ul255_t apn_req;/* The APN requested. */
struct ul255_t apn_sub;/* The APN received from the HLR. */
struct ul255_t apn_use;/* The APN Network Identifier currently used. */
uint8_t nsapi; /* Network layer Service Access Point Identifier. (4 bit) */
uint16_t ti; /* Transaction Identifier. (4 or 12 bit) */
uint32_t teic_own; /* (Own Tunnel Endpoint Identifier Control) */
uint32_t teid_own; /* (Own Tunnel Endpoint Identifier Data I) */
uint32_t teic_gn; /* Tunnel Endpoint Identifier for the Gn and Gp interfaces. (Control plane) */
uint32_t teid_gn; /* Tunnel Endpoint Identifier for the Gn and Gp interfaces. (Data I) */
uint32_t tei_iu; /* Tunnel Endpoint Identifier for the Iu interface. */
uint16_t fllc; /* (Local Flow Label Control, gtp0) */
uint16_t fllu; /* (Local Flow Label Data I, gtp0) */
uint16_t flrc; /* (Remote gn/gp Flow Label Control, gtp0) */
uint16_t flru; /* (Remote gn/gp Flow Label Data I, gtp0) */
struct ul_t tft; /* Traffic flow template. */
/*struct ul16_t sgsnc; * The IP address of the SGSN currently serving this MS. (Control plane) */
/*struct ul16_t sgsnu; * The IP address of the SGSN currently serving this MS. (User plane) */
/*struct ul16_t ggsnc; * The IP address of the GGSN currently used. (Control plane) */
/*struct ul16_t ggsnu; * The IP address of the GGSN currently used. (User plane) */
struct ul16_t gsnlc; /* The IP address of the local GSN. (Control plane) */
struct ul16_t gsnlu; /* The IP address of the local GSN. (User plane) */
struct ul16_t gsnrc; /* The IP address of the remote GSN. (Control plane) */
struct ul16_t gsnru; /* The IP address of the remote GSN. (User plane) */
uint8_t vplmn_allow; /* Specifies whether the MS is allowed to use the APN in the domain of the HPLMN only, or additionally the APN in the domain of the VPLMN. (1 bit) */
uint8_t qos_sub0[3]; /* The quality of service profile subscribed. */
uint8_t qos_req0[3]; /* The quality of service profile requested. */
uint8_t qos_neg0[3]; /* The quality of service profile negotiated. */
struct ul255_t qos_sub; /* The quality of service profile subscribed. */
struct ul255_t qos_req; /* The quality of service profile requested. */
struct ul255_t qos_neg; /* The quality of service profile negotiated. */
uint8_t radio_pri;/* The RLC/MAC radio priority level for uplink user data transmission. (4 bit) */
uint16_t flow_id; /* Packet flow identifier. */
/* struct ul_t bssqos_neg; * The aggregate BSS quality of service profile negotiated for the packet flow that this PDP context belongs to. (NOT GTP)*/
uint8_t sndcpd; /* SNDCP sequence number of the next downlink N-PDU to be sent to the MS. */
uint8_t sndcpu; /* SNDCP sequence number of the next uplink N-PDU expected from the MS. */
uint8_t rec_sgsn; /* Indicates if the SGSN is performing database recovery. (1 bit, not transmitted) */
/* uint16_t gtpsnd; GTP-U sequence number of the next downlink N-PDU to be sent to the SGSN / received from the GGSN. */
/* uint16_t gtpsnu; GTP-U sequence number of the next uplink N-PDU to be received from the SGSN / sent to the GGSN */
uint16_t gtpsntx; /* GTP-U sequence number of the next downlink N-PDU to be sent (09.60 section 8.1.1.1) */
uint16_t gtpsnrx; /* GTP-U sequence number of the next uplink N-PDU to be received (09.60 section 8.1.1.1) */
uint8_t pdcpsndd; /* Sequence number of the next downlink in-sequence PDCP-PDU to be sent to the MS. */
uint8_t pdcpsndu; /* Sequence number of the next uplink in-sequence PDCP-PDU expected from the MS. */
uint32_t cid; /* Charging identifier, identifies charging records generated by SGSN and GGSN. */
uint16_t cch_pdp; /* The charging characteristics for this PDP context, e.g. normal, prepaid, flat-rate, and/or hot billing. */
struct ul16_t rnc_addr;/* The IP address of the RNC currently used. */
uint8_t reorder; /* Specifies whether the GGSN shall reorder N-PDUs received from the SGSN / Specifies whether the SGSN shall reorder N-PDUs before delivering the N-PSUs to the MS. (1 bit) */
struct ul255_t pco_req; /* Requested packet control options. */
struct ul255_t pco_neg; /* Negotiated packet control options. */
uint32_t selmode; /* Selection mode. */
uint64_t tid; /* (Combination of imsi and nsapi) */
};
/* functions related to pdp_t management */
int pdp_init();
int pdp_newpdp(struct pdp_t **pdp, uint64_t imsi, uint8_t nsapi,
struct pdp_t *pdp_old);
int pdp_freepdp(struct pdp_t *pdp);
int pdp_getpdp(struct pdp_t **pdp);
int pdp_getgtp0(struct pdp_t **pdp, uint16_t fl);
int pdp_getgtp1(struct pdp_t **pdp, uint32_t teid);
int pdp_tidhash(uint64_t tid);
int pdp_tidset(struct pdp_t *pdp, uint64_t tid);
int pdp_tiddel(struct pdp_t *pdp);
int pdp_tidget(struct pdp_t **pdp, uint64_t tid);
int pdp_iphash(void* ipif, struct ul66_t *eua);
int pdp_ipset(struct pdp_t *pdp, void* ipif, struct ul66_t *eua);
int pdp_ipdel(struct pdp_t *pdp);
int pdp_ipget(struct pdp_t **pdp, void* ipif, struct ul66_t *eua);
int pdp_ntoeua(struct in_addr *src, struct ul66_t *eua);
uint64_t pdp_gettid(uint64_t imsi, uint8_t nsapi);
int ulcpy(void* dst, void* src, size_t size);
#endif /* !_PDP_H */

249
gtp/queue.c Normal file
View File

@ -0,0 +1,249 @@
/*
* 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):
*
*/
/*
* Queue.c
* Reliable delivery of signalling messages
*/
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <string.h>
#include "pdp.h"
#include "gtp.h"
#include "queue.h"
int queue_print(struct queue_t *queue) {
int n;
printf("Queue: %x Next: %d First: %d Last: %d\n", (int) queue, queue->next, queue->first, queue->last);
printf("# State seq next prev timeout retrans\n");
for (n=0; n<QUEUE_SIZE; n++) {
printf("%d %d %d %d %d %d %d\n",
n,
queue->qmsga[n].state,
queue->qmsga[n].seq,
queue->qmsga[n].next,
queue->qmsga[n].prev,
(int) queue->qmsga[n].timeout,
queue->qmsga[n].retrans);
}
return 0;
}
int queue_seqhash(struct sockaddr_in *peer, uint16_t seq) {
/* With QUEUE_HASH_SIZE = 2^16 this describes all possible
seq values. Thus we have perfect hash for the request queue.
For the response queue we might have collisions, but not very
often.
For performance optimisation we should remove the modulus
operator, but this is only valid for QUEUE_HASH_SIZE = 2^16 */
return seq % QUEUE_HASH_SIZE;
}
int queue_seqset(struct queue_t *queue, struct qmsg_t *qmsg,
struct sockaddr_in *peer, uint16_t seq) {
int hash = queue_seqhash(peer, seq);
struct qmsg_t *qmsg2;
struct qmsg_t *qmsg_prev = NULL;
if (QUEUE_DEBUG) printf("Begin queue_seqset seq = %d\n", (int) seq);
if (QUEUE_DEBUG) printf("SIZEOF PEER %d, *PEER %d\n", sizeof(peer), sizeof(*peer));
qmsg->seq = seq;
memcpy(&qmsg->peer, peer, sizeof(*peer));
for (qmsg2 = queue->hashseq[hash]; qmsg2; qmsg2 = qmsg2->seqnext)
qmsg_prev = qmsg2;
if (!qmsg_prev)
queue->hashseq[hash] = qmsg;
else
qmsg_prev->seqnext = qmsg;
if (QUEUE_DEBUG) printf("End queue_seqset\n");
return 0;
}
int queue_seqdel(struct queue_t *queue, struct qmsg_t *qmsg) {
int hash = queue_seqhash(&qmsg->peer, qmsg->seq);
struct qmsg_t *qmsg2;
struct qmsg_t *qmsg_prev = NULL;
if (QUEUE_DEBUG) printf("Begin queue_seqdel seq = %d\n", (int) qmsg->seq);
for (qmsg2 = queue->hashseq[hash]; qmsg2; qmsg2 = qmsg2->seqnext) {
if (qmsg == qmsg) {
if (!qmsg_prev)
queue->hashseq[hash] = qmsg2->seqnext;
else
qmsg_prev->seqnext = qmsg2->seqnext;
if (QUEUE_DEBUG) printf("End queue_seqset: SEQ found\n");
return 0;
}
qmsg_prev = qmsg2;
}
printf("End queue_seqset: SEQ not found\n");
return EOF; /* End of linked list and not found */
}
/* Allocates and initialises new queue structure */
int queue_new(struct queue_t **queue) {
if (QUEUE_DEBUG) printf("queue_new\n");
*queue = calloc(1, sizeof(struct queue_t));
(*queue)->next = 0;
(*queue)->first = -1;
(*queue)->last = -1;
if (QUEUE_DEBUG) queue_print(*queue);
if (*queue) return 0;
else return EOF;
}
/* Deallocates queue structure */
int queue_free(struct queue_t *queue) {
if (QUEUE_DEBUG) printf("queue_free\n");
if (QUEUE_DEBUG) queue_print(queue);
free(queue);
return 0;
}
int queue_newmsg(struct queue_t *queue, struct qmsg_t **qmsg,
struct sockaddr_in *peer, uint16_t seq) {
if (QUEUE_DEBUG) printf("queue_newmsg %d\n", (int) seq);
if (queue->qmsga[queue->next].state == 1) {
return EOF; /* Queue is full */
}
else {
*qmsg = &queue->qmsga[queue->next];
queue_seqset(queue, *qmsg, peer, seq);
(*qmsg)->state = 1; /* Space taken */
(*qmsg)->this = queue->next;
(*qmsg)->next=-1; /* End of the queue */
(*qmsg)->prev=queue->last; /* Link to the previous */
queue->qmsga[queue->last].next=queue->next; /* Link previous to us */
queue->last = queue->next; /* End of queue */
if (queue->first == -1) queue->first = queue->next;
queue->next = (queue->next+1) % QUEUE_SIZE; /* Increment */
if (QUEUE_DEBUG) queue_print(queue);
return 0;
}
}
int queue_freemsg(struct queue_t *queue, struct qmsg_t *qmsg) {
if (QUEUE_DEBUG) printf("queue_freemsg\n");
if (qmsg->state != 1) {
return EOF; /* Not in queue */
}
queue_seqdel(queue, qmsg);
if (qmsg->next == -1) /* Are we the last in queue? */
queue->last = qmsg->prev;
else
queue->qmsga[qmsg->next].prev = qmsg->prev;
if (qmsg->prev == -1) /* Are we the first in queue? */
queue->first = qmsg->next;
else
queue->qmsga[qmsg->prev].next = qmsg->next;
memset(qmsg, 0, sizeof(struct qmsg_t)); /* Just to be safe */
if (QUEUE_DEBUG) queue_print(queue);
return 0;
}
int queue_back(struct queue_t *queue, struct qmsg_t *qmsg) {
if (QUEUE_DEBUG) printf("queue_back\n");
if (qmsg->state != 1) {
return EOF; /* Not in queue */
}
/* Insert stuff to maintain hash table */
if (qmsg->next != -1) {/* Only swop if there are others */
queue->qmsga[qmsg->next].prev = qmsg->prev;
queue->first = qmsg->next;
qmsg->next = -1;
qmsg->prev = queue->last;
if (queue->last != -1) queue->qmsga[queue->last].next = qmsg->this;
queue->last = qmsg->this;
}
if (QUEUE_DEBUG) queue_print(queue);
return 0;
}
/* Get the element with a particular sequence number */
int queue_getfirst(struct queue_t *queue, struct qmsg_t **qmsg) {
/*printf("queue_getfirst\n");*/
if (queue->first == -1) {
*qmsg = NULL;
return EOF; /* End of queue = queue is empty. */
}
*qmsg = &queue->qmsga[queue->first];
if (QUEUE_DEBUG) queue_print(queue);
return 0;
}
int queue_getseqx(struct queue_t *queue, struct qmsg_t **qmsg,
struct sockaddr_in *peer, uint16_t seq) {
int n;
if (QUEUE_DEBUG) printf("queue_getseq, %d\n", (int) seq);
if (QUEUE_DEBUG) queue_print(queue);
for (n=0; n<QUEUE_SIZE; n++) {
if ((queue->qmsga[n].seq == seq) &&
(!memcmp(&queue->qmsga[n].peer, peer, sizeof(*peer)))) {
*qmsg = &queue->qmsga[n];
return 0;
}
}
return EOF; /* Not found */
}
int queue_seqget(struct queue_t *queue, struct qmsg_t **qmsg,
struct sockaddr_in *peer, uint16_t seq) {
int hash = queue_seqhash(peer, seq);
struct qmsg_t *qmsg2;
if (QUEUE_DEBUG) printf("Begin queue_seqget seq = %d\n", (int) seq);
for (qmsg2 = queue->hashseq[hash]; qmsg2; qmsg2 = qmsg2->seqnext) {
if ((qmsg2->seq == seq) &&
(!memcmp(&qmsg2->peer, peer, sizeof(*peer)))) {
*qmsg = qmsg2;
if (QUEUE_DEBUG) printf("End queue_seqget. Found\n");
return 0;
}
}
if (QUEUE_DEBUG) printf("End queue_seqget. Not found\n");
return EOF; /* End of linked list and not found */
}
int queue_freemsg_seq(struct queue_t *queue, struct sockaddr_in *peer,
uint16_t seq, uint8_t *type, void **aid) {
struct qmsg_t *qmsg;
if (queue_seqget(queue, &qmsg, peer, seq)) {
*aid = NULL;
*type = 0;
return EOF;
}
*aid = qmsg->aid;
*type = qmsg->type;
if (queue_freemsg(queue, qmsg)) {
return EOF;
}
return 0;
}

77
gtp/queue.h Normal file
View File

@ -0,0 +1,77 @@
/*
* 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):
*
*/
/*
* Queue.c
* Reliable delivery of signalling messages
*/
#ifndef _QUEUE_H
#define _QUEUE_H
#define QUEUE_DEBUG 0 /* Print debug information */
#define QUEUE_SIZE 256 /* Size of retransmission queue */
#define QUEUE_HASH_SIZE 65536 /* Size of hash table (2^16) */
struct qmsg_t { /* Holder for queued packets */
int state; /* 0=empty, 1=full */
uint16_t seq; /* The sequence number */
u_int8_t type; /* The type of packet */
void *aid; /* Application specific pointer */
union gtp_packet p; /* The packet stored */
int l; /* Length of the packet */
struct sockaddr_in peer;/* Address packet was sent to / received from */
struct qmsg_t *seqnext; /* Pointer to next in sequence hash list */
int next; /* Pointer to the next in queue. -1: Last */
int prev; /* Pointer to the previous in queue. -1: First */
int this; /* Pointer to myself */
time_t timeout; /* When do we retransmit this packet? */
int retrans; /* How many times did we retransmit this? */
};
struct queue_t {
struct qmsg_t qmsga[QUEUE_SIZE]; /* Array holding signalling messages */
void *hashseq[QUEUE_HASH_SIZE]; /* Hash array */
int next; /* Next location in queue to use */
int first; /* First packet in queue (oldest timeout) */
int last; /* Last packet in queue (youngest timeout) */
};
/* Allocates and initialises new queue structure */
int queue_new(struct queue_t **queue);
/* Deallocates queue structure */
int queue_free(struct queue_t *queue);
/* Find a new queue element. Return EOF if allready full */
int queue_newmsg(struct queue_t *queue, struct qmsg_t **qmsg,
struct sockaddr_in *peer, uint16_t seq);
/* Remove an element from the queue. */
int queue_freemsg(struct queue_t *queue, struct qmsg_t *qmsg);
/* Move an element to the back of the queue */
int queue_back(struct queue_t *queue, struct qmsg_t *qmsg);
/* Get the first element in the queue (oldest) */
int queue_getfirst(struct queue_t *queue, struct qmsg_t **qmsg);
/* Get the element with a particular sequence number */
int queue_seqget(struct queue_t *queue, struct qmsg_t **qmsg,
struct sockaddr_in *peer, uint16_t seq);
/* Free message based on sequence number */
int queue_freemsg_seq(struct queue_t *queue, struct sockaddr_in *peer,
uint16_t seq, uint8_t *type, void **aid);
#endif /* !_QUEUE_H */

0
intl/Makefile Normal file
View File

0
intl/Makefile.in Normal file
View File

4288
libtool Executable file

File diff suppressed because it is too large Load Diff

0
po/Makefile Normal file
View File

33
sgsnemu/.deps/cmdline.P Normal file
View File

@ -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 :

107
sgsnemu/.deps/pptpstuff.P Normal file
View File

@ -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 :

157
sgsnemu/.deps/sgsnemu.P Normal file
View File

@ -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 :

View File

@ -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 :

108
sgsnemu/.deps/tun.P Normal file
View File

@ -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 :

343
sgsnemu/Makefile Normal file
View File

@ -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:

11
sgsnemu/Makefile.am Normal file
View File

@ -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

343
sgsnemu/Makefile.in Normal file
View File

@ -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:

776
sgsnemu/cmdline.c Normal file
View File

@ -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;
}

37
sgsnemu/cmdline.ggo Normal file
View File

@ -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

77
sgsnemu/cmdline.h Normal file
View File

@ -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 */

1
sgsnemu/ggsn_restart Normal file
View File

@ -0,0 +1 @@
51

754
sgsnemu/sgsnemu.c Normal file
View File

@ -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;
}

1
sgsnemu/sgsnemu.pid Normal file
View File

@ -0,0 +1 @@
14305

128
sgsnemu/tun.c Normal file
View File

@ -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);
}

48
sgsnemu/tun.h Normal file
View File

@ -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 */

0
src/Makefile Normal file
View File

0
tests/Makefile Normal file
View File

0
tests/Makefile.in Normal file
View File

24
version Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
#
# Little shell script to grab current version number from configure.in
#
# $Id: version,v 1.1 2002/12/16 13:33:52 jjako Exp $
VER=`grep AM_INIT_AUTOMAKE configure.in | awk -F'[(),]' '{print $3}'`
if [ "$1" == "-VERSION" ]
then
echo $VER | awk -F'.' '{print $1}'
exit
fi
if [ "$1" == "-PATCHLEVEL" ]
then
echo $VER | awk -F'.' '{print $2}'
exit
fi
if [ "$1" == "-SUBLEVEL" ]
then
echo $VER | awk -F'.' '{print $3}'
exit
fi
echo $VER
exit