Merge pull request #2 from crocodilertc/master

Enterprise Linux (CentOS|Red Hat) support
github/master
Richard Fuchs 12 years ago
commit 77849a3ea6

@ -7,7 +7,16 @@ CFLAGS+= `pkg-config --cflags openssl`
CFLAGS+= `pcre-config --cflags`
CFLAGS+= -I/lib/modules/`uname -r`/build/include/ -I../kernel-module/
CFLAGS+= -D_GNU_SOURCE
CFLAGS+= -DMEDIAPROXY_VERSION="\"$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')\""
ifneq ($(MEDIAPROXY_VERSION),)
CFLAGS+= -DMEDIAPROXY_VERSION="\"$(MEDIAPROXY_VERSION)\""
else
DPKG_PRSCHNGLG= $(shell which dpkg-parsechangelog 2>/dev/null)
ifneq ($(DPKG_PRSCHNGLG),)
CFLAGS+= -DMEDIAPROXY_VERSION="\"$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')\""
else
CFLAGS+= -DMEDIAPROXY_VERSION="\"undefined\""
endif
endif
CFLAGS+= -DMP_PLUGIN_DIR="\"/usr/lib/mediaproxy-ng\""
#CFLAGS+= -DSRTCP_KEY_DERIVATION_RFC_COMPLIANCE
@ -27,10 +36,13 @@ LDFLAGS+= `pcre-config --libs`
LDFLAGS+= `xmlrpc-c-config client --libs`
ifneq ($(DBG),yes)
# support http://wiki.debian.org/Hardening for >=wheezy
CFLAGS+= `dpkg-buildflags --get CFLAGS`
CPPFLAGS+= `dpkg-buildflags --get CPPFLAGS`
LDFLAGS+= `dpkg-buildflags --get LDFLAGS`
DPKG_BLDFLGS= $(shell which dpkg-buildflags 2>/dev/null)
ifneq ($(DPKG_BLDFLGS),)
# support http://wiki.debian.org/Hardening for >=wheezy
CFLAGS+= `dpkg-buildflags --get CFLAGS`
CPPFLAGS+= `dpkg-buildflags --get CPPFLAGS`
LDFLAGS+= `dpkg-buildflags --get LDFLAGS`
endif
endif
SRCS= main.c kernel.c poller.c aux.c control_tcp.c streambuf.c call.c control_udp.c redis.c \

@ -0,0 +1,120 @@
mediaproxy-ng for Enterprise Linux
==================================
Installing from RPMs
--------------------
There are three RPMs:
- *ngcp-mediaproxy-ng*: the userspace daemon
- *ngcp-mediaproxy-ng-kernel*: the iptables plugin
- *ngcp-mediaproxy-ng-dkms*: the kernel module source
All of the RPMs have correctly set dependencies and if you just want the
userspace daemon you can install it with yum (assuming you have access to a
CentOS repository).
The *ngcp-mediaproxy-ng-kernel* package is dependent on the
*ngcp-mediaproxy-ng*, and *ngcp-mediaproxy-ng-dkms* packages. The
*ngcp-mediaproxy-ng-dkms* package has a dependency (DKMS) that cannot be met
by the standard CentOS repository. If you want to use in-kernel forwarding you
need to download and install the latest version of the
[*dkms*](http://linux.dell.com/dkms/) package before attempting to install
*ngcp-mediaproxy-ng-dkms* or *ngcp-mediaproxy-ng-kernel*.
Note: installing *ngcp-mediaproxy-ng-dkms* builds a kernel module which requires
the sources for the running kernel. The *kernel-devel* and *kernel-headers*
packages are meta-packages that install the headers and source for the latest
kernel version. This will be what what you want unless you are running a custom
or older kernel. *ngcp-mediaproxy-ng-dkms* does not have *kernel-devel* and
*kernel-headers* as dependencies as this could cause problems if you are using
a custom or older kernel, so you need to install these manually.
RPM Compliation
---------------
To build the RPMs you need all of the packages listed in the Manual Compilation
section (except for *kernel-devel* and *kernel-headers*) plus:
- *redhat-rpm-config*
- *rpm-build*
To build the RPMs:
- Checkout (clone) the Git repository
- Create the `~/rpmbuild/SOURCES` directory
- Create a tar archive. For example, from within the cloned directory you can
use
`git archive --output ~/rpmbuild/SOURCES/ngcp-mediaproxy-ng-<version number>.tar.gz --prefix=ngcp-mediaproxy-ng-<version number>/ master`
where `<version number>` is the version number of the master branch
- Build the RPMs. For example,
`rpmbuild -ta ~/rpmbuild/SOURCES/ngcp-mediaproxy-ng-<version number>.tar.gz`
Once the build has completed the binary RPMs will be in `~/rpmbuild/RPMS`.
Manual Compilation
------------------
There are three parts to mediaproxy-ng, each of which can be found in the
respective subdirectories.
* `daemon`
The userspace daemon and workhorse, minimum requirement for anything
to work. Running `MEDIAPROXY_VERSION="\"<version number>\"" make` will
compile the binary, which will be called `mediaproxy-ng`. The
following software packages are required to compile the daemon:
- *gcc*
- *make*
- *pkgconfig*
- *glib2-devel*
- *libcurl-devel*
- *openssl-devel*
- *pcre-devel*
- *xmlrpc-c-devel*
- *zlib-devel*
* `iptables-extension`
Required for in-kernel packet forwarding. Running
`MEDIAPROXY_VERSION="\"<version number>\"" make` will compile the plugin
for `iptables` and `ip6tables`. The file will be called
`libxt_MEDIAPROXY.so` and should be copied into the directory
`/lib/xtables/` in 32-bit environments and `/lib64/xtables/` in 64-bit
environments. The following software packages are required to compile
the plugin:
- *gcc*
- *make*
- *iptables-devel*
* `kernel-module`
Required for in-kernel packet forwarding. Compilation of the kernel
module requires the kernel development packages for the kernel version
you are using (see output of `uname -r`) to be installed. Running
`MEDIAPROXY_VERSION="\"<version number>\"" make` will compile the kernel
module.
Successful compilation of the module will produce the file
`xt_MEDIAPROXY.ko`. The module can be inserted into the running kernel
manually through `insmod xt_MEDIAPROXY.ko` (which will result in an
error if depending modules aren't loaded, for example the `x_tables`
module), but it's recommended to copy the module into
`/lib/modules/<version number>/updates/`, followed by running
`depmod -a`. After this, the module can be loaded by issuing
`modprobe xt_MEDIAPROXY`.
The following software packages are required to compile the plugin:
- *gcc*
- *make*
- *kernel-devel*
- *kernel-headers*
Note: the *kernel-devel* and *kernel-headers* packages are meta-packages
that install the headers and source for the latest kernel version. This
will be what you want unless you are running a custom or older kernel.

@ -0,0 +1,210 @@
#!/bin/bash
#
# mediaproxy-ng Startup script for NGCP mediaproxy-ng
#
# chkconfig: 345 84 16
# description: NGCP mediaproxy-ng
#
# processname: mediaproxy-ng
# config: /etc/sysconfig/mediaproxy-ng
# pidfile: /var/run/mediaproxy-ng.pid
#
### BEGIN INIT INFO
# Provides: mediaproxy-ng
# Required-Start: $local_fs $network
# Short-Description: NGCP mediaproxy-ng
# Description: NGCP mediaproxy-ng
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/mediaproxy-ng ]
then
. /etc/sysconfig/mediaproxy-ng
else
echo "Error: /etc/sysconfig/mediproxy-ng not present"
exit -1
fi
mediaproxy_ng=/usr/sbin/mediaproxy-ng
prog=mediaproxy-ng
pidfile=${PIDFILE-/var/run/mediaproxy-ng.pid}
lockfile=${LOCKFILE-/var/lock/subsys/mediaproxy-ng}
cachefile=/var/lib/mediaproxy-ng/mediaproxy-ng.cfg
RETVAL=0
OPTS="--pidfile $pidfile"
MODULE=0
IP6=0
build_opts() {
shopt -s nocasematch
RPMS=`rpm -qa | grep ngcp-mediaproxy-ng-kernel`
if [[ "$KERNEL" == "yes" && -n "$TABLE" && -n "$RPMS" ]]
then
MODULE=1
OPTS+=" --table=$TABLE"
else
MODULE=0
OPTS+=" --table=-1"
fi
if [[ "$FALLBACK" != "yes" ]]
then
OPTS+=" --no-fallback"
fi
shopt -u nocasematch
if [[ -n "$RTP_IP" ]]
then
OPTS+=" --ip=$RTP_IP"
fi
if [[ -n "$RTP_ADV_IP" ]]
then
OPTS+=" --advertised-ip=$RTP_ADV_IP"
fi
if [[ -n "$RTP_IP6" ]]
then
OPTS+=" --ip6=$RTP_IP6"
IP6=1
fi
if [[ -n "$RTP_ADV_IP6" ]]
then
OPTS+=" --advertised-ip6=$RTP_ADV_IP6"
fi
if [[ -n "$LISTEN_TCP" ]]
then
OPTS+=" --listen-tcp=$LISTEN_TCP"
fi
if [[ -n "$LISTEN_UDP" ]]
then
OPTS+=" --listen-udp=$LISTEN_UDP"
fi
if [[ -n "$LISTEN_NG" ]]
then
OPTS+=" --listen-ng=$LISTEN_NG"
fi
if [[ -n "$TOS" ]]
then
OPTS+=" --tos=$TOS"
fi
if [[ -n "$TIMEOUT" ]]
then
OPTS+=" --timeout=$TIMEOUT"
fi
if [[ -n "$SILENT_TIMEOUT" ]]
then
OPTS+=" --silent-timeout=$SILENT_TIMEOUT"
fi
if [[ -n "$PORT_MIN" ]]
then
OPTS+=" --port-min=$PORT_MIN"
fi
if [[ -n "$PORT_MAX" ]]
then
OPTS+=" --port-max=$PORT_MAX"
fi
if [[ -n "$REDIS" ]]
then
OPTS+=" --redis=$REDIS"
fi
if [[ -n "$REDIS_DB" ]]
then
OPTS+=" --redis-db=$REDIS_DB"
fi
if [[ -n "$B2B_URL" ]]
then
OPTS+=" --b2b-url=$B2B_URL"
fi
}
start() {
build_opts
if [[ $MODULE == 1 ]]
then
echo "Loading module for in-kernel packet forwarding"
modprobe xt_MEDIAPROXY
iptables -I INPUT -p udp -j MEDIAPROXY --id $TABLE
if [[ IP6 == 1 ]]
then
ip6tables -I INPUT -p udp -j MEDIAPROXY --id $TABLE
fi
cat <<EOF > "$cachefile"
CUR_TABLE=$TABLE
CUR_IP6=$IP6
EOF
fi
echo -n $"Starting $prog: "
daemon --pidfile=${pidfile} $mediaproxy_ng $OPTS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} $mediaproxy_ng
RETVAL=$?
echo
if [ -f "$cachefile" ]
then
. "$cachefile"
echo "Unloading module for in-kernel packet forwarding"
echo "del $TABLE" > /proc/mediaproxy/control
iptables -D INPUT -p udp -j MEDIAPROXY --id $CUR_TABLE
if [[ CUR_IP6 == 1 ]]
then
ip6tables -D INPUT -p udp -j MEDIAPROXY --id $CUR_TABLE
fi
# rmmod xt_MEDIAPROXY
rm -f $cachefile
fi
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $mediaproxy_ng
RETVAL=$?
;;
restart)
stop
start
;;
condrestart|try-restart)
if status -p ${pidfile} $mediaproxy_ng >&/dev/null; then
stop
start
fi
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|status}"
RETVAL=2
esac
exit $RETVAL

@ -0,0 +1,174 @@
Name: ngcp-mediaproxy-ng
Version: 2.3.0
Release: 1%{?dist}
Summary: The Sipwise NGCP mediaproxy-ng
Group: System Environment/Daemons
License: unknown
URL: https://github.com/crocodilertc/mediaproxy-ng
Source: %{name}-%{version}.tar.gz
Conflicts: %{name}-kernel < %{version}
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires: gcc make pkgconfig redhat-rpm-config
BuildRequires: glib2-devel libcurl-devel openssl-devel pcre-devel
BuildRequires: xmlrpc-c-devel zlib-devel
Requires: glibc libcurl openssl pcre xmlrpc-c
%description
The Sipwise NGCP mediaproxy-ng is a proxy for RTP traffic and other UDP based
media traffic. It's meant to be used with the Kamailio SIP proxy and forms a
drop-in replacement for any of the other available RTP and media proxies.
%package kernel
Summary: NGCP mediaproxy-ng in-kernel packet forwarding
Group: System Environment/Daemons
BuildRequires: gcc make redhat-rpm-config iptables-devel
Requires: iptables iptables-ipv6 ngcp-mediaproxy-ng = %{version}
Requires: ngcp-mediaproxy-ng-dkms = %{version}
%description kernel
NGCP mediaproxy-ng in-kernel packet forwarding
%package dkms
Summary: Kernel module for NGCP mediaproxy-ng in-kernel packet forwarding
Group: System Environment/Daemons
BuildArch: noarch
BuildRequires: redhat-rpm-config
Requires: gcc make
Requires(post): dkms
Requires(preun): dkms
%description dkms
Kernel module for mediaproxy-ng in-kernel packet forwarding
%prep
%setup -q
%build
cd daemon
MEDIAPROXY_VERSION="\"%{version}-%{release}\"" make
cd ../iptables-extension
MEDIAPROXY_VERSION="\"%{version}-%{release}\"" make
cd ..
%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "$RPM_BUILD_ROOT"
# Install the userspace daemon
mkdir -p $RPM_BUILD_ROOT/%{_sbindir}
install -m755 daemon/mediaproxy-ng $RPM_BUILD_ROOT/%{_sbindir}/mediaproxy-ng
## Install the init.d script and configuration file
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d
install -m755 el/mediaproxy-ng.init \
$RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/mediaproxy-ng
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig
install -m644 el/mediaproxy-ng.sysconfig \
$RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/mediaproxy-ng
mkdir -p $RPM_BUILD_ROOT/%{_sharedstatedir}/mediaproxy-ng
# Install the iptables plugin
mkdir -p $RPM_BUILD_ROOT/%{_lib}/xtables
install -m755 iptables-extension/libxt_MEDIAPROXY.so \
$RPM_BUILD_ROOT/%{_lib}/xtables/libxt_MEDIAPROXY.so
# Install the documentation
mkdir -p $RPM_BUILD_ROOT/%{_docdir}/%{name}-%{version}-%{release}
install -m644 README.md \
$RPM_BUILD_ROOT/%{_docdir}/%{name}-%{version}-%{release}/README.md
install -m644 debian/changelog \
$RPM_BUILD_ROOT/%{_docdir}/%{name}-%{version}-%{release}/changelog
install -m644 debian/copyright \
$RPM_BUILD_ROOT/%{_docdir}/%{name}-%{version}-%{release}/copyright
install -m644 el/README.md \
$RPM_BUILD_ROOT/%{_docdir}/%{name}-%{version}-%{release}/README.el.md
## DKMS module source install
mkdir -p $RPM_BUILD_ROOT/%{_usrsrc}/%{name}-%{version}-%{release}
install -m644 kernel-module/Makefile \
$RPM_BUILD_ROOT/%{_usrsrc}/%{name}-%{version}-%{release}/Makefile
install -m644 kernel-module/xt_MEDIAPROXY.c \
$RPM_BUILD_ROOT/%{_usrsrc}/%{name}-%{version}-%{release}/xt_MEDIAPROXY.c
install -m644 kernel-module/xt_MEDIAPROXY.h \
$RPM_BUILD_ROOT/%{_usrsrc}/%{name}-%{version}-%{release}/xt_MEDIAPROXY.h
sed "s/__VERSION__/%{version}-%{release}/g" debian/dkms.conf.in > \
$RPM_BUILD_ROOT/%{_usrsrc}/%{name}-%{version}-%{release}/dkms.conf
%clean
rm -rf %{buildroot}
%pre
/usr/sbin/groupadd -r mediaproxy-ng 2> /dev/null || :
/usr/sbin/usradd -r -g mediaproxy-ng -s /bin/false -c "mediaproxy-ng daemon" \
-d %{_docdir}/%{name}-%{version}-%{release} mediaproxy-ng \
2> /dev/null || :
%post
/sbin/chkconfig --add mediaproxy-ng
%post dkms
# Add to DKMS registry, build, and install module
dkms add -m %{name} -v %{version}-%{release} --rpm_safe_upgrade &&
dkms build -m %{name} -v %{version}-%{release} --rpm_safe_upgrade &&
dkms install -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --force
true
%preun
/sbin/service mediaproxy-ng stop
/sbin/chkconfig --del mediaproxy-ng
%preun dkms
# Remove from DKMS registry
dkms remove -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --all
true
%files
%defattr(-,root,root,-)
# Userspace daemon
%{_sbindir}/mediaproxy-ng
# init.d script and configuration file
%{_sysconfdir}/rc.d/init.d/mediaproxy-ng
%config(noreplace) %{_sysconfdir}/sysconfig/mediaproxy-ng
%dir %{_sharedstatedir}/mediaproxy-ng
# Documentation
%dir %{_docdir}/%{name}-%{version}-%{release}
%doc %{_docdir}/%{name}-%{version}-%{release}/README.md
%doc %{_docdir}/%{name}-%{version}-%{release}/changelog
%doc %{_docdir}/%{name}-%{version}-%{release}/copyright
%doc %{_docdir}/%{name}-%{version}-%{release}/README.el.md
%files kernel
%defattr(-,root,root,-)
/%{_lib}/xtables/libxt_MEDIAPROXY.so
%files dkms
%defattr(-,root,root,0755)
%{_usrsrc}/%{name}-%{version}-%{release}/
%changelog
* Thu Aug 15 2013 Peter Dunkley <peter.dunkley@crocodilertc.net>
- init.d scripts and configuration file
* Wed Aug 14 2013 Peter Dunkley <peter.dunkley@crocodilertc.net>
- First version of .spec file
- Builds and installs userspace daemon (but no init.d scripts etc yet)
- Builds and installs the iptables plugin
- DKMS package for the kernel module

@ -0,0 +1,38 @@
# For more information on configuring mediaproxy-ng see
# http://github.com/sipwise/mediproxy-ng
#
# (m) means the item is mandatory, (o) means the item is optional
#
KERNEL=yes # (m) "yes" enable in-kernel forwarding, "no" disables
TABLE=0 # (o) iptables table for in-kernel forwarding rules
# comment out when "KERNEL=no"
FALLBACK=yes # (m) "yes" enables fallback to userspace forwarding
# only, "no" disables
RTP_IP=127.0.0.1 # (m) Local IPv4 address for packet forwarding
#RTP_ADV_IP=127.0.0.1 # (o) IPv4 address to "advertise" for packet forwarding
#RTP_IP6=::1 # (o) Local IPv6 address for packet forwarding
#RTP_ADV_IP6=::1 # (o) IPv6 address to "advertise" for packet forwarding
#
# At least one of LISTEN_(TCP|UDP|NG) is required
#LISTEN_TCP=127.0.0.1:2222 # IP address and port combination for TCP
# control
LISTEN_UDP=127.0.0.1:2222 # IP address and port combination for UDP
# control
#LISTEN_NG=127.0.0.1:2223 # IP address and port combination for NG (UDP)
# control
#
#TOS=184 # (o) TOS value to use in outgoing packets
#TIMEOUT=60 # (o) Number of seconds after which a media stream is
# considered dead if there is no traffic.
# Default: 60
#SILENT_TIMEOUT=3600 # (o) Number of seconds after which a muted or inactive
# stream is considered dead. Default: 3600
#PORT_MIN=30000 # (o) Lowest port in the local port range for media
# traffic. Default: 30000
#PORT_MAX=40000 # (o) Highest port in the local port range for media
# traffic. Default: 40000
#
# The following items are for use with NGCP
#REDIS=127.0.0.1:6379
#REDIS_DB=0
#B2B_URL=http://127.0.0.1:8080/xmlrpc

@ -1,5 +1,14 @@
CFLAGS = -O2 -Wall -shared -fPIC
CFLAGS += -DMEDIAPROXY_VERSION="\"$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')\""
ifneq ($(MEDIAPROXY_VERSION),)
CFLAGS += -DMEDIAPROXY_VERSION="\"$(MEDIAPROXY_VERSION)\""
else
DPKG_PRSCHNGLG= $(shell which dpkg-parsechangelog 2>/dev/null)
ifneq ($(DPKG_PRSCHNGLG),)
CFLAGS += -DMEDIAPROXY_VERSION="\"$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')\""
else
CFLAGS += -DMEDIAPROXY_VERSION="\"undefined\""
endif
endif
XTABLES = $(shell test -e /usr/include/xtables.h && echo 1)
IPTABLES = $(shell test -e /usr/include/iptables.h && echo 1)

@ -1,11 +1,18 @@
PWD := $(shell pwd)
KSRC ?= /lib/modules/$(shell uname -r)/build
KBUILD := $(KSRC)
ifeq ($(origin MEDIAPROXY_VERSION), undefined)
MEDIAPROXY_VERSION := $(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')
export MEDIAPROXY_VERSION
ifneq ($(MEDIAPROXY_VERSION),)
EXTRA_CFLAGS += -DMEDIAPROXY_VERSION="\"$(MEDIAPROXY_VERSION)\""
else
DPKG_PRSCHNGLG= $(shell which dpkg-parsechangelog 2>/dev/null)
ifneq ($(DPKG_PRSCHNGLG),)
EXTRA_CFLAGS += -DMEDIAPROXY_VERSION="\"$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}')\""
else
EXTRA_CFLAGS += -DMEDIAPROXY_VERSION="\"undefined\""
endif
endif
EXTRA_CFLAGS += -DMEDIAPROXY_VERSION="\"$(MEDIAPROXY_VERSION)\"" -D__MP_EXTERNAL
EXTRA_CFLAGS += -D__MP_EXTERNAL
obj-m += xt_MEDIAPROXY.o

Loading…
Cancel
Save