Initial revision

This commit is contained in:
Thomas Ries 2002-08-24 17:53:58 +00:00
parent 379443665b
commit a82f8837fa
31 changed files with 6365 additions and 0 deletions

0
AUTHORS Normal file
View File

340
COPYING Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 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
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) <year> <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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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) year 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.

9
ChangeLog Normal file
View File

@ -0,0 +1,9 @@
0.1.1
=====
- 24-Aug-2002: Imlemented handling of a config file,
obsoletes siproxd_conf.h
0.1.0
=====
- 19-Aug-2002: Released version 0.1.0

182
INSTALL Normal file
View File

@ -0,0 +1,182 @@
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.

24
Makefile.am Normal file
View File

@ -0,0 +1,24 @@
#
# Copyright (C) 2002 Thomas Ries <tries@gmx.net>
#
# This file is part of Siproxd.
#
# Siproxd 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.
#
# Siproxd 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 Siproxd; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
SUBDIRS = src doc
EXTRA_DIST = TODO

377
Makefile.in Normal file
View File

@ -0,0 +1,377 @@
# Makefile.in generated automatically by automake 1.4a 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.
#
# Copyright (C) 2002 Thomas Ries <tries@gmx.net>
#
# This file is part of Siproxd.
#
# Siproxd 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.
#
# Siproxd 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 Siproxd; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
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@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_FLAG =
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
AWK = @AWK@
CC = @CC@
LN_S = @LN_S@
MAKEINFO = @MAKEINFO@
PACKAGE = @PACKAGE@
VERSION = @VERSION@
SUBDIRS = src doc
EXTRA_DIST = TODO
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/scripts/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \
Makefile.am Makefile.in NEWS TODO aclocal.m4 config.h.in configure \
configure.in
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)
config.h: stamp-h
@if test ! -f $@; then \
rm -f stamp-h; \
$(MAKE) stamp-h; \
else :; fi
stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES= CONFIG_HEADERS=config.h \
$(SHELL) ./config.status
@echo timestamp > stamp-h 2> /dev/null
$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
@if test ! -f $@; then \
rm -f $(srcdir)/stamp-h.in; \
$(MAKE) $(srcdir)/stamp-h.in; \
else :; fi
$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOHEADER)
@echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
mostlyclean-hdr:
clean-hdr:
distclean-hdr:
-rm -f config.h
maintainer-clean-hdr:
# 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) config.h.in $(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)config.h.in$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$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
all-recursive-am: config.h
$(MAKE) $(AM_MAKEFLAGS) all-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 config.h
all-redirect: all-recursive-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-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-hdr mostlyclean-tags mostlyclean-generic
mostlyclean: mostlyclean-recursive
clean-am: clean-hdr clean-tags clean-generic mostlyclean-am
clean: clean-recursive
distclean-am: distclean-hdr distclean-tags distclean-generic clean-am
distclean: distclean-recursive
-rm -f config.status
maintainer-clean-am: maintainer-clean-hdr 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: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
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 all-recursive-am \
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

98
README Normal file
View File

@ -0,0 +1,98 @@
Be warned, this (and all the other) documentantation is far from
complete. This is just *very* preliminary pre-alpha release. Don't
expect anything!
Overview:
=========
Siprox is an proxy/masquerading daemon for the SIP protocol.
It handles registrations of SIP clients on a private IP network
and performs rewriting of the SIP message bodies to make SIP
connections possible via an masquerading firewall.
It allows SIP clients (like kphone, linphone) to work behind
an IP masquerading firewall or router.
SIP (Session Initiation Protocol, RFC2543) is used by Softphones
(Voice over IP) to initiate communication. By itself, SIP does not
work via masquerading firewalls as the transfered data contains
IP addresses and port numbers.
Requirements:
=============
- libosip-0.8.8 (http://www.fsf.org/software/osip/)
Up to now, this packages only has been tested under an i386 Redhat Linux 6.0.
However, it should build and run under newer versions.
How to get started:
===================
- ./configure
- make
- make install
- copy sipproxd.conf.example to /etc/siproxd.conf
- edit /etc/siproxd.conf according to your situation
At least 'host_inbound' and 'host_outbound' have to be adapted!
host_inbound is your IP address of your private network,
host_outbound is your publich IP address or hostname (if you
have dynamic IP addresses, then you might want to use a hostname
here and use a dynamic DNS service like dyndns.org)
!! ACTUALLY, THIS IS NOT YET TRUE. The configuration of INBOUND
and OUTBOUND host ist still a compile time issue...
Edit the file siproxd_conf.h accordingly. Support for the
config file will be very next.
What siproxd does:
=================
Siproxd's main purpose (up to now) is to rewrite SIP messages.
What siproxd does NOT do:
=========================
Siproxd does *not* (yet) create masquerading tunnels or port-forwarding
for the data stream through the firewall.
These forwarding rules have to be set-up manually.
Example, using ipchains (mfw):
# ipchains -A input --proto udp --dport 7078 -m 100 -j ACCEPT
# ipmasqadm mfw -A -m 100 -r <remoteaddress> 7078
Example, using ipchains (portfw):
# portfw -a -P udp -L <localaddress> 7078 -R <remoteaddress> 7078
Limitations:
============
- currently, only UDP is supported
- very likely it does not follow the SIP spec in all details ;-)
Important Notice:
=================
gethostbyname() leaks memory in RedHat 6.0 with glibc 2.1.1.
The gethostbyname() function leaks memory in RedHat 6.0 with glibc 2.1.1.
The quick fix is to delete nisplus service from hosts entry in
/etc/nsswitch.conf. In my tests, memory use remained stable
after I made the above change.
(->http://www.squid-cache.org/Doc/FAQ/FAQ-14.html)
Contacts:
=========
Thomas Ries <tries@gmx.net>

14
TODO Normal file
View File

@ -0,0 +1,14 @@
TODOs, in anarchistic order:
============================
- support for configuration file!
- 2.2.x kernels:
make use of the portfw.so (ipmasqadm package) to create forwarding
tunnels for incomming data streams
How to determine when finished? Is it possible to keep it stateless?
- Is there a possibility to open up an masquerading tunnel by
a userspace program on the firewall?

129
aclocal.m4 vendored Normal file
View File

@ -0,0 +1,129 @@
dnl aclocal.m4 generated automatically by aclocal 1.4a
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.
# Like AC_CONFIG_HEADER, but automatically create stamp file.
AC_DEFUN(AM_CONFIG_HEADER,
[AC_PREREQ([2.12])
AC_CONFIG_HEADER([$1])
dnl When config.status generates a header, we must update the stamp-h file.
dnl This file resides in the same directory as the config header
dnl that is generated. We must strip everything past the first ":",
dnl and everything past the last "/".
AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
<<am_indx=1
for am_file in <<$1>>; do
case " <<$>>CONFIG_HEADERS " in
*" <<$>>am_file "*<<)>>
echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
;;
esac
am_indx=`expr "<<$>>am_indx" + 1`
done<<>>dnl>>)
changequote([,]))])
# 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])
dnl We require 2.13 because we rely on SHELL being computed by configure.
AC_PREREQ([2.13])
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)])

56
config.h.in Normal file
View File

@ -0,0 +1,56 @@
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* Define to empty if the keyword does not work. */
#undef const
/* Define if you don't have vprintf but do have _doprnt. */
#undef HAVE_DOPRNT
/* Define if you have the vprintf function. */
#undef HAVE_VPRINTF
/* 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 if your <sys/time.h> declares struct tm. */
#undef TM_IN_SYS_TIME
/* 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 strerror function. */
#undef HAVE_STRERROR
/* Define if you have the strstr function. */
#undef HAVE_STRSTR
/* Define if you have the <stdarg.h> header file. */
#undef HAVE_STDARG_H
/* Define if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if you have the <varargs.h> header file. */
#undef HAVE_VARARGS_H
/* Define if you have the osip library (-losip). */
#undef HAVE_LIBOSIP
/* Name of package */
#undef PACKAGE
/* Version number of package */
#undef VERSION

2192
configure vendored Executable file

File diff suppressed because it is too large Load Diff

45
configure.in Normal file
View File

@ -0,0 +1,45 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/siproxd.c)
dnl ******************************************************************
dnl
SPD_MAJOR_VERSION=0
SPD_MINOR_VERSION=1
SPD_MICRO_VERSION=1
SPD_VERSION=$SPD_MAJOR_VERSION.$SPD_MINOR_VERSION.$SPD_MICRO_VERSION
dnl *********************************************************************
dnl Initialize automake stuff
AC_CONFIG_AUX_DIR(scripts)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(siproxd, $SPD_VERSION)
dnl Checks for programs.
AC_PROG_AWK
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
dnl Checks for libraries.
AC_CHECK_LIB(osip, parser_init)
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/time.h unistd.h)
AC_CHECK_HEADERS(stdarg.h varargs.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM
dnl Checks for library functions.
AC_FUNC_MEMCMP
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(select socket strerror strstr)
AC_OUTPUT(Makefile \
src/Makefile \
doc/Makefile \
)

22
doc/Makefile.am Normal file
View File

@ -0,0 +1,22 @@
#
# Copyright (C) 2002 Thomas Ries <tries@gmx.net>
#
# This file is part of Siproxd.
#
# Siproxd 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.
#
# Siproxd 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 Siproxd; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
EXTRA_DIST = siproxd.conf.example

195
doc/Makefile.in Normal file
View File

@ -0,0 +1,195 @@
# Makefile.in generated automatically by automake 1.4a 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.
#
# Copyright (C) 2002 Thomas Ries <tries@gmx.net>
#
# This file is part of Siproxd.
#
# Siproxd 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.
#
# Siproxd 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 Siproxd; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
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@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_FLAG =
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
AWK = @AWK@
CC = @CC@
LN_S = @LN_S@
MAKEINFO = @MAKEINFO@
PACKAGE = @PACKAGE@
VERSION = @VERSION@
EXTRA_DIST = siproxd.conf.example
mkinstalldirs = $(SHELL) $(top_srcdir)/scripts/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
DIST_COMMON = Makefile.am Makefile.in
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 doc/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
tags: TAGS
TAGS:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = doc
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 doc/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
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-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: uninstall-am
all-am: Makefile
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
installdirs:
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-generic
mostlyclean: mostlyclean-am
clean-am: clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-generic clean-am
distclean: distclean-am
maintainer-clean-am: 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: 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 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:

44
doc/siproxd.conf.example Normal file
View File

@ -0,0 +1,44 @@
#
# /etc/siproxd.conf - siproxd configuration file
#
# !! This is a sample file, adapt it to your needs before using it
#
######################################################################
# DBCLASS_BABBLE 0x00000001 // babble (like entering/leaving fnc)
# DBCLASS_NET 0x00000002 // network
# DBCLASS_SIP 0x00000004 // SIP manipulations
# DBCLASS_REG 0x00000008 // Client registration
# DBCLASS_NOSPEC 0x00000010 // non specified class
# DBCLASS_PROXY 0x00000020 // proxy
# DBCLASS_DNS 0x00000040 // DNS stuff
# DBCLASS_NETTRAF 0x00000080 // network traffic
# DBCLASS_CONFIG 0x00000100 // configuration
debug_level = 0x0ffffffe
######################################################################
# The IP addresses of the INBOUND and OUTBOUND interface can
# be specified as hostnames or in dotted decimal form:
#
# host_inbound=foo.bar.org
#
# or as dotted decimal IP:
#
# host_inbound=10.0.0.1
host_inbound = 192.168.1.8
host_outbound = ries.homeip.net
######################################################################
# Port to listen for incomming SIP messages.
# 5060 is usually the correct choise - don't change is unless you
# know what you're doing
sip_port = 5060
######################################################################
# Shall we daemonize?
daemonize = 0

251
scripts/install-sh Executable file
View File

@ -0,0 +1,251 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

190
scripts/missing Executable file
View File

@ -0,0 +1,190 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
# 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, 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., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
case "$1" in
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing - GNU libit 0.0"
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
aclocal)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acinclude.m4' or \`configure.in'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`configure.in'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acconfig.h' or \`configure.in'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequirements for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0

40
scripts/mkinstalldirs Executable file
View File

@ -0,0 +1,40 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain
# $Id$
errstatus=0
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# mkinstalldirs ends here

46
src/Makefile.am Normal file
View File

@ -0,0 +1,46 @@
#
# Copyright (C) 2002 Thomas Ries <tries@gmx.net>
#
# This file is part of Siproxd.
#
# Siproxd 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.
#
# Siproxd 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 Siproxd; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
CFLAGS =@CFLAGS@ -Wall -DBUILDSTR=\"`cat .buildno`\"
bin_PROGRAMS = siproxd
siproxd_SOURCES = siproxd.c proxy.c register.c sock.c utils.c \
log.c readconf.c
noinst_HEADERS = log.h siproxd.h
EXTRA_DIST = .buildno
#
# count BUILDs - each time increment by one and define the
# C macro BUILDNO. bing it to a file everybody includes (log.h)
#
log.h: increment_build
increment_build:
@echo "incrementing BUILD number"
@if [ -f .buildno ]; then \
bld=`cat .buildno`; \
bld=`expr $${bld} + 1`; \
else \
bld=1; \
fi; \
echo "$${bld}" >.buildno;

357
src/Makefile.in Normal file
View File

@ -0,0 +1,357 @@
# Makefile.in generated automatically by automake 1.4a 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.
#
# Copyright (C) 2002 Thomas Ries <tries@gmx.net>
#
# This file is part of Siproxd.
#
# Siproxd 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.
#
# Siproxd 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 Siproxd; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
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@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_FLAG =
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
AWK = @AWK@
CC = @CC@
LN_S = @LN_S@
MAKEINFO = @MAKEINFO@
PACKAGE = @PACKAGE@
VERSION = @VERSION@
CFLAGS = @CFLAGS@ -Wall -DBUILDSTR=\"`cat .buildno`\"
bin_PROGRAMS = siproxd
siproxd_SOURCES = siproxd.c proxy.c register.c sock.c utils.c log.c readconf.c
noinst_HEADERS = log.h siproxd.h
EXTRA_DIST = .buildno
mkinstalldirs = $(SHELL) $(top_srcdir)/scripts/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
PROGRAMS = $(bin_PROGRAMS)
DEFS = @DEFS@ -I. -I$(srcdir) -I..
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
siproxd_OBJECTS = siproxd.o proxy.o register.o sock.o utils.o log.o \
readconf.o
siproxd_LDADD = $(LDADD)
siproxd_DEPENDENCIES =
siproxd_LDFLAGS =
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
HEADERS = $(noinst_HEADERS)
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
DEP_FILES = .deps/log.P .deps/proxy.P .deps/readconf.P .deps/register.P \
.deps/siproxd.P .deps/sock.P .deps/utils.P
SOURCES = $(siproxd_SOURCES)
OBJECTS = $(siproxd_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .o .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu src/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 " $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
$(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$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:
siproxd: $(siproxd_OBJECTS) $(siproxd_DEPENDENCIES)
@rm -f siproxd
$(LINK) $(siproxd_LDFLAGS) $(siproxd_OBJECTS) $(siproxd_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 = src
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 src/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) $(HEADERS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-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-tags mostlyclean-depend mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-binPROGRAMS clean-compile clean-tags clean-depend \
clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \
distclean-depend distclean-generic clean-am
distclean: distclean-am
maintainer-clean-am: maintainer-clean-binPROGRAMS \
maintainer-clean-compile 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 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
#
# count BUILDs - each time increment by one and define the
# C macro BUILDNO. bing it to a file everybody includes (log.h)
#
log.h: increment_build
increment_build:
@echo "incrementing BUILD number"
@if [ -f .buildno ]; then \
bld=`cat .buildno`; \
bld=`expr $${bld} + 1`; \
else \
bld=1; \
fi; \
echo "$${bld}" >.buildno;
# 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:

126
src/log.c Normal file
View File

@ -0,0 +1,126 @@
/*
Copyright (C) 2002 Thomas Ries <tries@gmx.net>
This file is part of Siproxd.
Siproxd 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.
Siproxd 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 Siproxd; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "log.h"
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
static char const ident[]="$Id: " __FILE__ ": " PACKAGE "-" VERSION "-"\
BUILDSTR " $";
int debug_pattern=0;
void log_set_pattern(int pattern) {
debug_pattern=pattern;
}
/* for all the LOGGING routines:
They should figure out if we are running as a daemon, then write
their stuff to syslog or something like that
*/
void log_debug(int class, char *file, int line, const char *format, ...) {
va_list ap;
time_t t;
struct tm *tim;
if ((debug_pattern & class) == 0) return;
va_start(ap, format);
time(&t);
tim=localtime(&t);
fprintf(stderr,"%2.2i:%2.2i:%2.2i %s:%i ", tim->tm_hour,
tim->tm_min, tim->tm_sec, file, line);
vfprintf(stderr, format, ap);
fprintf(stderr,"\n");
va_end(ap);
fflush(stderr);
return;
}
void log_error(char *file, int line, const char *format, ...) {
va_list ap;
time_t t;
struct tm *tim;
va_start(ap, format);
time(&t);
tim=localtime(&t);
fprintf(stderr,"%2.2i:%2.2i:%2.2i ERROR:%s:%i ",tim->tm_hour,
tim->tm_min, tim->tm_sec,file,line);
vfprintf(stderr, format, ap);
fprintf(stderr,"\n");
va_end(ap);
fflush(stderr);
return;
}
void log_warn(char *file, int line, const char *format, ...) {
va_list ap;
time_t t;
struct tm *tim;
va_start(ap, format);
time(&t);
tim=localtime(&t);
fprintf(stderr,"%2.2i:%2.2i:%2.2i WARNING:%s:%i ",tim->tm_hour,
tim->tm_min, tim->tm_sec,file,line);
vfprintf(stderr, format, ap);
fprintf(stderr,"\n");
va_end(ap);
fflush(stderr);
return;
}
void log_dump_buffer(int class, char *file, int line,
char *buffer, int length) {
int i;
if ((debug_pattern & class) == 0) return;
fprintf(stderr,"---BUFFER DUMP follows---\n");
for (i=0;i<length;i++) {
fprintf(stderr,"%c",buffer[i]);
}
fprintf(stderr,"\n---end of BUFFER DUMP---\n");
fflush(stderr);
return;
}

49
src/log.h Normal file
View File

@ -0,0 +1,49 @@
/*
Copyright (C) 2002 Thomas Ries <tries@gmx.net>
This file is part of Siproxd.
Siproxd 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.
Siproxd 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 Siproxd; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#define DBCLASS_BABBLE 0x00000001 // babble (like entering/leaving fnc)
#define DBCLASS_NET 0x00000002 // network
#define DBCLASS_SIP 0x00000004 // SIP manipulations
#define DBCLASS_REG 0x00000008 // Client registration
#define DBCLASS_NOSPEC 0x00000010 // non specified class
#define DBCLASS_PROXY 0x00000020 // proxy
#define DBCLASS_DNS 0x00000040 // DNS stuff
#define DBCLASS_NETTRAF 0x00000080 // network traffic
#define DBCLASS_CONFIG 0x00000100 // configuration
#define DEBUG(F...) log_debug(1,__FILE__, __LINE__,F)
void log_set_pattern(int pattern);
#define DEBUGC(C,F...) log_debug(C,__FILE__, __LINE__,F)
void log_debug(int class, char *file, int line, const char *format, ...);
#define ERROR(F...) log_error(__FILE__, __LINE__,F)
void log_error(char *file, int line, const char *format, ...);
#define WARN(F...) log_warn(__FILE__, __LINE__,F)
void log_warn(char *file, int line, const char *format, ...);
/* tobedone: dump a buffer */
#define DUMP_BUFFER(C,F...) log_dump_buffer(C,__FILE__, __LINE__,F)
void log_dump_buffer(int class, char *file, int line,
char *buffer, int length);

562
src/proxy.c Normal file
View File

@ -0,0 +1,562 @@
/*
Copyright (C) 2002 Thomas Ries <tries@gmx.net>
This file is part of Siproxd.
Siproxd 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.
Siproxd 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 Siproxd; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <osip/smsg.h>
#include "siproxd.h"
#include "log.h"
static char const ident[]="$Id: " __FILE__ ": " PACKAGE "-" VERSION "-"\
BUILDSTR " $";
/* configuration storage */
extern struct siproxd_config configuration;
/*
* knows hot to rewrite the SIP URLs in a request/response
*/
extern int errno;
extern struct urlmap_s urlmap[]; // URL mapping table
extern struct lcl_if_s local_addresses;
int proxy_request (sip_t *request) {
int i;
int sts;
int type;
struct in_addr addr;
contact_t *contact;
url_t *url;
int port;
char *buffer;
#define REQTYP_INCOMMING 1
#define REQTYP_OUTGOING 2
DEBUGC(DBCLASS_PROXY,"proxy_request");
/* check for VIA loop, if yes, discard the request */
sts=check_vialoop(request);
if (sts !=0) {
DEBUGC(DBCLASS_PROXY,"via loop detected, ignoring request");
return 1;
}
/* figure out if this is an request comming from the outside
* world to one of our registered clients ('to' == 'masq' URL)
* or if this is a request sent by on e of our registered clients
* ('from' == 'true' URL)
*/
msg_getcontact(request,0,&contact);
type = 0;
for (i=0; i<URLMAP_SIZE; i++) {
if (urlmap[i].active == 0) continue;
/*&&&& comparison of hosts should be based on IP addresses
as it looks (at least RQ URI)...*/
/*&&&& make this comparison into a subroutine - it is used a LOT !
also make the HOST comparison more flexible (name<->IP) */
/* incomming request ('to' == 'masq') */
if ((strcmp(request->to->url->username,
urlmap[i].masq_url->username)==0) &&
(strcmp(request->to->url->host,
urlmap[i].masq_url->host)==0)) {
type=REQTYP_INCOMMING;
DEBUGC(DBCLASS_PROXY,"incomming request from %s@%s from outbound",
request->from->url->username,
request->from->url->host);
break;
}
/* outgoing request ('contact' == 'true') */
if ((strcmp(contact->url->username,
urlmap[i].true_url->username)==0) &&
(strcmp(contact->url->host,
urlmap[i].true_url->host)==0)) {
type=REQTYP_OUTGOING;
DEBUGC(DBCLASS_PROXY,"outgoing request from %s@%s from inbound",
request->from->url->username,
request->from->url->host);
break;
}
}
/*
* ok, we got a request that we are allowed to process.
*/
switch (type) {
/*
* from an external host to the internal masqueraded host
*/
case REQTYP_INCOMMING:
/* rewrite request URI to point to the real host */
/* i still holds the valid index into the URLMAP table */
/* THIS IS UGLY!!! I dont like it &&&&&&*/
DEBUGC(DBCLASS_PROXY,"rewriting incomming Request URI");
url=msg_geturi(request);
free(url->host);url->host=NULL;
{
char *copy;
copy = (char *)malloc(strlen(urlmap[i].true_url->host)+1);
memcpy(copy, urlmap[i].true_url->host, strlen(urlmap[i].true_url->host));
copy[strlen(urlmap[i].true_url->host)]='\0';
url_sethost(url, copy);
}
/* add my Via header line (inbound interface)*/
sts = proxy_add_myvia(request, 1);
break;
/*
* from the internal masqueraded host to an external host
*/
case REQTYP_OUTGOING:
/* if an INVITE, rewrite body */
if (MSG_IS_INVITE(request)) {
sts = proxy_rewrite_invitation_body(request);
}
/* add my Via header line (outbound interface)*/
sts = proxy_add_myvia(request, 0);
break;
default:
DEBUGC(DBCLASS_PROXY,"request: refuse to proxy - UA not registered?");
/* some clients seem to run amok when passing back a negative response */
// proxy_gen_response(request, 403 /*forbidden*/);
return 1;
}
/* get target address from request URL */
url=msg_geturi(request);
#if EXP1
/* &&&& linphone 0.9.0pre4
take To address and place it into URI (at least the host part)
Linphone 0.9.0pre4 puts the proxy host in the request URI
if OUTBOUNT proxy is activated!
This is only a hack to recreate the proper final request URI.
see linphone, osipdialog.c line 1172
if (call_leg->peer == NULL)
url_2char (call_leg->to->url, &tmp);
else
url_2char (call_leg->peer->url, &tmp);
url_parse (sipmsg->strtline->rquri, tmp); <<<<----
*/
{
header_t *header_ua;
msg_getuser_agent(request,0,&header_ua);
if ( header_ua && header_ua->hvalue &&
(strcmp(header_ua->hvalue,"oSIP/Linphone-0.8.0")==0) ) {
/* if an outgoing request, try to fix the SIP URI */
if (type == REQTYP_OUTGOING) {
WARN("broken linphone-0.8.0: restoring SIP URI");
free (url->host);
url->host=malloc(strlen(request->to->url->host));
strcpy(url->host,request->to->url->host);
}
}
}
#endif
sts = get_ip_by_host(url->host, &addr);
sts = msg_2char(request, &buffer);
if (sts != 0) {
ERROR("proxy_request: msg_2char failed");
return 1;
}
/* send to destination */
if (url->port) {
port=atoi(url->port);
} else {
port=configuration.sip_listen_port;
}
sipsock_send_udp(addr, port, buffer, strlen(buffer));
free (buffer);
return 0;
}
int proxy_response (sip_t *response) {
int i;
int sts;
int type;
struct in_addr addr;
via_t *via;
int port;
char *buffer;
#define RESTYP_INCOMMING 1
#define RESTYP_OUTGOING 2
DEBUGC(DBCLASS_PROXY,"proxy_response");
/* check for VIA loop, if yes, discard the request */
sts=check_vialoop(response);
if (sts !=0) {
DEBUGC(DBCLASS_PROXY,"via loop detected, ignoring response");
return 1;
}
/* ALWAYS: remove my Via header line */
sts = proxy_del_myvia(response);
if (sts !=0) {
DEBUGC(DBCLASS_PROXY,"not addressed to my VIA, ignoring response");
return 1;
}
/* figure out if this is an request comming from the outside
* world to one of our registered clients
*/
/* Ahhrghh...... an response seems to have NO contact information...
* so let's take FROM instead...
* the TO and FROM headers are EQUAL to the request - that means
* they are swapped in their meaning for a response...
*/
type = 0;
for (i=0; i<URLMAP_SIZE; i++) {
if (urlmap[i].active == 0) continue;
/* incomming response ('from' == 'masq') */
if ((strcmp(response->from->url->username,
urlmap[i].masq_url->username)==0) &&
(strcmp(response->from->url->host,
urlmap[i].masq_url->host)==0)) {
type=RESTYP_INCOMMING;
DEBUGC(DBCLASS_PROXY,"incomming response for %s@%s from outbound",
response->from->url->username,
response->from->url->host);
break;
}
/* outgoing response ('to' == 'masq') */
if ((strcmp(response->to->url->username,
urlmap[i].masq_url->username)==0) &&
(strcmp(response->to->url->host,
urlmap[i].masq_url->host)==0)) {
type=RESTYP_OUTGOING;
DEBUGC(DBCLASS_PROXY,"outgoing response for %s@%s from inbound",
response->from->url->username,
response->from->url->host);
break;
}
}
/*
* ok, we got a response that we are allowed to process.
*/
switch (type) {
/*
* from an external host to the internal masqueraded host
*/
case RESTYP_INCOMMING:
#if 0 /* do we really have to?? in the incomming response
we have the correct address. But we mus rewrite an
outgoing response to an incomming INVITE request ! */
/* If an 200 answer to an INVITE request, rewrite body */
if ((MSG_IS_RESPONSEFOR(response,"INVITE") &&
(MSG_TEST_CODE(response, 200)) ) {
sts = proxy_rewrite_invitation_body(response);
}
#endif
break;
/*
* from the internal masqueraded host to an external host
*/
case RESTYP_OUTGOING:
#define satoi atoi /* used in MSG_TEST_CODE macro ... */
/* If an 200 answer to an INVITE request, rewrite body */
if ((MSG_IS_RESPONSEFOR(response,"INVITE")) &&
(MSG_TEST_CODE(response, 200))) {
sts = proxy_rewrite_invitation_body(response);
}
break;
default:
DEBUGC(DBCLASS_PROXY,"response: refuse to proxy - UA not registered?");
/* some clients seem to run amok when passing back a negative response */
// proxy_gen_response(request, 403 /*forbidden*/);
return 1;
}
/* get target address from VIA header */
via = (via_t *) list_get (response->vias, 0);
sts = get_ip_by_host(via->host, &addr);
sts = msg_2char(response, &buffer);
if (sts != 0) {
ERROR("proxy_request: msg_2char failed");
return 1;
}
/* send to destination */
if (via->port) {
port=atoi(via->port);
} else {
port=configuration.sip_listen_port;
}
sipsock_send_udp(addr, port, buffer, strlen(buffer));
free (buffer);
return 0;
}
/*
* send an proxy generated response back to the client.
* Only errors are reported from the proxy itself.
* code = SIP result code to deliver
*/
int proxy_gen_response(sip_t *request, int code) {
sip_t *response;
int sts;
via_t *via;
char *buffer;
struct in_addr addr;
/* create the response template */
if ((response=msg_make_template_reply(request, code))==NULL) {
ERROR("proxy_response: error in msg_make_template_reply");
return 1;
}
/* we must check if first via has x.x.x.x address. If not, we must resolve it */
msg_getvia (response, 0, &via);
if (via == NULL)
{
ERROR("proxy_response: Cannot send response - no via field");
return 1;
}
/* name resolution */
if (inet_aton (via->host,&addr) == 0)
{
/* need name resolution */
DEBUGC(DBCLASS_DNS,"resolving name:%s",via->host);
sts = get_ip_by_host(via->host, &addr);
}
DEBUGC(DBCLASS_PROXY,"response=%p",response);
sts = msg_2char(response, &buffer);
if (sts != 0) {
ERROR("proxy_response: msg_2char failed");
return 1;
}
/* send to destination */
sipsock_send_udp(addr, atoi(via->port), buffer, strlen(buffer));
/* free the resources */
msg_free(response);
free(response);
free (buffer);
return 0;
}
/*
* routine to rewrite the header and message bodies
*/
/* interface == 0 -> outbound interface, else inbound interface */
int proxy_add_myvia (sip_t *request, int interface) {
struct in_addr addr;
char tmp[URL_STRING_SIZE];
via_t *via;
int sts;
if (interface == 0) {
sts = get_ip_by_host(configuration.outboundhost, &addr);
} else {
sts = get_ip_by_host(configuration.inboundhost, &addr);
}
sprintf (tmp, "SIP/2.0/UDP %s:%i", inet_ntoa(addr),
configuration.sip_listen_port);
DEBUGC(DBCLASS_BABBLE,"adding VIA:%s",tmp);
sts = via_init(&via);
if (sts!=0) return -1; /* allocation failed */
sts = via_parse(via, tmp);
if (sts!=0) return -1;
list_add(request->vias,via,0);
return 0;
}
int proxy_del_myvia (sip_t *response) {
via_t *via;
int sts;
DEBUGC(DBCLASS_PROXY,"deleting topmost VIA");
via = list_get (response->vias, 0);
if ( !is_via_local(via) ) {
ERROR("I'm trying to delete a VIA but it's not mine! host=%s",via->host);
return -1;
}
sts = list_remove(response->vias, 0);
via_free (via);
free(via);
return 0;
}
int proxy_rewrite_invitation_body(sip_t *mymsg){
body_t *body;
struct in_addr addr;
int sts;
char *oldbody;
char newbody[BODY_MESSAGE_MAX_SIZE];
char clen[8]; /* probably never more than 7 digits for content length !*/
sts = msg_getbody(mymsg, 0, &body);
if (sts != 0) {
ERROR("rewrite_invitation_body: no body found in message");
return 1;
}
sts = body_2char(body, &oldbody);
{
char *tmp2;
content_length_2char(mymsg->contentlength, &tmp2);
DEBUG("Body before rewrite (clen=%s, strlen=%i):\n%s\n----",
tmp2, strlen(oldbody), oldbody);
free(tmp2);
}
/* TODO */
/* - change the 'c=' line to present the outbound address (the other
side will send its audio data there
- 'm=' line: here we should change the port number to a free local
(outbound) port and set up an port forwarding to the hidden
inbound client ...*/
{
char *data=NULL;
char *data2=NULL;
char *ptr=NULL;
memset(newbody, 0, sizeof(newbody));
data = strstr (oldbody, "\nc=");
if (data == NULL) data = strstr (oldbody, "\rc=");
if (data == NULL) {
ERROR("did not find a c= line in the body");
return 1;
}
data += 3;
/* can only rewrite IPV4 addresses by now */
if (strncmp(data,"IN IP4 ",7)!=0) {
ERROR("c= does not contain an IN IP4 address");
return 1;
}
data += 7;
data2 = strstr (data, "\n");
if (data2 == NULL) data2 = strstr (oldbody, "\r");
if (data2 == NULL) {
ERROR("did not find a CR/LF after c= line");
return 1;
}
/* copy up to the to-be-masqueraded address */
memcpy(newbody, oldbody, data-oldbody);
/* insert proxy outbound address */
sts = get_ip_by_host(configuration.outboundhost, &addr);
ptr=newbody+(data-oldbody);
sprintf(ptr, "%s", inet_ntoa(addr));
ptr += strlen(ptr);
/* copy rest */
memcpy (ptr, data2, strlen(data2));
}
/* remove old body */
sts = list_remove(mymsg->bodies, 0);
body_free(body);
free(body);
/* include new body */
msg_setbody(mymsg, newbody);
/* free content length resource and include new one*/
content_length_free(mymsg->contentlength);
free(mymsg->contentlength);
mymsg->contentlength=NULL;
sprintf(clen,"%i",strlen(newbody));
sts = msg_setcontent_length(mymsg, clen);
{
char *tmp, *tmp2;
sts = msg_getbody(mymsg, 0, &body);
sts = body_2char(body, &tmp);
content_length_2char(mymsg->contentlength, &tmp2);
DEBUG("Body after rewrite (clen=%s, strlen=%i):\n%s\n----",
tmp2, strlen(tmp), tmp);
free(tmp);
free(tmp2);
}
free(oldbody);
return 0;
}

182
src/readconf.c Normal file
View File

@ -0,0 +1,182 @@
/*
Copyright (C) 2002 Thomas Ries <tries@gmx.net>
This file is part of Siproxd.
Siproxd 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.
Siproxd 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 Siproxd; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <osip/smsg.h>
#include "siproxd.h"
#include "log.h"
static char const ident[]="$Id: " __FILE__ ": " PACKAGE "-" VERSION "-"\
BUILDSTR " $";
extern int errno;
/* configuration storage */
extern struct siproxd_config configuration;
/* prototypes used locally only */
static int parse_config (FILE *configfile);
/* try to open (witchever found first):
<name>
$HOME/.<name>rc
/etc/<name>.conf
/usr/etc/<name>.conf
/usr/local/etc/<name>.conf
*/
int read_config(char *name, int search) {
int sts;
FILE *configfile=NULL;
int i;
char tmp[256];
const char *completion[] = {
"%s/.%src", /* this one is special... (idx=0)*/
"/etc/%s.conf",
"/usr/etc/%s.conf",
"/usr/local/etc/%s.conf",
NULL };
DEBUGC(DBCLASS_CONFIG,"trying to read config file");
/* shall I search the config file myself ? */
if (search != 0) {
/* yup, try to find it */
for (i=0; completion[i]!=NULL; i++) {
switch (i) {
case 0:
sprintf(tmp,completion[i],getenv("HOME"),name);
break;
default:
sprintf(tmp,completion[i],name);
break;
}
DEBUGC(DBCLASS_CONFIG,"... trying %s",tmp);
configfile = fopen(tmp,"r");
if (configfile==NULL) continue;
break; /* got config file */
}
} else {
/* don't search it, just try the one given file */
DEBUGC(DBCLASS_CONFIG,"... trying %s",name);
configfile = fopen(name,"r");
}
/* config file not found or unable to open for read */
if (configfile==NULL) {
ERROR ("could not open config file: %s", strerror(errno));
return 1;
}
sts = parse_config(configfile);
fclose(configfile);
return sts;
}
static int parse_config (FILE *configfile) {
char buff[128];
char *ptr;
int i;
int j;
int num;
struct cfgopts {
char *keyword;
enum type {TYP_INT4, TYP_STRING, TYP_FLOAT} type;
void *dest;
} configoptions[] = {
{ "debug_level", TYP_INT4, &configuration.debuglevel },
{ "sip_port", TYP_INT4, &configuration.sip_listen_port },
{ "daemonize", TYP_INT4, &configuration.daemonize },
{ "host_inbound", TYP_STRING, &configuration.inboundhost },
{ "host_outbound", TYP_STRING, &configuration.outboundhost },
{0, 0, 0}
};
while (fgets(buff,sizeof(buff),configfile) != NULL) {
/* strip newline if present */
if (buff[strlen(buff)-1]=='\n') buff[strlen(buff)-1]='\0';
/* strip emty lines */
if (strlen(buff) == 0) continue;
/* strip comments and line with only whitespaces */
for (i=0;i<strlen(buff);i++) {
if ((buff[i] == ' ') && (buff[i] == '\t')) continue;
if (buff[i] =='#') i=strlen(buff);
break;
}
if (i == strlen(buff)) continue;
DEBUGC(DBCLASS_CONFIG,"pc:\"%s\"",buff);
/* scan for known keyword */
for (j=0; configoptions[j].keyword != NULL; j++) {
if ((ptr=strstr(buff, configoptions[j].keyword)) != NULL) {
ptr += strlen(configoptions[j].keyword);
DEBUGC(DBCLASS_CONFIG,"got keyword:\"%s\"",
configoptions[j].keyword);
/* check for argument separated by '=' */
if ((ptr=strchr(ptr,'=')) == NULL) {;
ERROR("argument missing to config parameter %s",
configoptions[j].keyword);
break;
}
do {ptr++;} while (*ptr == ' '); /* skip spaces after '=' */
DEBUGC(DBCLASS_CONFIG,"got argument:\"%s\"",ptr);
num=0;
switch (configoptions[j].type) {
case TYP_INT4:
num=sscanf(ptr,"%i",(int*)configoptions[j].dest);
DEBUGC(DBCLASS_BABBLE,"INT4=%i",*(int*)configoptions[j].dest);
break;
case TYP_STRING:
num=sscanf(ptr,"%as",(char**)configoptions[j].dest);
DEBUGC(DBCLASS_BABBLE,"STRING=%s",*(char**)configoptions[j].dest);
break;
default:
break;
}
if (num == 0) {
ERROR("illegal format in config file, line:\"%s\"",buff);
}
break;
}
}
}
return 0;
}

249
src/register.c Normal file
View File

@ -0,0 +1,249 @@
/*
Copyright (C) 2002 Thomas Ries <tries@gmx.net>
This file is part of Siproxd.
Siproxd 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.
Siproxd 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 Siproxd; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <osip/smsg.h>
#include "siproxd.h"
#include "log.h"
static char const ident[]="$Id: " __FILE__ ": " PACKAGE "-" VERSION "-"\
BUILDSTR " $";
/* configuration storage */
extern struct siproxd_config configuration;
extern int errno;
struct urlmap_s urlmap[URLMAP_SIZE]; // URL mapping table
/*
* initialize the URL mapping table
*/
void register_init(void) {
memset (urlmap, 0, sizeof(urlmap));
return;
}
/*
* handles register requests and updates the URL mapping table
* sts = 0 : successfully registered
* sts = 1 : registration failed
*/
int register_client(sip_t *my_msg) {
int i,j;
int expires;
time_t time_now;
url_t *url1_to, *url1_contact;
url_t *url2_to, *url2_contact;
header_t *expires_hdr;
/*
fetch 1st Via entry and remember this address. Incomming requests
for the registered address have to be passed on to that host.
To: -> address to be registered
Contact: -> host is reachable there
=> Mapping is
To: <1--n> Contact
*/
time(&time_now);
DEBUGC(DBCLASS_BABBLE,"sip_register:");
/* evaluate Expires Header field */
msg_getexpires(my_msg, 0, &expires_hdr);
if (expires_hdr) {
expires=atoi(expires_hdr->hvalue);
} else {
/* it seems the expires filed in not present everywhere... */
WARN("no 'expires' header found - set time to 600 sec");
expires=600;
msg_setexpires(my_msg, "600");
}
DEBUGC(DBCLASS_REG,"expires:%i seconds",expires);
/* Update registration. There are two possibilities:
* - already registered, the update the existing record
* - not registered, then create a new record
*/
url1_to=my_msg->to->url;
url1_contact=((contact_t*)(my_msg->contacts->node->element))->url;
j=-1;
for (i=0; i<URLMAP_SIZE; i++) {
if (urlmap[i].active == 0) {
if (j < 0) j=i; /* remember first hole */
continue;
}
url2_to=urlmap[i].masq_url;
url2_contact=urlmap[i].true_url;
if ( (strcmp(url1_to->username, url2_to->username )==0) &&
(strcmp(url1_to->host, url2_to->host )==0) &&
(strcmp(url1_contact->username, url2_contact->username)==0) &&
(strcmp(url1_contact->host, url2_contact->host )==0) ) {
DEBUGC(DBCLASS_REG, "found entry for %s@%s at slot=%i, exp=%li",
url1_contact->username,url1_contact->host,
i, urlmap[i].expires-time_now);
break;
}
}
if ( (j < 0) && (i >= URLMAP_SIZE) ) {
/* oops, no free entries left... */
ERROR("URLMAP is full - registration failed");
return 1;
}
if (i >= URLMAP_SIZE) {
/* entry no existing, create new one */
i=j;
DEBUGC(DBCLASS_REG,"create new entry for %s@%s at slot=%i",
url1_contact->username, url1_contact->host, i);
/* write entry */
urlmap[i].active=1;
url_clone( ((contact_t*)(my_msg->contacts->node->element))->url,
&urlmap[i].true_url); /* Contact: field */
url_clone( my_msg->to->url,
&urlmap[i].masq_url); /* To: field */
via_clone( ((via_t*)(my_msg->vias->node->element)),
&urlmap[i].via); /* via field */
}
/* give some safety margin for the next update */
if (expires >0) expires+=30;
/* update registration timeout */
urlmap[i].expires=time_now+expires;
return 0;
}
/*
* cyclically called to do the aging of the URL mapping table entries
* and throw out expired entries.
*/
void register_agemap(void) {
int i;
time_t t;
time(&t);
DEBUGC(DBCLASS_BABBLE,"sip_agemap, t=%i",(int)t);
for (i=0; i<URLMAP_SIZE; i++) {
if ((urlmap[i].active == 1) && (urlmap[i].expires < t)) {
DEBUGC(DBCLASS_REG,"cleaned entry:%i %s@%s", i,
urlmap[i].masq_url->username, urlmap[i].masq_url->host);
urlmap[i].active=0;
url_free(urlmap[i].true_url);
url_free(urlmap[i].masq_url);
via_free(urlmap[i].via);
free(urlmap[i].true_url);
free(urlmap[i].masq_url);
free(urlmap[i].via);
}
}
return;
}
/*
* send answer to a registration request.
* flag = 0 -> positive answer
* flag != 0 -> negative answer
*/
int register_response(sip_t *request, int flag) {
sip_t *response;
int code;
int sts;
via_t *via;
int port;
char *buffer;
struct in_addr addr;
header_t *expires_hdr;
/* ok -> 200, fail -> 503 */
if (flag == 0) code = 200;
else code = 503;
/* create the response template */
if ((response=msg_make_template_reply(request, code))==NULL) {
ERROR("register_response: error in msg_make_template_reply");
return 1;
}
/* insert the expiration header */
msg_getexpires(request, 0, &expires_hdr);
if (expires_hdr) {
msg_setexpires(response, expires_hdr->hvalue);
}
/* get the IP address from existing VIA header */
msg_getvia (response, 0, &via);
if (via == NULL) {
ERROR("register_response: Cannot send response - no via field");
return 1;
}
/* name resolution needed? */
if (inet_aton (via->host,&addr) == 0) {
/* yes, get IP address */
sts = get_ip_by_host(via->host, &addr);
}
sts = msg_2char(response, &buffer);
if (sts != 0) {
ERROR("register_response: msg_2char failed");
return 1;
}
/* send answer back */
if (via->port) {
port=atoi(via->port);
} else {
port=configuration.sip_listen_port;
}
sipsock_send_udp(addr, port, buffer, strlen(buffer));
/* free the resources */
msg_free(response);
free(response);
free (buffer);
return 0;
}

197
src/siproxd.c Normal file
View File

@ -0,0 +1,197 @@
/*
Copyright (C) 2002 Thomas Ries <tries@gmx.net>
This file is part of Siproxd.
Siproxd 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.
Siproxd 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 Siproxd; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/in.h>
#include <getopt.h>
#include <osip/smsg.h>
#include "siproxd.h"
#include "log.h"
static char const ident[]="$Id: " __FILE__ ": " PACKAGE "-" VERSION "-"\
BUILDSTR " $";
/* configuration storage */
struct siproxd_config configuration;
int main (int argc, char *argv[])
{
int sts;
int i;
char buff [BUFFER_SIZE];
sip_t *my_msg=NULL;
extern char *optarg;
int ch1;
char configfile[64]="siproxd";
int config_search=1;
/* prepare default configuration */
configuration.debuglevel=-1;
configuration.daemonize=0;
configuration.sip_listen_port=SIP_PORT;
configuration.inboundhost=NULL;
configuration.outboundhost=NULL;
log_set_pattern(configuration.debuglevel);
/*
* parse command line
*/
{
int option_index = 0;
static struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
{"config", required_argument, NULL, 'c'},
{"debug", required_argument, NULL, 'd'},
{0,0,0,0}
};
while ((ch1 = getopt_long_only(argc, argv, "hc:d:n",
long_options, &option_index)) != -1) {
switch (ch1) {
case 'h': /* help */
DEBUGC(DBCLASS_CONFIG,"option: help");
exit(0);
break;
case 'c': /* load config file */
DEBUGC(DBCLASS_CONFIG,"option: config file=%s",optarg);
strncpy(configfile,optarg,sizeof(configfile)-1);
configfile[sizeof(configfile)]='\0';
config_search=0;
break;
case 'd': /* set debug level */
DEBUGC(DBCLASS_CONFIG,"option: set debug level: %s",optarg);
configuration.debuglevel=atoi(optarg);
log_set_pattern(configuration.debuglevel);
break;
default:
DEBUGC(DBCLASS_CONFIG,"no command line options");
break;
}
}
}
/*
* Init stuff
*/
if (read_config(configfile, config_search) != 0) exit(1);
/* if a debug_level statement was in the config file, make sure
the debug pattern is set after reading the config */
log_set_pattern(configuration.debuglevel);
/* init the oSIP parser */
parser_init();
/* initialize the registration facility */
register_init();
/* listen for incomming messages */
sipsock_listen();
/*&&&& daemonize !! */
if (configuration.daemonize) {
DEBUGC(DBCLASS_CONFIG,"daemonizing");
if (fork()!=0) exit(0);
/* close STDIN, STDOUT, STDERR */
close(0);close(1);close(2);
}
/*
* Main loop
*/
while (1) {
DEBUGC(DBCLASS_BABBLE,"going into sip_wait\n");
while (sipsock_wait()==0) {
/* got no input, here by timeout. do aging */
register_agemap();
}
/* got input, process */
DEBUGC(DBCLASS_BABBLE,"back from sip_wait");
i=sipsock_read(&buff, sizeof(buff));
/*
* more integrity checks of received packet needed !!
* it's possible to crash msg_parse with some crap-input.
*/
sts=msg_init(&my_msg);
sts=msg_parse( my_msg, buff);
/*
* if message parsing was ok go on - otherwise skip
*/
if (sts != 0) continue;
DEBUGC(DBCLASS_SIP,"received SIP type %s:%s",
(MSG_IS_REQUEST(my_msg))? "REQ" : "RES",
my_msg->strtline->sipmethod);
/* if RQ REGISTER, just register and send an answer */
if (MSG_IS_REGISTER(my_msg) && MSG_IS_REQUEST(my_msg)) {
sts = register_client(my_msg);
sts = register_response(my_msg, sts);
/* MSG is a request, add current via entry,
* do a lookup in the URLMAP table and
* send to the final destination */
} else if (MSG_IS_REQUEST(my_msg)) {
sts = proxy_request(my_msg);
/* MSG is a response, remove current via and
* send to next via in chain */
} else if (MSG_IS_RESPONSE(my_msg)) {
sts = proxy_response(my_msg);
/* unsupported message */
} else {
ERROR("received unsupported SIP type %s %s",
(MSG_IS_REQUEST(my_msg))? "REQ" : "RES",
my_msg->strtline->sipmethod);
}
/*
* free the SIP message buffers
*/
msg_free(my_msg);
free(my_msg);
} /* while TRUE */
} /* main */

96
src/siproxd.h Normal file
View File

@ -0,0 +1,96 @@
/*
Copyright (C) 2002 Thomas Ries <tries@gmx.net>
This file is part of Siproxd.
Siproxd 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.
Siproxd 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 Siproxd; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* sock.c */
int sipsock_listen (void);
int sipsock_wait(void);
int sipsock_read(void *buf, size_t bufsize);
int sipsock_send_udp(struct in_addr addr, int port, char *buffer, int size);
/* register.c */
void register_init(void);
int register_client(sip_t *request);
void register_agemap(void);
int register_response(sip_t *request, int flag);
/* proxy.c */
int proxy_request (sip_t *request);
int proxy_response (sip_t *response);
int proxy_gen_response(sip_t *request, int code);
int proxy_add_myvia (sip_t *request, int interface);
int proxy_del_myvia (sip_t *response);
int proxy_rewrite_invitation_body(sip_t *mymsg);
/* utils.c */
sip_t * msg_make_template_reply (sip_t * request, int code);
int check_vialoop (sip_t *my_msg);
int is_via_local (via_t *via);
int get_ip_by_host(char *hostname, struct in_addr *addr);
/* config.c */
int read_config(char *name, int search);
/*
* table to hold the client registrations
*/
struct urlmap_s {
int active;
int expires;
url_t *true_url;
url_t *masq_url;
via_t *via;
};
/*
* configuration option table
*/
struct siproxd_config {
int debuglevel;
char *inboundhost;
char *outboundhost;
int sip_listen_port;
int daemonize;
};
/*
* some constant definitions
*/
#define URLMAP_SIZE 128 // size of URL mapping table
#define BUFFER_SIZE 1024 // input buffer for read from socket
#define URL_STRING_SIZE 128 //
#define SIP_PORT 5060
/*
* optionasl hacks
*/
#define EXP1 1 /* HACK linphone0.9.0pre4 */
/* 14-Aug-2002 TR
Linphone puts in the proxies hostname in the request URI when
OUTBOUND proxy is activated. But ONLY the hostname. Username and
Port (!!!) are kept from the SIP address givven by the user.
This is a BUG in my eyes. Linphone must send the datagrap to
the Proxy, but have the final receiver in the request URI !
*/

140
src/sock.c Normal file
View File

@ -0,0 +1,140 @@
/*
Copyright (C) 2002 Thomas Ries <tries@gmx.net>
This file is part of Siproxd.
Siproxd 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.
Siproxd 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 Siproxd; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <osip/smsg.h>
#include "siproxd.h"
#include "log.h"
static char const ident[]="$Id: " __FILE__ ": " PACKAGE "-" VERSION "-"\
BUILDSTR " $";
/* configuration storage */
extern struct siproxd_config configuration;
extern int errno;
static int listen_socket=0;
/*
* binds to SIP UDP socket for listening to incomming packets
*
* returns 0 on success
*/
int sipsock_listen (void) {
struct sockaddr_in my_addr;
int sts;
my_addr.sin_family = AF_INET;
memset(&my_addr.sin_addr.s_addr, 0, sizeof(struct in_addr));
my_addr.sin_port= htons(configuration.sip_listen_port);
listen_socket=socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (listen_socket == 0) {
ERROR("socket() call failed:%s",strerror(errno));
return 1;
}
sts=bind(listen_socket, (struct sockaddr *)&my_addr, sizeof(my_addr));
if (sts != 0) {
ERROR("bind failed:%s",strerror(errno));
return 2;
}
DEBUGC(DBCLASS_NET,"bound listen socket %i",listen_socket);
return 0;
}
int sipsock_wait(void) {
int sts;
fd_set fdset;
struct timeval timeout;
timeout.tv_sec=5;
timeout.tv_usec=0;
FD_ZERO(&fdset);
FD_SET (listen_socket, &fdset);
sts=select (listen_socket+1, &fdset, NULL, NULL, &timeout);
return sts;
}
int sipsock_read(void *buf, size_t bufsize) {
int count;
count=read(listen_socket, buf, bufsize);
DEBUGC(DBCLASS_NET,"received UDP packet, count=%i", count);
DUMP_BUFFER(DBCLASS_NETTRAF, buf, count);
return count;
}
/*
* sends an UDP datagram to the specified destination
*/
int sipsock_send_udp(struct in_addr addr, int port, char *buffer, int size) {
struct sockaddr_in dst_addr;
static int s=0;
int sts;
/* first time: allocate a socket for sending */
if (s == 0) {
s=socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (s == 0) {
ERROR("socket() call failed:%s",strerror(errno));
return 1;
}
DEBUGC(DBCLASS_NET,"allocated send socket %i",s);
}
dst_addr.sin_family = AF_INET;
memcpy(&dst_addr.sin_addr.s_addr, &addr, sizeof(struct in_addr));
dst_addr.sin_port= htons(port);
DEBUGC(DBCLASS_NET,"send UDP packet to %s",inet_ntoa(addr));
DUMP_BUFFER(DBCLASS_NETTRAF, buffer, size);
sts = sendto (s, buffer, size, 0, &dst_addr, sizeof(dst_addr));
if (sts == -1) {
ERROR("sendto() call failed:%s",strerror(errno));
return 1;
}
return 0;
}

152
src/utils.c Normal file
View File

@ -0,0 +1,152 @@
/*
Copyright (C) 2002 Thomas Ries <tries@gmx.net>
This file is part of Siproxd.
Siproxd 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.
Siproxd 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 Siproxd; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <osip/smsg.h>
#include <osip/port.h>
#include "siproxd.h"
#include "log.h"
static char const ident[]="$Id: " __FILE__ ": " PACKAGE "-" VERSION "-"\
BUILDSTR " $";
/* configuration storage */
extern struct siproxd_config configuration;
extern int h_errno;
sip_t *msg_make_template_reply (sip_t * request, int code) {
sip_t *response;
char *tmp;
int pos;
msg_init (&response);
msg_setversion (response, sgetcopy ("SIP/2.0"));
tmp = malloc(5);
snprintf (tmp, 5, "%i", code);
msg_setstatuscode (response, tmp);
msg_setreasonphrase (response, msg_getreason (code));
to_clone (request->to, &response->to);
from_clone (request->from, &response->from);
/* via headers */
pos = 0;
while (!list_eol (request->vias, pos)) {
via_t *via;
via = (via_t *) list_get (request->vias, pos);
via_2char (via, &tmp);
msg_setvia (response, tmp);
free (tmp);
pos++;
}
call_id_clone(request->call_id,&response->call_id);
cseq_clone(request->cseq,&response->cseq);
return response;
}
int check_vialoop (sip_t *my_msg) {
int sts;
int pos;
int found_own_via;
found_own_via=0;
pos = 1; /* for detecting a loop, don't check the first entry
as this is my VIA! */
while (!list_eol (my_msg->vias, pos)) {
via_t *via;
via = (via_t *) list_get (my_msg->vias, pos);
sts = is_via_local (via);
if (sts == 1) found_own_via=1;
pos++;
}
return found_own_via;
}
int is_via_local (via_t *via) {
int sts;
struct in_addr addr_via, addr_myself;
char *my_hostnames[]=
{ configuration.inboundhost, configuration.outboundhost, NULL };
int i;
char *ptr;
DEBUGC(DBCLASS_BABBLE,"via name %s",via->host);
if (inet_aton(via->host,&addr_via) == 0) {
/* need name resolution */
get_ip_by_host(via->host, &addr_via);
}
/* make this more optimized!!
do the lookup at the beginning and then compare against all
the via entries !
*/
sts=0;
for (i=0; ; i++) {
ptr=my_hostnames[i];
if (ptr==NULL) break;
DEBUGC(DBCLASS_BABBLE,"local name %s",ptr);
/* check the extracted VIA against my own host addresses */
sts = get_ip_by_host(ptr, &addr_myself);
if (memcmp(&addr_myself, &addr_via, sizeof(addr_myself))==0) {
sts=1;
break;
}
}
return sts;
}
int get_ip_by_host(char *hostname, struct in_addr *addr) {
struct hostent *hostentry;
/* &&&& bahh, figure out a way to make this stuff non-blocking*/
/* an asynchronous name-resolving might be neat */
hostentry=gethostbyname(hostname);
if (hostentry==NULL) {
ERROR("gethostbyname(%s) failed: %s",hostname,hstrerror(h_errno));
return 1;
}
memcpy(addr, hostentry->h_addr, sizeof(struct in_addr));
DEBUGC(DBCLASS_BABBLE, "resolved: %s -> %s", hostname, inet_ntoa(*addr));
return 0;
}

1
stamp-h.in Normal file
View File

@ -0,0 +1 @@
timestamp