Sync with upstream 3.3.1

remotes/origin/3.3+ngcp2.6
Jon Bonilla 14 years ago
parent 153a3ba271
commit a8c25c0799

@ -1,3 +1,244 @@
===================== 2012-08-02 Version 3.3.1 Released =====================
===================== Changes Since Version 3.3.0 ===========================
commit eca8ae21eb2d2c71d4752362fd88ca078941532b
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Thu Aug 2 15:30:06 2012 +0200
Makefile.defs: version set to 3.3.1
commit da7552bf8983343072415ccafac19f59d1affa34
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Thu Aug 2 15:23:47 2012 +0200
pkg/deb: version set to 3.3.1 for deb specs
commit be9d77be00e1978be97c85e199efd712fabbabf4
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Thu Aug 2 15:19:28 2012 +0200
pkg/rpm: version set to 3.3.1 for rpm specs
commit b5f95a603228fce13b2f168dfbf0120ed2e7befd
Author: Pawel Kuzak <pawel.kuzak@1und1.de>
Date: Fri Jul 13 16:06:48 2012 +0300
Ported gruu and outbound changes to p_usrloc module
(cherry picked from commit 1f6bfa0b3ba15201c2ca3e2387a9f9e81e989643)
commit 153baccb8bbbcf08b6485f1cfc75a2b809bdafca
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Mon Jul 30 12:57:09 2012 +0200
register(k): pack contact info based on header for searching existing ul records
- not using the contact header resulted in omitting instance and reg-id
parameters, not following gruu/ob extensions, ending in duplicate
records for same +sip.instance
- reported by José Luis Millán
(cherry picked from commit efa3099252ca5d200bef6ce71df33f33b55f9941)
commit b5b534ec77634041d0ed11280241a947b61aff0c
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Mon Jul 30 12:55:36 2012 +0200
usrloc(k): on ul update, re-clone uri and callid if instance is set
- changes can happen when gruu/ob is enabled as the UA can get different
address for same instance
(cherry picked from commit a7cad776a514b0ec73a5c40b7971af8e0f0da92b)
commit 5f8405f577d66069fde48202862f06cac432139b
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Wed Jul 18 19:00:38 2012 +0200
tls: set function to return the id
- starting with v1.0.0 openssl does not use anymore getpid(), but address
of errno which can point to same virtual address in a multi-process
application
- for refrence http://www.openssl.org/docs/crypto/threads.html
- credits to Jijo on sr-dev mailing list
(cherry picked from commit 0615826fe602c5183fbc7be7c51de5eb5eb7223c)
commit cd50811c1964e4e2227e45ffcb4e5e1f0db04745
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Wed Jul 18 18:51:54 2012 +0200
kamdbctl: mtree tables were not in the list for db creation
(cherry picked from commit e35e16efbbc6c746a7a4dfeddfc241c2c78d30bc)
commit 87618b2f1c5d6e3724c3935709b81b151c4645b5
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Wed Jul 18 08:27:52 2012 +0200
kamailio.cfg: removed sample db_mode parameter for domain module
- no longer exists since 3.3 domain update
(cherry picked from commit bb4925540d241eb91cc8b68712bec20f1970b086)
commit fe8265334cef872d8f3fabe407d3f3d744a45960
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Thu Jun 28 16:24:47 2012 +0200
p_usrloc: added missing usrloc API members
- they are set to NULL to get a clean crash, they have to be implemented
- the missing API members are the functions introduced in 3.3 for
handling SIP GRUU and Outbound extensions
- a proper fix to follow
- reported by Dan Bogos
(cherry picked from commit f030b2f274b69526f256e66098de72a074000ed1)
commit 81149e30785aa1cc6f04e130afafb643d9163cce
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Mon Jun 25 10:36:31 2012 +0200
dispatcher(k): allow set id 0 for OPTIONS callback
- set id is provided in param pointer address, 0 being equivalent to
NULL
- reported by Avi Brender
(cherry picked from commit 2664cb9aa8ffd5d26ef6a0841318ccbcdefbf69b)
commit 85bda41ac007464efe940713426b54c38e5d4303
Author: Juha Heinanen <jh@tutpro.com>
Date: Fri Jul 27 13:08:21 2012 +0300
modules/lcr: improved documentation of lcr_count module param
(cherry picked from commit 9a1450d99accef8e473cf2324412fdfc09a7cd11)
commit 28be16549831df46dd1b8312da223b02359d8a9c
Author: Richard Fuchs <rfuchs@sipwise.com>
Date: Thu Jul 26 09:41:26 2012 -0400
modules/lcr: Fix printing of IPv4 addresses in lcr.dump_gws
IPv4 addresses were printed incorrectly. Also add special handling for
null gw addresses and print them as 0.0.0.0 for backwards compatibility.
commit 3a8288482aa38afd8048193ef45b8ad979cacfab
Author: Anca Vamanu <anca.vamanu@1and1.ro>
Date: Fri Jul 20 16:59:52 2012 +0300
modules/matrix Fixed MI command not exported
Added missing register_mi_mod() call in mod_init.
(cherry picked from commit b26f862322ad311e3c42d899f72eaa1fb665b755)
commit 32e67eb8ebe8e1ef1190b03151962412ad41dbd3
Author: Carsten Bock <carsten@ng-voice.com>
Date: Tue Jul 17 10:15:46 2012 -0400
Remove duplicate entry of "default_domain" in docs.
Remove double occurance of the CSeq Attribute in the XML.
(closes FS#246 - pua_reginfo adds duplicate cseq field in XML body on the Bugtracker)
Thanks to Andrew Pogrebennyk (apogrebennyk@sipwise.com) for pointing this out.
commit 4aad5415215e4157f7bbe7c1b57178920aaaf3cc
Author: Peter Dunkley <peter.dunkley@crocodile-rcs.com>
Date: Sun Jul 15 14:15:17 2012 +0100
pkg/kamailio/(centos|fedora): Updated/fixed CentOS/Fedora build appliances and .spec
- Had fixed some small issues in master, and now merged them back.
commit 6f47d8ac983cbbd616c7b5b941a8ec671f6e15e6
Author: Peter Dunkley <peter.dunkley@crocodile-rcs.com>
Date: Thu Jul 12 21:46:58 2012 +0100
modules_k/registrar: Fixed some errors in module documentation
- Fix by Hugh Waite @ Crocodile RCS
(cherry picked from commit 6d040935f31be0098a09f4621874268164f3926a)
commit a897251aaa545c8726587412009f4906ff21e2aa
Author: Peter Dunkley <peter.dunkley@crocodile-rcs.com>
Date: Thu Jul 12 21:48:08 2012 +0100
modules/sl: Fixed segmentation fault and corrected log messages
- Fixes by Hugh Waite @ Crocodile RCS
(cherry picked from commit e78ff34f1ecfe9a60a52996126032ea04fb490ab)
commit 7e412d720b1747fadac3e94c22d270877087b8a0
Author: Peter Dunkley <peter.dunkley@crocodile-rcs.com>
Date: Thu Jul 12 21:44:45 2012 +0100
core: update printing of socket lists to show the advertised address if set for the socket
- useful for diagnosing what is going on with advertised address
- Enhancement added by Hugh Waite @ Crocodile RCS
(cherry picked from commit 274969bcca2301c96dbbcc17c5b1d411073c8277)
commit ac24a183397924a7dab209c6f205b955936d4379
Author: Peter Dunkley <peter.dunkley@crocodile-rcs.com>
Date: Thu Jul 12 21:20:49 2012 +0100
modules_k/presence: Added missing use_table() call
(cherry picked from commit 0de5e17770cd5dcfcdd64174eb24f0bcaccef021)
commit 4570fc02082f69dd036ab7a3deea57ee8cffa411
Author: Peter Dunkley <peter.dunkley@crocodile-rcs.com>
Date: Thu Jul 12 16:26:38 2012 +0100
Makefile: SCTP library check doesn't look in /usr/lib64
- This means you can't build Kamailio for a 64-bit OS like CentOS or
Fedora.
(cherry picked from commit f2f8ff72137a39702d284dfe6deb9ef4442e4e78)
commit 671b52a37e3811bf89c74d83e6438739a67f50a7
Author: Klaus Darilion <klaus.mailinglists@pernau.at>
Date: Wed Jul 11 12:30:51 2012 +0000
kamdbctl: add domain_attrs table to standard tables
(cherry picked from commit 699526ddb3b02cb5766bc7ad6f1c7a1861006d4c)
commit 66240e60d99b6bf9fc8f06c05cb7f4ecf6d8d1ad
Author: Andreas Granig <agranig@sipwise.com>
Date: Wed Jul 11 12:52:38 2012 +0200
modules_k/uac: fix handling of empty display-part.
This re-enables the feature to strip the display name by setting
an empty string, like uac_replace_from("", "$var(from)");
commit 948df15d215e7d12ad404dec7dfdbb41d58bea3e
Author: Juha Heinanen <jh@tutpro.com>
Date: Wed Jul 4 17:15:43 2012 +0300
modules/lcr: Fixed to/from_gw tests when proto parameter is 0 (ANY)
- Also, updated README regarding handling of NULL value in lcr_gw
transport column.
(cherry picked from commit 1382c30da7ffd8831479affafde4d8e038a41240)
commit 3abf967f61a1bd95c28d4e8a929a8bd5df00671d
Author: Anca Vamanu <anca.vamanu@1and1.ro>
Date: Wed Jun 27 18:34:55 2012 +0300
modules_k/presence_xml Xcap auth reason when user deleted from list
The reason in Subscription-Status header in Notify when a user is
deleted from the contact list can be decided by the admin by setting
presence_xml module parameter xcapauth_usedel_reason. Default value is
"probation".
commit 33a2157ec034c106e5a4bd42aa874e57550a13fe
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Mon Jun 25 18:36:18 2012 +0200
dialog(k): proper unlock of profile for mi list command
- the profile was unlocked in a wrong place, before finishing listing
the its content and could cause a race in accessing it
- reported by Ricardo Martinez
(cherry picked from commit 3a2e929c63c656fe2db78e746546af05c66740ea)
===================== 2012-06-18 Version 3.3.0 Released =====================
===================== Changes Since Version 3.2.0 ===========================

@ -170,7 +170,7 @@ module_group_postgres=$(module_group_postgres_driver) $(module_group_db)
# For radius
module_group_radius=acc_radius auth_radius misc_radius avp_radius uri_radius \
peering pcem
peering
# For presence
# kamailio modules
@ -226,7 +226,7 @@ module_group_kpostgres=db_postgres
module_group_kcpl=cpl-c
# K radius modules
module_group_kradius=acc_radius auth_radius misc_radius peering pcem
module_group_kradius=acc_radius auth_radius misc_radius peering
# K unixodbc module
module_group_kunixodbc=db_unixodbc
@ -309,7 +309,7 @@ else
db_sqlite db_unixodbc db_cassandra memcached mi_xmlrpc \
perl perlvdb purple \
snmpstats xmpp \
carrierroute peering pcem \
carrierroute peering \
dialplan lcr utils presence presence_mwi \
presence_dialoginfo presence_xml pua pua_bla \
pua_dialoginfo pua_usrloc pua_xmpp \
@ -884,7 +884,7 @@ sunpkg:
.PHONY: install
install: mk_params="compile_for_install=yes"
install: install-bin install-every-module \
install: install-bin install-every-module install-cfg \
install-doc install-man install-utils install-share
.PHONY: dbinstall

@ -161,7 +161,7 @@ INSTALL_FLAVOUR=$(FLAVOUR)
#version number
VERSION = 3
PATCHLEVEL = 3
SUBLEVEL = 0
SUBLEVEL = 1
EXTRAVERSION =
# memory debugger switcher
@ -1742,6 +1742,7 @@ ifeq ($(OS), linux)
sctp_dev_locations := /usr/include/netinet/sctp.h \
$(LOCALBASE)/include/netinet/sctp.h
sctp_lib_locations := /usr/lib/libsctp.so \
/usr/lib64/libsctp.so \
$(LOCALBASE)/usr/local/lib/libsctp.so
sctp_dev_path := $(wildcard $(sctp_dev_locations))
sctp_lib_path := $(wildcard $(sctp_lib_locations))

@ -380,8 +380,6 @@ modparam("speeddial", "use_domain", MULTIDOMAIN)
# ----- domain params -----
#!ifdef WITH_MULTIDOMAIN
modparam("domain", "db_url", DBURL)
# use caching
modparam("domain", "db_mode", 1)
# register callback to match myself condition with domains list
modparam("domain", "register_myself", 1)
#!endif

@ -277,7 +277,7 @@ static int dp_update(struct sip_msg * msg, pv_spec_t * src, pv_spec_t * dest,
int no_change;
pv_value_t val;
no_change = (dest->type == PVT_NONE) || (!repl->s);
no_change = (dest->type == PVT_NONE) || (!repl->s) || (!repl->len);
if (no_change)
goto set_attr_pvar;

@ -147,9 +147,41 @@ int rule_translate(struct sip_msg *msg, str string, dpl_node_t * rule,
subst_comp = rule->subst_comp;
repl_comp = rule->repl_comp;
if (!subst_comp) {
/*simply copy from the replacing string*/
if(!repl_comp || !repl_comp->replacement.s || repl_comp->replacement.len == 0){
if(!repl_comp){
LM_DBG("null replacement\n");
return 0;
}
if(subst_comp){
/*just in case something went wrong at load time*/
rc = pcre_fullinfo(subst_comp, NULL, PCRE_INFO_CAPTURECOUNT,
&cap_cnt);
if (rc != 0) {
LM_ERR("pcre_fullinfo on compiled pattern yielded error: %d\n",
rc);
return -1;;
}
if(repl_comp->max_pmatch > cap_cnt){
LM_ERR("illegal access to the %i-th subexpr of the subst expr\n",
repl_comp->max_pmatch);
return -1;
}
/*search for the pattern from the compiled subst_exp*/
if (pcre_exec(rule->subst_comp, NULL, string.s, string.len,
0, 0, ovector, 3 * (MAX_REPLACE_WITH + 1)) <= 0) {
LM_ERR("the string %.*s matched "
"the match_exp %.*s but not the subst_exp %.*s!\n",
string.len, string.s,
rule->match_exp.len, rule->match_exp.s,
rule->subst_exp.len, rule->subst_exp.s);
return -1;
}
}
/*simply copy from the replacing string*/
if(!subst_comp || (repl_comp->n_escapes <=0)){
if(!repl_comp->replacement.s || repl_comp->replacement.len == 0){
LM_ERR("invalid replacing string\n");
goto error;
}
@ -162,156 +194,108 @@ int rule_translate(struct sip_msg *msg, str string, dpl_node_t * rule,
return 0;
}
/*just in case something went wrong at load time*/
rc = pcre_fullinfo(subst_comp, NULL, PCRE_INFO_CAPTURECOUNT,
&cap_cnt);
if (rc != 0) {
LM_ERR("pcre_fullinfo on compiled pattern yielded error: %d\n",
rc);
return -1;;
}
if(repl_comp && repl_comp->max_pmatch > cap_cnt){
LM_ERR("illegal access to the %i-th subexpr of the subst expr\n",
repl_comp->max_pmatch);
return -1;
}
/* offset- offset in the replacement string */
result->len = repl_nb = offset = 0;
p=repl_comp->replacement.s;
/*search for the pattern from the compiled subst_exp*/
if (pcre_exec(rule->subst_comp, NULL, string.s, string.len,
0, 0, ovector, 3 * (MAX_REPLACE_WITH + 1)) <= 0) {
LM_ERR("the string %.*s matched "
"the match_exp %.*s but not the subst_exp %.*s!\n",
string.len, string.s,
rule->match_exp.len, rule->match_exp.s,
rule->subst_exp.len, rule->subst_exp.s);
return -1;
}
/* copy non-matched prefix of string to output */
if (ovector[0] > 0) {
if (ovector[0] >= MAX_PHONE_NB_DIGITS) {
LM_ERR("overflow\n");
goto error;
}
memcpy(result->s, string.s, ovector[0]);
result->len += ovector[0];
}
while( repl_nb < repl_comp->n_escapes){
if (repl_comp) {
/* offset- offset in the replacement string */
repl_nb = offset = 0;
p=repl_comp->replacement.s;
token = repl_comp->replace[repl_nb];
while( repl_nb < repl_comp->n_escapes){
token = repl_comp->replace[repl_nb];
if(offset< token.offset){
if((repl_comp->replacement.len < offset)||
if(offset< token.offset){
if((repl_comp->replacement.len < offset)||
(result->len + token.offset -offset >= MAX_PHONE_NB_DIGITS)){
LM_ERR("invalid length\n");
LM_ERR("invalid length\n");
goto error;
}
/*copy from the replacing string*/
size = token.offset - offset;
memcpy(result->s + result->len, p + offset, size);
LM_DBG("copying <%.*s> from replacing string\n",
size, p + offset);
result->len += size;
offset = token.offset;
}
switch(token.type) {
case REPLACE_NMATCH:
/*copy from the match subexpression*/
match_nb = token.u.nmatch * 2;
match.s = string.s + ovector[match_nb];
match.len = ovector[match_nb + 1] - ovector[match_nb];
if(result->len + match.len >= MAX_PHONE_NB_DIGITS){
LM_ERR("overflow\n");
goto error;
}
/*copy from the replacing string*/
size = token.offset - offset;
memcpy(result->s + result->len, p + offset, size);
LM_DBG("copying <%.*s> from replacing string\n",
size, p + offset);
result->len += size;
offset = token.offset;
}
switch(token.type) {
case REPLACE_NMATCH:
/*copy from the match subexpression*/
match_nb = token.u.nmatch * 2;
match.s = string.s + ovector[match_nb];
match.len = ovector[match_nb + 1] - ovector[match_nb];
if(result->len + match.len >= MAX_PHONE_NB_DIGITS){
LM_ERR("overflow\n");
goto error;
}
memcpy(result->s + result->len, match.s, match.len);
LM_DBG("copying match <%.*s> token size %d\n",
match.len, match.s, token.size);
result->len += match.len;
offset += token.size;
memcpy(result->s + result->len, match.s, match.len);
LM_DBG("copying match <%.*s> token size %d\n",
match.len, match.s, token.size);
result->len += match.len;
offset += token.size;
break;
case REPLACE_CHAR:
if(result->len + 1>= MAX_PHONE_NB_DIGITS){
LM_ERR("overflow\n");
goto error;
}
*(result->s + result->len) = token.u.c;
LM_DBG("copying char <%c> token size %d\n",
case REPLACE_CHAR:
if(result->len + 1>= MAX_PHONE_NB_DIGITS){
LM_ERR("overflow\n");
goto error;
}
*(result->s + result->len) = token.u.c;
LM_DBG("copying char <%c> token size %d\n",
token.u.c, token.size);
result->len++;
offset += token.size;
result->len++;
offset += token.size;
break;
case REPLACE_URI:
if ( msg== NULL || msg->first_line.type!=SIP_REQUEST){
LM_CRIT("uri substitution attempt on no request"
case REPLACE_URI:
if ( msg== NULL || msg->first_line.type!=SIP_REQUEST){
LM_CRIT("uri substitution attempt on no request"
" message\n");
break; /* ignore, we can continue */
}
uri= (msg->new_uri.s)?(&msg->new_uri):
(&msg->first_line.u.request.uri);
if(result->len+uri->len>=MAX_PHONE_NB_DIGITS){
LM_ERR("overflow\n");
goto error;
}
memcpy(result->s + result->len, uri->s, uri->len);
LM_DBG("copying uri <%.*s> token size %d\n",
break; /* ignore, we can continue */
}
uri= (msg->new_uri.s)?(&msg->new_uri):
(&msg->first_line.u.request.uri);
if(result->len+uri->len>=MAX_PHONE_NB_DIGITS){
LM_ERR("overflow\n");
goto error;
}
memcpy(result->s + result->len, uri->s, uri->len);
LM_DBG("copying uri <%.*s> token size %d\n",
uri->len, uri->s, token.size);
result->len+=uri->len;
offset += token.size;
result->len+=uri->len;
offset += token.size;
break;
case REPLACE_SPEC:
if (msg== NULL) {
LM_DBG("replace spec attempted on no message\n");
break;
}
if (pv_get_spec_value(msg, &token.u.spec, &sv) != 0) {
LM_CRIT("item substitution returned error\n");
break; /* ignore, we can continue */
}
if(result->len+sv.rs.len>=MAX_PHONE_NB_DIGITS){
LM_ERR("rule_translate: overflow\n");
goto error;
}
memcpy(result->s + result->len, sv.rs.s,
sv.rs.len);
LM_DBG("copying pvar value <%.*s> token size %d\n",
case REPLACE_SPEC:
if (msg== NULL) {
LM_DBG("replace spec attempted on no message\n");
break;
}
if (pv_get_spec_value(msg, &token.u.spec, &sv) != 0) {
LM_CRIT("item substitution returned error\n");
break; /* ignore, we can continue */
}
if(result->len+sv.rs.len>=MAX_PHONE_NB_DIGITS){
LM_ERR("rule_translate: overflow\n");
goto error;
}
memcpy(result->s + result->len, sv.rs.s,
sv.rs.len);
LM_DBG("copying pvar value <%.*s> token size %d\n",
sv.rs.len, sv.rs.s, token.size);
result->len+=sv.rs.len;
offset += token.size;
result->len+=sv.rs.len;
offset += token.size;
break;
default:
LM_CRIT("unknown type %d\n", repl_comp->replace[repl_nb].type);
/* ignore it */
}
repl_nb++;
}
/* anything left? */
if(offset < repl_comp->replacement.len){
/*copy from the replacing string*/
size = repl_comp->replacement.len - offset;
memcpy(result->s + result->len, p + offset, size);
LM_DBG("copying leftover <%.*s> from replacing string\n",
size, p + offset);
result->len += size;
default:
LM_CRIT("unknown type %d\n", repl_comp->replace[repl_nb].type);
/* ignore it */
}
repl_nb++;
}
/* copy non-matched suffix of string to output */
size = string.len - ovector[1];
if (size > 0) {
if (result->len + size >= MAX_PHONE_NB_DIGITS) {
LM_ERR("overflow\n");
goto error;
}
memcpy(result->s + result->len, string.s + ovector[1], size);
/* anything left? */
if( repl_nb && offset < repl_comp->replacement.len){
/*copy from the replacing string*/
size = repl_comp->replacement.len - offset;
memcpy(result->s + result->len, p + offset, size);
LM_DBG("copying leftover <%.*s> from replacing string\n",
size, p + offset);
result->len += size;
}

@ -0,0 +1,373 @@
--- /root/sip-router/etc/sip-router-oob.cfg 2011-04-05 21:11:22.000000000 +0200
+++ sip-router-oob-RTPPROXY.cfg-pre_flexroute 2011-04-05 21:03:19.000000000 +0200
@@ -283,23 +287,11 @@
#
session_timer.min_se = "90" desc "minimum session interval (in s)"
-# RTP Proxy options
-#
-# Whether to enable or disable the rtp proxy. Possible values are:
-# "0" -- always disable
-# "1" -- always enable regardless of whether UAC or UAS is behind NAT
-# "detect" -- detect whether the UAC or the UAS is behind NAT,
-# and enable the rtp proxy when necessary
-#
-#DEBCONF-RTP_ENABLE-START
-rtp_proxy.enabled = "detect" desc "indicates whether the RTP Proxy is enabled or not (0/1/detect)"
-#DEBCONF-RTP_ENABLE-END
-
# ------------------ Module Loading -----------------------------------------
#!ifdef LOCAL_TEST_RUN
loadpath "modules:modules_s"
#!else
-loadpath "/usr/lib/sip-router/modules:/usr/lib/sip-router/modules_s"
+loadpath "/usr/local/lib/ser/modules:/usr/local/lib/ser/modules_s"
#!endif
# load a SQL database for authentication, domains, user AVPs etc.
@@ -457,7 +449,7 @@
modparam("rr", "enable_full_lr", 1)
# Limit the length of the AVP cookie to necessary attributes only
-modparam("rr", "cookie_filter", "(account|rproxy|stimer|dialog_id)")
+modparam("rr", "cookie_filter", "(account|stimer|dialog_id)")
# You probably do not want that someone can simply read and change
# the AVP cookie in your Routes, thus should really change this
@@ -467,7 +459,7 @@
# The ftag Route parameter may be used to easily determine if a BYE
# is coming from caller or callee, but we prefer shorter messages
# Enable when FLAG_REVERSE_DIR is to be used
-modparam("rr", "append_fromtag", 0)
+modparam("rr", "append_fromtag", 1)
# -- gflags --
@@ -529,7 +521,7 @@
# RTP Proxy address
#DEBCONF-RTTPPROXY-START
-modparam("nathelper", "rtpproxy_sock", "udp:127.0.0.1:22222")
+#modparam("nathelper", "rtpproxy_sock", "udp:127.0.0.1:22222")
#DEBCONF-RTTPPROXY-END
# TCP keepalives as simple as CRLF
@@ -649,7 +641,7 @@
route(PSTN);
# nothing matched
- sl_reply("404", "No route matched");
+ t_reply("404", "No route matched");
}
# Forward a request to the destination set.
@@ -668,7 +660,8 @@
# If this is an initial INVITE (without a To-tag) we might try
# another target (call forwarding or voicemail) after receiving
# an error.
- if (isflagset(FLAG_INIT_DLG)) {
+ # and also for RTPPROXY processing
+ if (method=="INVITE" || method == "UPDATE") {
t_on_failure("FAILURE_ROUTE");
}
@@ -682,7 +675,7 @@
# Activate the RTP proxy as the second last step because it modifies the
# body but also sets an dialog AVP cookie.
- route(RTPPROXY);
+ route(RTPPROXY_PROCESS_REQUEST);
# Insert a Record-Route header into all requests.
# This has to be done as one of the last steps to include all the
@@ -742,10 +735,10 @@
# if needed then we MUST put after force_rport() which is located in NAT_DETECTION!!!
# also must be called after FLAG_ACC is set !!!
# Check t_reply() vs. sl_reply() usage in script
- #if (!t_newtran()) {
- # sl_reply("500", "Internal tm error");
- # drop;
- #}
+ if (!t_newtran()) {
+ sl_reply("500", "Internal tm error");
+ drop;
+ }
# Set flag and use it instead of the attribute.
if ($replicate==1) {
@@ -765,6 +758,7 @@
(uri == myself || $t.did != ""))
{
options_reply();
+ t_release();
drop;
}
}
@@ -879,47 +873,7 @@
}
}
-
-# Activates RTP proxy if necessary.
-#
-route[RTPPROXY]
-{
- if (@cfg_get.rtp_proxy.enabled == "0") {
- # RTP Proxy is disabled
- break;
- } else if (@cfg_get.rtp_proxy.enabled == "detect") {
- if (!isflagset(FLAG_NAT)) {
- # If no NAT is involved we don't have to do here anything.
- break;
- }
- } else if (@cfg_get.rtp_proxy.enabled != "1") {
- # This is not a valid setting
- xlog("L_ERR", "Unknown option for rtp_proxy.enabled: %@cfg_get.rtp_proxy.enabled\n");
- break;
- } # else rtp proxy is permanently enabled
-
- # If the message terminates a dialog for which the RTP proxy
- # was turned on, turn it off again.
- if ((method == "BYE" && isflagset(FLAG_RTP_PROXY)) ||
- (method == "CANCEL")) {
- unforce_rtp_proxy();
- append_hf("P-RTP-Proxy: Off\r\n");
- break;
- }
-
- # Turn the RTP proxy on for INVITEs and UPDATEs, if they
- # have a body
- if (((method=="INVITE" || method == "UPDATE") && @msg.body != "")
- && !isflagset(FLAG_RTP_PROXY))
- {
- force_rtp_proxy('r');
- append_hf("P-RTP-Proxy: On\r\n");
- setflag(FLAG_RTP_PROXY);
- $rproxy = 1;
- setavpflag($rproxy, "dialog_cookie");
- }
-}
-
+include_file "sip-router-oob-RTPPROXY.cfg.inc"
# Handling of Route headers
#
@@ -934,7 +888,7 @@
xlog("L_DEBUG", "\n%mb\n\ndialogid -/from/to=%$dialog_id/%$f.dialog_id/%$t.dialog_id");
if (method == "INVITE" || method == "UPDATE" || method == "ACK" || method == "BYE") {
if (!defined $dialog_id) {
- sl_reply("400", "Missing cookie");
+ t_reply("400", "Missing cookie");
drop;
}
}
@@ -954,11 +908,6 @@
setflag(FLAG_ACC_MISSED);
}
- # Restore the RTP proxy flag if present
- if ($rproxy == "1") {
- setflag(FLAG_RTP_PROXY);
- }
-
# Restore Session Timer flag and headers.
if ( defined $stimer && ($stimer != "0")) {
route(SESSION_TIMER);
@@ -1039,7 +988,7 @@
# then From b@B and To a@A. There is no mentioning of c@C despite
# legitimate behaviour of c@C).
if (!isflagset(FLAG_TOTAG) && strempty($t.did) && strempty($f.did)) {
- sl_reply("403", "Relaying Forbidden");
+ t_reply("403", "Relaying Forbidden");
drop;
}
}
@@ -1057,6 +1006,7 @@
# If this is a replica (sent to the multicast address), trust it to
# be secure and store it in usrloc
if (dst_ip==224.0.1.75) {
+ t_release();
if (!isflagset(FLAG_REPL_ENABLED)) {
# Multicast replication administratively disabled.
# Ignore.
@@ -1097,13 +1047,13 @@
# Check if the REGISTER if for one of our local domains.
if (strempty($t.did)) {
- sl_reply("403", "Register Forwarding Forbidden");
+ t_reply("403", "Register Forwarding Forbidden");
drop;
}
# The REGISTER target is in the To header, so reload the domain.
if (!lookup_domain("$td", "@to.uri.host")) {
- sl_reply("404", "Unknown Domain");
+ t_reply("404", "Unknown Domain");
drop;
}
@@ -1115,29 +1065,29 @@
# We want only authenticated users to be registered.
if (!www_authenticate("$fd.digest_realm", "credentials")) {
if ($? == -2) {
- sl_reply("500", "Internal Server Error");
+ t_reply("500", "Internal Server Error");
}
else if ($? == -3) {
- sl_reply("400", "Bad Request");
+ t_reply("400", "Bad Request");
}
else {
if ($digest_challenge != "") {
append_to_reply("%$digest_challenge");
}
- sl_reply("401", "Unauthorized");
+ t_reply("401", "Unauthorized");
}
drop;
}
# Check if the authenticated user is the same as the target user.
if (!lookup_user("$tu.uid", "@to.uri")) {
- sl_reply("404", "Unknown user in To");
+ t_reply("404", "Unknown user in To");
drop;
}
# the authentication ID does not match the ID in the To header
if ($f.uid != $t.uid) {
- sl_reply("403", "Authentication and To-Header mismatch");
+ t_reply("403", "Authentication and To-Header mismatch");
drop;
}
@@ -1145,11 +1095,11 @@
# originator. You may uncomment it if you care, which URI is in
# the From header.
#if (!lookup_user("$fr.uid", "@from.uri")) {
- # sl_reply("404", "Unknown user in From");
+ # t_reply("404", "Unknown user in From");
# drop;
#}
#if ($fu.uid != $fr.uid) {
- # sl_reply("403", "Authentication and From-Header mismatch");
+ # t_reply("403", "Authentication and From-Header mismatch");
# drop;
#}
@@ -1158,7 +1108,7 @@
}
# Everything is fine. Store the binding.
if (!save_contacts("location")) {
- sl_reply("400", "Invalid REGISTER Request");
+ t_reply("400", "Invalid REGISTER Request");
drop;
}
# do not delete the following 3 lines, they are used by debconf
@@ -1190,7 +1140,7 @@
#DEBCONF-REPLICATION2-START
#
#DEBCONF-REPLICATION2-END
-
+ t_release();
drop;
}
@@ -1221,16 +1171,16 @@
if (!proxy_authenticate("$fd.digest_realm", "credentials")) {
if ($? == -2) {
- sl_reply("500", "Internal Server Error");
+ t_reply("500", "Internal Server Error");
}
else if ($? == -3) {
- sl_reply("400", "Bad Request");
+ t_reply("400", "Bad Request");
}
else {
if (defined $digest_challenge && $digest_challenge != "") {
append_to_reply("%$digest_challenge");
}
- sl_reply("407", "Proxy Authentication Required");
+ t_reply("407", "Proxy Authentication Required");
}
drop;
}
@@ -1238,11 +1188,11 @@
# Check if the UID derived from authentication matches that from
# the From header.
if (!lookup_user("$fr.uid", "@from.uri")) {
- sl_reply("403", "Fake Identity");
+ t_reply("403", "Fake Identity");
drop;
}
if ($fu.uid != $fr.uid) {
- sl_reply("403", "Fake Identity");
+ t_reply("403", "Fake Identity");
drop;
}
setflag(FLAG_AUTH_OK);
@@ -1274,10 +1224,10 @@
# UA to the real target.
if ($fd.did != "" && uri =~ "sip:[0-9][0-9]@") {
if (sd_lookup("speed_dial")) {
- sl_reply("302", "Speed Dial Redirect");
+ t_reply("302", "Speed Dial Redirect");
}
else {
- sl_reply("404", "Speed Dial Not Found");
+ t_reply("404", "Speed Dial Not Found");
}
drop;
}
@@ -1392,7 +1342,7 @@
# Check permissions of the caller for initial INVITEs.
if (isflagset(FLAG_INIT_DLG)) {
if ($f.gw_acl != "1") {
- sl_reply("403", "PSTN Not Permitted");
+ t_reply("403", "PSTN Not Permitted");
drop;
}
}
@@ -1431,7 +1381,7 @@
xlog("L_DEBUG", "catching cancel dialogid=%$dialog_id\n");
if (!t_relay_cancel()) {
# An INVITE was found but some error occurred.
- sl_reply("500", "Internal Server Error");
+ t_reply("500", "Internal Server Error");
drop;
}
# Bad luck, no corresponding INVITE was found, we have to
@@ -1486,7 +1436,7 @@
# Session interval is lower than the
# configured Min-SE
append_to_reply("Min-SE: %@cfg_get.session_timer.min_se\r\n");
- sl_reply("422", "Session Interval Too Small");
+ t_reply("422", "Session Interval Too Small");
drop;
}
@@ -1592,6 +1542,7 @@
}
}
} # if (isflagset...
+ route(RTPPROXY_PROCESS_FAILURE);
}
@@ -1603,14 +1554,7 @@
# allow proper routing of in-dialog messages.
route(UAS_NAT_DETECTION);
- # If RTP proxy was activated and this is a 18x or 2xx reply with a
- # body, inform RTP proxy.
- if (isflagset(FLAG_RTP_PROXY)
- && status=~"(18[03])|(2[0-9][0-9])"
- && @msg.body != "")
- {
- force_rtp_proxy('r');
- }
+ route(RTPPROXY_PROCESS_REPLY);
# Let's check for session timer support.
if (isflagset(FLAG_SESSIONTIMER) && status =~ "2[0-9][0-9]") {

@ -268,8 +268,8 @@ Chapter 1. Admin Guide
scheme, IP address, port, and transport protocol.
Valid URI scheme values are NULL = sip, 1 = sip and 2 = sips. Currently
valid transport protocol values are NULL = none, 1 = udp, 2 = tcp, 3 =
tls, and 4 = sctp.
valid transport protocol values are NULL and 0 = none, 1 = udp, 2 =
tcp, 3 = tls, and 4 = sctp.
As a side effect of gateway selection, selected gateway's tag and flags
(that may contain information about the gateway and its capabilities)
@ -638,7 +638,7 @@ modparam("lcr","weight_column", "target_weight")
3.27. lcr_count (integer)
Number of LCR instances.
Maximun value of lcr_id.
Default value is 1.

@ -103,7 +103,7 @@
</para>
<para>
Valid URI scheme values are NULL = sip, 1 = sip and 2
= sips. Currently valid transport protocol values are NULL =
= sips. Currently valid transport protocol values are NULL and 0 =
none, 1 = udp, 2 = tcp, 3 = tls, and 4 = sctp.
</para>
<para>
@ -716,7 +716,7 @@ modparam("lcr","weight_column", "target_weight")
<section>
<title><varname>lcr_count</varname> (integer)</title>
<para>
Number of LCR instances.
Maximun value of lcr_id.
</para>
<para>
<emphasis>

@ -2309,8 +2309,8 @@ static int do_from_gw(struct sip_msg* _m, unsigned int lcr_id,
/* Store tag and flags and return result */
if ((res != NULL) &&
((transport == PROTO_NONE) || (res->transport == transport))) {
LM_DBG("request came from gw\n");
((transport == PROTO_NONE) || (res->transport == transport))) {
LM_DBG("request game from gw\n");
if (tag_avp_param) {
val.s.s = res->tag;
val.s.len = res->tag_len;
@ -2498,8 +2498,7 @@ static int do_to_gw(struct sip_msg* _m, unsigned int lcr_id,
/* Return result */
if ((res != NULL) &&
((res->transport == transport) ||
((transport == PROTO_NONE) && (res->transport == PROTO_UDP)))) {
((transport == PROTO_NONE) || (res->transport == transport))) {
LM_DBG("request goes to gw\n");
return 1;
} else {

@ -584,6 +584,12 @@ static int mod_init(void)
{
matrix_db_vars();
if(register_mi_mod(exports.name, mi_cmds)!=0)
{
LM_ERR("failed to register MI commands\n");
return -1;
}
if (init_shmlock() != 0) return -1;
if (matrix_db_init() != 0) return -1;
if (matrix_db_open() != 0) return -1;

@ -283,8 +283,7 @@ static int alter_mediaport(struct sip_msg *, str *, str *, str *, int);
static int alter_rtcp(struct sip_msg *msg, str *body, str *oldport, str *newport);
static char *gencookie();
static int rtpp_test(struct rtpp_node*, int, int);
static int unforce_rtp_proxy0_f(struct sip_msg *, char *, char *);
static int unforce_rtp_proxy1_f(struct sip_msg *, char *, char *);
static int unforce_rtp_proxy_f(struct sip_msg *, char *, char *);
static int force_rtp_proxy(struct sip_msg *, char *, char *, int, int);
static int start_recording_f(struct sip_msg *, char *, char *);
static int rtpproxy_answer1_f(struct sip_msg *, char *, char *);
@ -350,16 +349,10 @@ static cmd_export_t cmds[] = {
{"set_rtp_proxy_set", (cmd_function)set_rtp_proxy_set_f, 1,
fixup_set_id, 0,
ANY_ROUTE},
{"unforce_rtp_proxy", (cmd_function)unforce_rtp_proxy0_f, 0,
{"unforce_rtp_proxy", (cmd_function)unforce_rtp_proxy_f, 0,
0, 0,
ANY_ROUTE},
{"unforce_rtp_proxy", (cmd_function)unforce_rtp_proxy1_f, 1,
0, 0,
ANY_ROUTE},
{"rtpproxy_destroy", (cmd_function)unforce_rtp_proxy0_f, 0,
0, 0,
ANY_ROUTE},
{"rtpproxy_destroy", (cmd_function)unforce_rtp_proxy1_f, 1,
{"rtpproxy_destroy", (cmd_function)unforce_rtp_proxy_f, 0,
0, 0,
ANY_ROUTE},
{"start_recording", (cmd_function)start_recording_f, 0,
@ -1645,14 +1638,7 @@ found:
}
static int
unforce_rtp_proxy0_f(struct sip_msg* msg, char* str1, char* str2)
{
char arg[1] = {'\0'};
return unforce_rtp_proxy1_f(msg, arg, str2);
}
static int
unforce_rtp_proxy1_f(struct sip_msg* msg, char* str1, char* str2)
unforce_rtp_proxy_f(struct sip_msg* msg, char* str1, char* str2)
{
str callid, from_tag, to_tag, viabranch;
char *cp;
@ -1754,7 +1740,7 @@ rtpproxy_manage(struct sip_msg *msg, char *flags, char *ip)
return -1;
if(method==METHOD_CANCEL || method==METHOD_BYE)
return unforce_rtp_proxy0_f(msg, 0, 0);
return unforce_rtp_proxy_f(msg, 0, 0);
if(ip==NULL)
{
@ -1780,13 +1766,13 @@ rtpproxy_manage(struct sip_msg *msg, char *flags, char *ip)
&& tmb.t_gett()!=T_UNDEFINED)
tmb.t_gett()->uas.request->msg_flags |= FL_SDP_BODY;
if(route_type==FAILURE_ROUTE)
return unforce_rtp_proxy0_f(msg, 0, 0);
return unforce_rtp_proxy_f(msg, 0, 0);
return force_rtp_proxy(msg, flags, (cp!=NULL)?newip:ip, 1,
(ip!=NULL)?1:0);
}
} else if(msg->first_line.type == SIP_REPLY) {
if(msg->first_line.u.reply.statuscode>=300)
return unforce_rtp_proxy0_f(msg, 0, 0);
return unforce_rtp_proxy_f(msg, 0, 0);
if(nosdp==0) {
if(method==METHOD_UPDATE)
return force_rtp_proxy(msg, flags, (cp!=NULL)?newip:ip, 0,

@ -0,0 +1,374 @@
diff --git a/Makefile.am b/Makefile.am
index 258de5e..a61bc57 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,7 @@ rtpproxy_SOURCES=main.c rtp.h rtp_server.c rtp_server.h \
rtpp_command.c rtpp_command.h rtpp_log.c rtpp_network.h rtpp_network.c \
rtpp_syslog_async.c rtpp_syslog_async.h rtpp_notify.c rtpp_notify.h \
rtpp_command_async.h rtpp_command_async.c
-rtpproxy_LDADD=-lm -lpthread
+rtpproxy_LDADD=-lm -lpthread @LIBS_XMLRPC@
dist_man_MANS=rtpproxy.8
makeann_SOURCES=makeann.c rtp.h g711.h
makeann_LDADD=@LIBS_G729@ @LIBS_GSM@
diff --git a/Makefile.in b/Makefile.in
index 47c14fd..cdb5e43 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -217,7 +217,7 @@ rtpproxy_SOURCES = main.c rtp.h rtp_server.c rtp_server.h \
rtpp_syslog_async.c rtpp_syslog_async.h rtpp_notify.c rtpp_notify.h \
rtpp_command_async.h rtpp_command_async.c
-rtpproxy_LDADD = -lm -lpthread
+rtpproxy_LDADD = -lm -lpthread @LIBS_XMLRPC@
dist_man_MANS = rtpproxy.8
makeann_SOURCES = makeann.c rtp.h g711.h
makeann_LDADD = @LIBS_G729@ @LIBS_GSM@
diff --git a/aclocal.m4 b/aclocal.m4
index b36bc80..0970c41 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -13,8 +13,8 @@
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],,
-[m4_warning([this file was generated for autoconf 2.68.
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],,
+[m4_warning([this file was generated for autoconf 2.67.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])
diff --git a/config.h.in b/config.h.in
index cd0c23a..87491e3 100644
--- a/config.h.in
+++ b/config.h.in
@@ -14,6 +14,9 @@
/* Define if you have libgsm library installed */
#undef ENABLE_GSM
+/* Define if you have xmlrpc library installed */
+#undef ENABLE_XMLRPC
+
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
diff --git a/configure.ac b/configure.ac
index 54c1a60..1c88b99 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,6 +53,17 @@ then
AC_DEFINE([ENABLE_G729], 1, [Define if you have libg729 library installed])
)
fi
+
+# XML-RPC-Libs:
+AC_CHECK_HEADERS(xmlrpc_client.h xmlrpc.h, found_xmlrpc=yes)
+if test "$found_xmlrpc" = yes
+then
+ AC_CHECK_LIB(curl, curl_version,
+ LIBS_XMLRPC="-lcurl -lxmlrpc_client -lxmlrpc -lxmlrpc_util -lxmlrpc_xmlparse -lxmlrpc_xmltok"
+ AC_DEFINE([ENABLE_XMLRPC], 1, [Define if you have XML-RPC-Client library installed])
+ )
+fi
+
##if test -z "$G729_SUPPORT"
##then
## echo "*************************************************************************** $ECHO_C" 1>&6
@@ -94,4 +105,5 @@ AC_CONFIG_FILES([Makefile])
AC_SUBST(AM_CFLAGS)
AC_SUBST(LIBS_GSM)
AC_SUBST(LIBS_G729)
+AC_SUBST(LIBS_XMLRPC)
AC_OUTPUT
diff --git a/rtpp_command.c b/rtpp_command.c
index c5734ae..d6072de 100644
--- a/rtpp_command.c
+++ b/rtpp_command.c
@@ -69,6 +69,9 @@ struct proto_cap proto_caps[] = {
{ "20081102", "Support for setting codecs in the update/lookup command" },
{ "20081224", "Support for session timeout notifications" },
{ "20090810", "Support for automatic bridging" },
+#ifdef ENABLE_XMLRPC
+ { "20100819", "Support for timeout notifications using XML-RPC towards Kamailio/sip-router.org" },
+#endif
{ NULL, NULL }
};
@@ -269,6 +272,7 @@ handle_command(struct cfg *cf, int controlfd, double dtime)
char *socket_name_u, *notify_tag;
struct sockaddr *local_addr;
char c;
+ struct rtpp_timeout_handler * my_timeout_h;
requested_nsamples = -1;
ia[0] = ia[1] = NULL;
@@ -468,7 +472,7 @@ handle_command(struct cfg *cf, int controlfd, double dtime)
}
call_id = argv[1];
if (op == UPDATE || op == LOOKUP || op == PLAY) {
- max_argc = (op == UPDATE ? 8 : 6);
+ max_argc = (op == PLAY ? 6 : 8);
if (argc < 5 || argc > max_argc) {
rtpp_log_write(RTPP_LOG_ERR, cf->stable.glog, "command syntax error");
reply_error(&cf->stable, controlfd, &raddr, rlen, cookie, 4);
@@ -478,7 +482,7 @@ handle_command(struct cfg *cf, int controlfd, double dtime)
to_tag = argv[5];
if (op == PLAY && argv[0][1] != '\0')
playcount = atoi(argv[0] + 1);
- if (op == UPDATE && argc > 6) {
+ if (op != PLAY && argc > 6) {
socket_name_u = argv[6];
if (strncmp("unix:", socket_name_u, 5) == 0)
socket_name_u += 5;
@@ -965,25 +969,39 @@ handle_command(struct cfg *cf, int controlfd, double dtime)
}
pthread_mutex_lock(&cf->glock);
- if (op == UPDATE) {
- if (cf->timeout_handler->socket_name == NULL && socket_name_u != NULL)
- rtpp_log_write(RTPP_LOG_ERR, spa->log, "must permit notification socket with -n");
+
+ if ((op == UPDATE) || (op == LOOKUP)){
if (spa->timeout_data.notify_tag != NULL) {
free(spa->timeout_data.notify_tag);
spa->timeout_data.notify_tag = NULL;
}
- if (cf->timeout_handler->socket_name != NULL && socket_name_u != NULL) {
- if (strcmp(cf->timeout_handler->socket_name, socket_name_u) != 0) {
- rtpp_log_write(RTPP_LOG_ERR, spa->log, "invalid socket name %s", socket_name_u);
- socket_name_u = NULL;
- } else {
+ spa->timeout_data.handler = NULL;
+ if (socket_name_u != NULL) {
+ if (cf->timeout_handler != NULL && cf->timeout_handler->socket_name != NULL
+ && strlen(cf->timeout_handler->socket_name) == strlen(socket_name_u)
+ && strcmp(cf->timeout_handler->socket_name, socket_name_u) != 0) {
rtpp_log_write(RTPP_LOG_INFO, spa->log, "setting timeout handler");
spa->timeout_data.handler = cf->timeout_handler;
spa->timeout_data.notify_tag = strdup(notify_tag);
+ } else {
+ rtpp_log_write(RTPP_LOG_INFO, spa->log, "setting custom timeout handler (%s)", socket_name_u);
+ my_timeout_h = malloc(sizeof(struct rtpp_timeout_handler));
+ if (my_timeout_h == NULL) {
+ rtpp_log_write(RTPP_LOG_ERR, spa->log, "Unable to allocate memory");
+ } else {
+ memset(my_timeout_h, 0, sizeof(struct rtpp_timeout_handler));
+ my_timeout_h->socket_name = (char *)malloc(strlen(socket_name_u) + 1);
+ if(my_timeout_h->socket_name != NULL) {
+ strcpy(my_timeout_h->socket_name, socket_name_u);
+ spa->timeout_data.handler = my_timeout_h;
+ if (notify_tag != NULL) spa->timeout_data.notify_tag = strdup(notify_tag);
+ else spa->timeout_data.notify_tag = NULL;
+ } else {
+ rtpp_log_write(RTPP_LOG_ERR, spa->log, "Unable to allocate memory");
+ free(my_timeout_h);
+ }
+ }
}
- } else if (socket_name_u == NULL && spa->timeout_data.handler != NULL) {
- spa->timeout_data.handler = NULL;
- rtpp_log_write(RTPP_LOG_INFO, spa->log, "disabling timeout handler");
}
}
diff --git a/rtpp_notify.c b/rtpp_notify.c
index e92c9ec..e6b30e4 100644
--- a/rtpp_notify.c
+++ b/rtpp_notify.c
@@ -42,10 +42,24 @@
#include "rtpp_session.h"
#include "rtpp_util.h"
+#ifdef ENABLE_XMLRPC
+#include <xmlrpc.h>
+#include <xmlrpc_client.h>
+#define XMLRPC_CLIENT_NAME "XML-RPC RTPProxy Client"
+#define XMLRPC_CLIENT_VERSION "0.2"
+#endif
+
struct rtpp_notify_wi
{
char *notify_buf;
int len;
+#ifdef ENABLE_XMLRPC
+ char *call_id;
+ int call_id_len;
+ char *param;
+ int param_len;
+ int custom_handler;
+#endif
struct rtpp_timeout_handler *th;
rtpp_log_t glog;
struct rtpp_notify_wi *next;
@@ -258,6 +272,13 @@ rtpp_notify_schedule(struct cfg *cf, struct rtpp_session *sp)
if (wi == NULL)
return -1;
+#ifdef ENABLE_XMLRPC
+ if (th != cf->timeout_handler)
+ wi->custom_handler = 1;
+ else
+ wi->custom_handler = 0;
+#endif
+
wi->th = th;
if (sp->timeout_data.notify_tag == NULL) {
/* two 5-digit numbers, space, \0 and \n */
@@ -289,6 +310,59 @@ rtpp_notify_schedule(struct cfg *cf, struct rtpp_session *sp)
len = snprintf(wi->notify_buf, len, "%s\n",
sp->timeout_data.notify_tag);
}
+#ifdef ENABLE_XMLRPC
+
+ // rtpp_log_write(RTPP_LOG_ERR, wi->glog, "Timeout socket is: %s (%p)\n", wi->th->socket_name, wi->th->socket_name);
+
+ if (strncmp("xmlrpc:", wi->th->socket_name, 7) == 0) {
+ // Copy the Socket-Name
+ len = strlen(wi->th->socket_name)+1;
+ if (wi->param == NULL) {
+ wi->param = malloc(len);
+ if (wi->param == NULL) {
+ rtpp_notify_queue_return_free_item(wi);
+ return -1;
+ }
+ } else {
+ notify_buf = realloc(wi->param, len);
+ if (notify_buf == NULL) {
+ rtpp_notify_queue_return_free_item(wi);
+ return -1;
+ }
+ wi->param = notify_buf;
+ }
+ memset(wi->param, '\0', len);
+ len = snprintf(wi->param, len, "%s",
+ wi->th->socket_name);
+ wi->param_len = len;
+
+ // rtpp_log_write(RTPP_LOG_ERR, wi->glog, "wi->param %s (%p)\n", wi->param, wi->param);
+
+ // Copy the Call-ID:
+ len = strlen(sp->call_id)+1;
+ if (wi->call_id == NULL) {
+ wi->call_id = malloc(len);
+ if (wi->call_id == NULL) {
+ rtpp_notify_queue_return_free_item(wi);
+ return -1;
+ }
+ } else {
+ notify_buf = realloc(wi->call_id, len);
+ if (notify_buf == NULL) {
+ rtpp_notify_queue_return_free_item(wi);
+ return -1;
+ }
+ wi->call_id = notify_buf;
+ }
+ memset(wi->call_id, '\0', len);
+ len = snprintf(wi->call_id, len, "%s",
+ sp->call_id);
+ wi->call_id_len = len;
+
+ // rtpp_log_write(RTPP_LOG_ERR, wi->glog, "wi->call_id %s (%p)\n", wi->call_id, wi->call_id);
+
+ }
+#endif
wi->glog = cf->stable.glog;
@@ -345,29 +419,72 @@ reconnect_timeout_handler(rtpp_log_t log, struct rtpp_timeout_handler *th)
}
}
+#ifdef ENABLE_XMLRPC
+static int
+do_xmlrpc_timeout_notification(rtpp_log_t log, struct rtpp_notify_wi *wi) {
+ xmlrpc_env env;
+ xmlrpc_value *result;
+
+ /* Start up our XML-RPC client library. */
+ xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, XMLRPC_CLIENT_NAME, XMLRPC_CLIENT_VERSION);
+ xmlrpc_env_init(&env);
+
+ /* Get the dialog-Info: */
+ result = xmlrpc_client_call(&env, wi->param+7,
+ "dlg_terminate_dlg", "(s)",
+ wi->call_id);
+ if (env.fault_occurred) {
+ rtpp_log_write(RTPP_LOG_ERR, wi->glog, "%s: XML-RPC Fault: %s (%d)\n", wi->call_id, env.fault_string, env.fault_code);
+ return -1;
+ }
+
+ /* Dispose of our result value. */
+ xmlrpc_DECREF(result);
+
+ /* Shutdown our XML-RPC client library. */
+ xmlrpc_env_clean(&env);
+ xmlrpc_client_cleanup();
+
+ return 0;
+}
+#endif
+
static void
do_timeout_notification(struct rtpp_notify_wi *wi, int retries)
{
int result;
- if (wi->th->connected == 0) {
- reconnect_timeout_handler(wi->glog, wi->th);
-
- /* If connect fails, no notification will be sent */
- if (wi->th->connected == 0) {
- rtpp_log_write(RTPP_LOG_ERR, wi->glog, "unable to send timeout notification");
- return;
- }
+ if (strncmp("xmlrpc:", wi->th->socket_name, 7) == 0) {
+ result = do_xmlrpc_timeout_notification(wi->glog, wi);
+ } else {
+ if (wi->th->connected == 0) {
+ reconnect_timeout_handler(wi->glog, wi->th);
+
+ /* If connect fails, no notification will be sent */
+ if (wi->th->connected == 0) {
+ rtpp_log_write(RTPP_LOG_ERR, wi->glog, "unable to send timeout notification");
+ return;
+ }
+ }
+
+ do {
+ result = send(wi->th->fd, wi->notify_buf, wi->len - 1, 0);
+ } while (result == -1 && errno == EINTR);
}
- do {
- result = send(wi->th->fd, wi->notify_buf, wi->len - 1, 0);
- } while (result == -1 && errno == EINTR);
-
if (result < 0) {
wi->th->connected = 0;
rtpp_log_ewrite(RTPP_LOG_ERR, wi->glog, "failed to send timeout notification");
if (retries > 0)
do_timeout_notification(wi, retries - 1);
}
+#ifdef ENABLE_XMLRPC
+ // In case we use a custom timeout handler, we have to free it.
+ if (wi->th && (wi->custom_handler == 1)) {
+ free(wi->th->socket_name);
+ free(wi->th);
+ wi->th = 0;
+ }
+#endif
+
}
diff --git a/rtpp_session.c b/rtpp_session.c
index 03e3d8a..51b3319 100644
--- a/rtpp_session.c
+++ b/rtpp_session.c
@@ -41,6 +41,7 @@
#include "rtpp_record.h"
#include "rtpp_session.h"
#include "rtpp_util.h"
+#include "rtpp_notify.h"
void
init_hash_table(struct cfg_stable *cf)

@ -209,7 +209,7 @@ static int w_sl_send_reply(struct sip_msg* msg, char* p1, char* p2)
}
if (get_str_fparam(&reason, msg, (fparam_t*)p2) < 0) {
reason = default_reason;;
reason = default_reason;
}
if(reason.s[reason.len-1]=='\0') {
@ -219,7 +219,7 @@ static int w_sl_send_reply(struct sip_msg* msg, char* p1, char* p2)
if (r == NULL) r = default_reason.s;
}
ret = sl_send_reply(msg, code, r);
if (r!=reason.s) pkg_free(r);
if ((r!=reason.s) && (r!=default_reason.s)) pkg_free(r);
return ret;
}

@ -183,7 +183,7 @@ int sl_reply_helper(struct sip_msg *msg, int code, char *reason, str *tag)
}
if (!buf.s)
{
DBG("DEBUG: sl_send_reply: response building failed\n");
DBG("DEBUG: sl_reply_helper: response building failed\n");
goto error;
}

@ -130,6 +130,10 @@ void tls_destroy_locks()
}
unsigned long sr_ssl_id_f()
{
return my_pid();
}
/* returns -1 on error, 0 on success */
int tls_init_locks()
@ -163,10 +167,13 @@ int tls_init_locks()
CRYPTO_set_dynlock_lock_callback(dyn_lock_f);
CRYPTO_set_dynlock_destroy_callback(dyn_destroy_f);
/* thread id callback: not needed because ser doesn't use thread and
* openssl already uses getpid() (by default)
* CRYPTO_set_id_callback(id_f);
/* starting with v1.0.0 openssl does not use anymore getpid(), but address
* of errno which can point to same virtual address in a multi-process
* application
* - for refrence http://www.openssl.org/docs/crypto/threads.html
*/
CRYPTO_set_id_callback(sr_ssl_id_f);
/* atomic add -- since for now we don't have atomic_add
* (only atomic_inc), fallback to the default use-locks mode
* CRYPTO_set_add_lock_callback(atomic_add_f);

@ -125,14 +125,6 @@ int core2strar(struct sip_msg *req, str *c_vals, int *i_vals, char *t_vals)
struct hdr_field *from;
struct hdr_field *to;
struct timeval tv;
struct timezone tz;
struct tm *tm;
uint64_t time_hires;
gettimeofday(&tv, &tz);
tm = localtime(&tv.tv_sec);
/* method : request/reply - cseq parsed in acc_preparse_req() */
c_vals[0] = get_cseq(req)->method;
t_vals[0] = TYPE_STR;
@ -182,10 +174,6 @@ int core2strar(struct sip_msg *req, str *c_vals, int *i_vals, char *t_vals)
t_vals[5] = TYPE_STR;
acc_env.ts = time(NULL);
time_hires = (tv.tv_sec * 1000) + tv.tv_usec / 1000;
acc_env.time_hires = time_hires;
return ACC_CORE_LEN;
}
@ -318,8 +306,7 @@ static void acc_db_init_keys(void)
db_keys[n++] = &acc_sipcode_col;
db_keys[n++] = &acc_sipreason_col;
db_keys[n++] = &acc_time_col;
db_keys[n++] = &acc_time_hires_col;
time_idx = n-2;
time_idx = n-1;
/* init the extra db keys */
for(extra=db_extra; extra ; extra=extra->next)
@ -335,7 +322,6 @@ static void acc_db_init_keys(void)
VAL_NULL(db_vals+i)=0;
}
VAL_TYPE(db_vals+time_idx)=DB1_DATETIME;
VAL_TYPE(db_vals+time_idx+1)=DB1_DOUBLE;
}
@ -394,8 +380,7 @@ int acc_db_request( struct sip_msg *rq)
VAL_STR(db_vals+i) = val_arr[i];
/* time value */
VAL_TIME(db_vals+(m++)) = acc_env.ts;
VAL_DOUBLE(db_vals+(m++)) = ((double) acc_env.time_hires) / 1000;
i = m;
/* extra columns */
m += extra2strar( db_extra, rq, val_arr+m, int_arr+m, type_arr+m);

@ -57,7 +57,6 @@ typedef struct acc_enviroment {
struct hdr_field *to;
str text;
time_t ts;
uint64_t time_hires;
} acc_enviroment_t;
/* acc extra parameter */

@ -193,7 +193,6 @@ str acc_callid_col = str_init("callid");
str acc_sipcode_col = str_init("sip_code");
str acc_sipreason_col = str_init("sip_reason");
str acc_time_col = str_init("time");
str acc_time_hires_col = str_init("time_hires");
int acc_db_insert_mode = 0;
#endif
@ -288,7 +287,6 @@ static param_export_t params[] = {
{"acc_sip_code_column", STR_PARAM, &acc_sipcode_col.s },
{"acc_sip_reason_column",STR_PARAM, &acc_sipreason_col.s },
{"acc_time_column", STR_PARAM, &acc_time_col.s },
{"acc_time_hires_column", STR_PARAM, &acc_time_hires_col.s },
{"db_insert_mode", INT_PARAM, &acc_db_insert_mode },
#endif
{0,0,0}
@ -431,7 +429,6 @@ static int mod_init( void )
acc_sipcode_col.len = strlen(acc_sipcode_col.s);
acc_sipreason_col.len = strlen(acc_sipreason_col.s);
acc_time_col.len = strlen(acc_time_col.s);
acc_time_hires_col.len = strlen(acc_time_hires_col.s);
#endif
if (log_facility_str) {

@ -90,7 +90,6 @@ extern str acc_cseqno_col;
extern str acc_sipcode_col;
extern str acc_sipreason_col;
extern str acc_time_col;
extern str acc_time_hires_col;
#endif /* SQL_ACC */

@ -678,6 +678,11 @@ int init_ds_db(void)
}
ret = ds_load_db();
if (ret == -2)
{
LM_WARN("failure while loading one or more dispatcher entries\n");
ret = 0;
}
ds_disconnect_db();
@ -691,6 +696,7 @@ int ds_load_db(void)
int flags;
int priority;
int nrcols;
int dest_errs = 0;
str uri;
str attrs = {0, 0};
db1_res_t * res;
@ -764,17 +770,20 @@ int ds_load_db(void)
}
if(add_dest2list(id, uri, flags, priority, &attrs,
*next_idx, &setn) != 0)
{
dest_errs++;
LM_WARN("unable to add destination %.*s to set %d -- skipping\n",
uri.len, uri.s, id);
}
}
ds_dbf.free_result(ds_db_handle, res);
if(reindex_dests(*next_idx, setn)!=0)
{
LM_ERR("error on reindex\n");
goto err2;
}
ds_dbf.free_result(ds_db_handle, res);
/* update data - should it be sync'ed? */
_ds_list_nr = setn;
*crt_idx = *next_idx;
@ -782,6 +791,8 @@ int ds_load_db(void)
ds_print_sets();
if (dest_errs > 0)
return -2;
return 0;
err2:
@ -2326,9 +2337,9 @@ static void ds_options_callback( struct cell *t, int type,
sip_msg_t *fmsg;
int state;
/* The Param does contain the group, in which the failed host
/* The param contains the group, in which the failed host
* can be found.*/
if (!*ps->param)
if (ps->param==NULL)
{
LM_DBG("No parameter provided, OPTIONS-Request was finished"
" with code %d\n", ps->code);

@ -36,10 +36,9 @@
#define DLIST_H
#include <stdio.h>
#include "udomain.h"
#include "../../str.h"
#include "../usrloc/usrloc.h"
#include "udomain.h"
/*!
* List of all domains registered with usrloc

@ -74,6 +74,7 @@
MODULE_VERSION
#define RUID_COL "ruid"
#define USER_COL "username"
#define DOMAIN_COL "domain"
#define CONTACT_COL "contact"
@ -88,6 +89,8 @@ MODULE_VERSION
#define PATH_COL "path"
#define SOCK_COL "socket"
#define METHODS_COL "methods"
#define INSTANCE_COL "instance"
#define REG_ID_COL "reg_id"
#define LAST_MOD_COL "last_modified"
static int mod_init(void); /*!< Module initialization function */
@ -135,6 +138,7 @@ extern int ul_locks_no;
* @param alg_location defines the algorithm for the location matching - based on crc32 for now
*/
str ruid_col = str_init(RUID_COL); /*!< Name of column containing record unique id */
str user_col = str_init(USER_COL); /*!< Name of column containing usernames */
str domain_col = str_init(DOMAIN_COL); /*!< Name of column containing domains */
str contact_col = str_init(CONTACT_COL); /*!< Name of column containing contact addresses */
@ -149,6 +153,8 @@ str received_col = str_init(RECEIVED_COL); /*!< Name of column containing tr
str path_col = str_init(PATH_COL); /*!< Name of column containing the Path header */
str sock_col = str_init(SOCK_COL); /*!< Name of column containing the received socket */
str methods_col = str_init(METHODS_COL); /*!< Name of column containing the supported methods */
str instance_col = str_init(INSTANCE_COL); /*!< Name of column containing the SIP instance value */
str reg_id_col = str_init(REG_ID_COL); /*!< Name of column containing the reg-id value */
str last_mod_col = str_init(LAST_MOD_COL); /*!< Name of column containing the last modified date */
int db_mode = 3; /*!< Database sync scheme: 1-write through, 2-write back, 3-only db */
int use_domain = 0; /*!< Whether usrloc should use domain part of aor */
@ -207,6 +213,7 @@ static cmd_export_t cmds[] = {
* Exported parameters
*/
static param_export_t params[] = {
{"ruid_column", STR_PARAM, &ruid_col.s },
{"user_column", STR_PARAM, &user_col.s },
{"domain_column", STR_PARAM, &domain_col.s },
{"contact_column", STR_PARAM, &contact_col.s },
@ -232,6 +239,8 @@ static param_export_t params[] = {
{"default_db_url", STR_PARAM, &default_db_url.s },
{"default_db_type", STR_PARAM, &default_db_type.s },
{"domain_db", STR_PARAM, &domain_db.s },
{"instance_column", STR_PARAM, &instance_col.s },
{"reg_id_column", STR_PARAM, &reg_id_col.s },
{"write_db_url", STR_PARAM, &write_db_url.s },
{"read_db_url", STR_PARAM, &read_db_url.s },
{"reg_db_table", STR_PARAM, &reg_table.s },
@ -319,6 +328,7 @@ static int mod_init(void)
/* Compute the lengths of string parameters */
ruid_col.len = strlen(ruid_col.s);
user_col.len = strlen(user_col.s);
domain_col.len = strlen(domain_col.s);
contact_col.len = strlen(contact_col.s);
@ -333,6 +343,8 @@ static int mod_init(void)
path_col.len = strlen(path_col.s);
sock_col.len = strlen(sock_col.s);
methods_col.len = strlen(methods_col.s);
instance_col.len = strlen(instance_col.s);
reg_id_col.len = strlen(reg_id_col.s);
last_mod_col.len = strlen(last_mod_col.s);
write_db_url.len = strlen (write_db_url.s);

@ -71,6 +71,7 @@
#define DEFAULT_DB_TYPE "single"
#define DEFAULT_DOMAIN_DB "location=cluster,cfa=single"
extern str ruid_col;
extern str user_col;
extern str domain_col;
extern str contact_col;
@ -85,6 +86,8 @@ extern str received_col;
extern str path_col;
extern str sock_col;
extern str methods_col;
extern str instance_col;
extern str reg_id_col;
extern str last_mod_col;
extern int db_mode;

@ -77,6 +77,12 @@ ucontact_t* new_ucontact(str* _dom, str* _aor, str* _contact, ucontact_info_t* _
if (_ci->path && _ci->path->len) {
if (shm_str_dup( &c->path, _ci->path) < 0) goto error;
}
if (_ci->ruid.s && _ci->ruid.len) {
if (shm_str_dup( &c->ruid, &_ci->ruid) < 0) goto error;
}
if (_ci->instance.s && _ci->instance.len) {
if (shm_str_dup( &c->instance, &_ci->instance) < 0) goto error;
}
c->domain = _dom;
c->aor = _aor;
@ -88,6 +94,7 @@ ucontact_t* new_ucontact(str* _dom, str* _aor, str* _contact, ucontact_info_t* _
c->flags = _ci->flags;
c->cflags = _ci->cflags;
c->methods = _ci->methods;
c->reg_id = _ci->reg_id;
c->last_modified = _ci->last_modified;
return c;
@ -116,6 +123,8 @@ void free_ucontact(ucontact_t* _c)
if (_c->user_agent.s) shm_free(_c->user_agent.s);
if (_c->callid.s) shm_free(_c->callid.s);
if (_c->c.s) shm_free(_c->c.s);
if (_c->ruid.s) shm_free(_c->ruid.s);
if (_c->instance.s) shm_free(_c->instance.s);
shm_free( _c );
}
@ -169,6 +178,11 @@ void print_ucontact(FILE* _f, ucontact_t* _c)
fprintf(_f, "Sock : none (null)\n");
}
fprintf(_f, "Methods : %u\n", _c->methods);
fprintf(_f, "ruid : '%.*s'\n",
_c->ruid.len, ZSW(_c->ruid.s));
fprintf(_f, "instance : '%.*s'\n",
_c->instance.len, ZSW(_c->instance.s));
fprintf(_f, "reg-id : %u\n", _c->reg_id);
fprintf(_f, "next : %p\n", _c->next);
fprintf(_f, "prev : %p\n", _c->prev);
fprintf(_f, "~~~/Contact~~~~\n");
@ -385,12 +399,14 @@ int st_flush_ucontact(ucontact_t* _c)
* \param _c inserted contact
* \return 0 on success, -1 on failure
*/
int db_insert_ucontact(ucontact_t* _c)
{
char* dom;
db_key_t keys[15];
db_val_t vals[15];
int nr_cols = 0;
db_key_t keys[18];
db_val_t vals[18];
int nr_cols = 0;
int nr_cols_key = 0;
struct udomain * _d;
str user={0, 0};
@ -433,11 +449,10 @@ int db_insert_ucontact(ucontact_t* _c)
vals[nr_cols].val.str_val.len = _c->aor->s + _c->aor->len - dom - 1;
}
domain = vals[nr_cols].val.str_val;
LM_DBG("** Username=%.*s Domain=%.*s\n", vals[0].val.str_val.len, vals[0].val.str_val.s,
LM_INFO("** Username=%.*s Domain=%.*s\n", vals[0].val.str_val.len, vals[0].val.str_val.s,
vals[nr_cols].val.str_val.len, vals[nr_cols].val.str_val.s);
nr_cols++;
}
nr_cols_key = nr_cols;
user = vals[0].val.str_val;
keys[nr_cols] = &expires_col;
@ -526,9 +541,39 @@ int db_insert_ucontact(ucontact_t* _c)
vals[nr_cols].type = DB1_DATETIME;
vals[nr_cols].nul = 0;
vals[nr_cols].val.time_val = _c->last_modified;
nr_cols++;
keys[nr_cols] = &ruid_col;
if(_c->ruid.len>0)
{
vals[nr_cols].type = DB1_STR;
vals[nr_cols].nul = 0;
vals[nr_cols].val.str_val = _c->ruid;
} else {
vals[nr_cols].nul = 1;
}
nr_cols++;
keys[nr_cols] = &instance_col;
if(_c->instance.len>0)
{
vals[nr_cols].type = DB1_STR;
vals[nr_cols].nul = 0;
vals[nr_cols].val.str_val = _c->instance;
} else {
vals[nr_cols].nul = 1;
}
nr_cols++;
keys[nr_cols] = &reg_id_col;
vals[nr_cols].type = DB1_INT;
vals[nr_cols].nul = 0;
vals[nr_cols].val.int_val = (int)_c->reg_id;
nr_cols++;
nr_cols_key = nr_cols;
/* to prevent errors from the DB because of duplicated entries */
if (ul_db_layer_replace(_d, &user, &domain, keys, vals, nr_cols, nr_cols_key) <0) {
LM_ERR("inserting contact in db failed\n");
return -1;
@ -549,8 +594,8 @@ int db_update_ucontact(ucontact_t* _c)
db_key_t keys1[4];
db_val_t vals1[4];
db_key_t keys2[11];
db_val_t vals2[11];
db_key_t keys2[14];
db_val_t vals2[14];
if (_c->flags & FL_MEM) {
return 0;
@ -575,6 +620,9 @@ int db_update_ucontact(ucontact_t* _c)
keys2[8] = &sock_col;
keys2[9] = &methods_col;
keys2[10] = &last_mod_col;
keys2[11] = &ruid_col;
keys2[12] = &instance_col;
keys2[13] = &reg_id_col;
vals1[0].type = DB1_STR;
vals1[0].nul = 0;
@ -648,6 +696,28 @@ int db_update_ucontact(ucontact_t* _c)
vals2[10].nul = 0;
vals2[10].val.time_val = _c->last_modified;
if(_c->ruid.len>0)
{
vals2[11].type = DB1_STR;
vals2[11].nul = 0;
vals2[11].val.str_val = _c->ruid;
} else {
vals2[11].nul = 1;
}
if(_c->instance.len>0)
{
vals2[12].type = DB1_STR;
vals2[12].nul = 0;
vals2[12].val.str_val = _c->instance;
} else {
vals2[12].nul = 1;
}
vals2[13].type = DB1_INT;
vals2[13].nul = 0;
vals2[13].val.int_val = (int)_c->reg_id;
if (use_domain) {
vals1[3].type = DB1_STR;
vals1[3].nul = 0;
@ -663,7 +733,7 @@ int db_update_ucontact(ucontact_t* _c)
}
if (ul_db_layer_update(_d, &vals1[0].val.str_val, &vals1[3].val.str_val, keys1, 0, vals1, keys2, vals2,
(use_domain) ? (4) : (3), 11) < 0) {
(use_domain) ? (4) : (3), 14) < 0) {
LM_ERR("updating database failed\n");
return -1;
}

@ -178,6 +178,7 @@ static inline void get_static_urecord(udomain_t* _d, str* _aor,
memset( &r, 0, sizeof(struct urecord) );
r.aor = *_aor;
r.aorhash = ul_get_aorhash(_aor);
r.domain = _d->name;
*_r = &r;
}
@ -334,6 +335,23 @@ static inline ucontact_info_t* dbrow2info( db_val_t *vals, str *contact)
ci.last_modified = VAL_TIME(vals+12);
}
/* record internal uid */
if (!VAL_NULL(vals+13)) {
ci.ruid.s = (char*)VAL_STRING(vals+13);
ci.ruid.len = strlen(ci.ruid.s);
}
/* sip instance */
if (!VAL_NULL(vals+14)) {
ci.instance.s = (char*)VAL_STRING(vals+14);
ci.instance.len = strlen(ci.instance.s);
}
/* reg-id */
if (!VAL_NULL(vals+15)) {
ci.reg_id = VAL_UINT(vals+15);
}
return &ci;
}
@ -349,7 +367,7 @@ static inline ucontact_info_t* dbrow2info( db_val_t *vals, str *contact)
urecord_t* db_load_urecord(udomain_t* _d, str *_aor)
{
ucontact_info_t *ci;
db_key_t columns[13];
db_key_t columns[16];
db_key_t keys[2];
db_key_t order;
db_val_t vals[2];
@ -395,13 +413,16 @@ urecord_t* db_load_urecord(udomain_t* _d, str *_aor)
columns[10] = &sock_col;
columns[11] = &methods_col;
columns[12] = &last_mod_col;
columns[13] = &ruid_col;
columns[14] = &instance_col;
columns[15] = &reg_id_col;
if (desc_time_order)
order = &last_mod_col;
else
order = &q_col;
if (ul_db_layer_query(_d, &vals[0].val.str_val, &vals[1].val.str_val, keys, 0, vals, columns, (use_domain)?2:1, 13, order,
if (ul_db_layer_query(_d, &vals[0].val.str_val, &vals[1].val.str_val, keys, 0, vals, columns, (use_domain)?2:1, 16, order,
&res) < 0) {
LM_ERR("db_query failed\n");
return 0;
@ -443,6 +464,125 @@ urecord_t* db_load_urecord(udomain_t* _d, str *_aor)
return r;
}
/*!
* \brief Loads from DB all contacts for a RUID
* \param _c database connection
* \param _d domain
* \param _aor address of record
* \return pointer to the record on success, 0 on errors or if nothing is found
*/
urecord_t* db_load_urecord_by_ruid(udomain_t* _d, str *_ruid)
{
ucontact_info_t *ci;
db_key_t columns[18];
db_key_t keys[1];
db_key_t order;
db_val_t vals[1];
db1_res_t* res = NULL;
db_row_t *row;
str contact;
str aor;
char aorbuf[512];
str domain;
urecord_t* r;
ucontact_t* c;
keys[0] = &ruid_col;
vals[0].type = DB1_STR;
vals[0].nul = 0;
vals[0].val.str_val = *_ruid;
columns[0] = &contact_col;
columns[1] = &expires_col;
columns[2] = &q_col;
columns[3] = &callid_col;
columns[4] = &cseq_col;
columns[5] = &flags_col;
columns[6] = &cflags_col;
columns[7] = &user_agent_col;
columns[8] = &received_col;
columns[9] = &path_col;
columns[10] = &sock_col;
columns[11] = &methods_col;
columns[12] = &last_mod_col;
columns[13] = &ruid_col;
columns[14] = &instance_col;
columns[15] = &user_col;
columns[16] = &reg_id_col;
columns[17] = &domain_col;
if (desc_time_order)
order = &last_mod_col;
else
order = &q_col;
if (ul_db_layer_query(_d, &vals[0].val.str_val, &vals[1].val.str_val, keys, 0, vals, columns, 1, 18, order,
&res) < 0) {
LM_ERR("db_query failed\n");
return 0;
}
if (RES_ROW_N(res) == 0) {
LM_DBG("aor %.*s not found in table %.*s\n",_ruid->len, _ruid->s,
_d->name->len, _d->name->s);
ul_db_layer_free_result(_d, res);
return 0;
}
r = 0;
/* use first row - shouldn't be more */
row = RES_ROWS(res);
ci = dbrow2info(ROW_VALUES(RES_ROWS(res)), &contact);
if (ci==0) {
LM_ERR("skipping record for %.*s in table %s\n",
_ruid->len, _ruid->s, _d->name->s);
goto done;
}
aor.s = (char*)VAL_STRING(ROW_VALUES(row) + 15);
aor.len = strlen(aor.s);
if (use_domain) {
domain.s = (char*)VAL_STRING(ROW_VALUES(row) + 17);
if (VAL_NULL(ROW_VALUES(row)+17) || domain.s==0 || domain.s[0]==0){
LM_CRIT("empty domain record for user %.*s...skipping\n",
aor.len, aor.s);
goto done;
}
domain.len = strlen(domain.s);
if(aor.len + domain.len + 2 >= 512) {
LM_ERR("AoR is too big\n");
goto done;
}
memcpy(aorbuf, aor.s, aor.len);
aorbuf[aor.len] = '@';
memcpy(aorbuf + aor.len + 1, domain.s, domain.len);
aor.len += 1 + domain.len;
aor.s = aorbuf;
aor.s[aor.len] = '\0';
}
get_static_urecord( _d, &aor, &r);
if ( (c=mem_insert_ucontact(r, &contact, ci)) == 0) {
LM_ERR("mem_insert failed\n");
free_urecord(r);
ul_db_layer_free_result(_d, res);
return 0;
}
/* We have to do this, because insert_ucontact sets state to CS_NEW
* and we have the contact in the database already */
c->state = CS_SYNC;
done:
ul_db_layer_free_result(_d, res);
;
return r;
}
/*!
* \brief Timer function to cleanup expired contacts, DB_ONLY db_mode
@ -551,8 +691,7 @@ void lock_udomain(udomain_t* _d, str* _aor)
unsigned int sl;
if (db_mode!=DB_ONLY)
{
sl = core_hash(_aor, 0, _d->size);
sl = ul_get_aorhash(_aor) & (_d->size - 1);
#ifdef GEN_LOCK_T_PREFERED
lock_get(_d->table[sl].lock);
#else
@ -572,7 +711,7 @@ void unlock_udomain(udomain_t* _d, str* _aor)
unsigned int sl;
if (db_mode!=DB_ONLY)
{
sl = core_hash(_aor, 0, _d->size);
sl = ul_get_aorhash(_aor) & (_d->size - 1);
#ifdef GEN_LOCK_T_PREFERED
lock_release(_d->table[sl].lock);
#else
@ -648,11 +787,11 @@ int get_urecord(udomain_t* _d, str* _aor, struct urecord** _r)
urecord_t* r;
if (db_mode!=DB_ONLY) {
/* search in cache */
aorhash = core_hash(_aor, 0, 0);
aorhash = ul_get_aorhash(_aor);
sl = aorhash&(_d->size-1);
r = _d->table[sl].first;
for(i = 0; i < _d->table[sl].n; i++) {
for(i = 0; r!=NULL && i < _d->table[sl].n; i++) {
if((r->aorhash==aorhash) && (r->aor.len==_aor->len)
&& !memcmp(r->aor.s,_aor->s,_aor->len)){
*_r = r;
@ -673,6 +812,65 @@ int get_urecord(udomain_t* _d, str* _aor, struct urecord** _r)
return 1; /* Nothing found */
}
/*!
* \brief Obtain a urecord pointer if the urecord exists in domain (lock slot)
* \param _d domain to search the record
* \param _aorhash hash id for address of record
* \param _ruid record internal unique id
* \param _r store pointer to location record
* \param _c store pointer to contact structure
* \return 0 if a record was found, 1 if nothing could be found
*/
int get_urecord_by_ruid(udomain_t* _d, unsigned int _aorhash,
str *_ruid, struct urecord** _r, struct ucontact** _c)
{
unsigned int sl, i;
urecord_t* r;
ucontact_t* c;
sl = _aorhash&(_d->size-1);
lock_ulslot(_d, sl);
if (db_mode!=DB_ONLY) {
/* search in cache */
r = _d->table[sl].first;
for(i = 0; i < _d->table[sl].n; i++) {
if(r->aorhash==_aorhash) {
c = r->contacts;
while(c) {
if(c->ruid.len==_ruid->len
&& !memcmp(c->ruid.s, _ruid->s, _ruid->len)) {
*_r = r;
*_c = c;
return 0;
}
}
}
r = r->next;
}
} else {
/* search in DB */
r = db_load_urecord_by_ruid(_d, _ruid);
if (r) {
if(r->aorhash==_aorhash) {
c = r->contacts;
while(c) {
if(c->ruid.len==_ruid->len
&& !memcmp(c->ruid.s, _ruid->s, _ruid->len)) {
*_r = r;
*_c = c;
return 0;
}
}
}
}
}
unlock_ulslot(_d, (_aorhash & (_d->size - 1)));
return -1; /* Nothing found */
}
/*!
* \brief Delete a urecord from domain

@ -175,6 +175,18 @@ int insert_urecord(udomain_t* _d, str* _aor, struct urecord** _r);
int get_urecord(udomain_t* _d, str* _aor, struct urecord** _r);
/*!
* \brief Obtain a urecord pointer if the urecord exists in domain (lock slot)
* \param _d domain to search the record
* \param _aorhash hash id for address of record
* \param _ruid record internal unique id
* \param _r store pointer to location record
* \param _c store pointer to contact structure
* \return 0 if a record was found, 1 if nothing could be found
*/
int get_urecord_by_ruid(udomain_t* _d, unsigned int _aorhash,
str *_ruid, struct urecord** _r, struct ucontact** _c);
/*!
* \brief Delete a urecord from domain
* \param _d domain where the record should be deleted

@ -119,6 +119,14 @@ static inline int mi_add_aor_node(struct mi_node *parent, urecord_t* r, time_t t
if (short_dump)
return 0;
#if 0
/* aor hash */
p = int2str((unsigned long)r->aorhash, &len);
node = add_mi_node_child( anode, MI_DUP_VALUE, "HashID", 6, p, len);
if (node==0)
return -1;
#endif
for( c=r->contacts ; c ; c=c->next) {
/* contact */
cnode = add_mi_node_child( anode, MI_DUP_VALUE, "Contact", 7,
@ -221,6 +229,28 @@ static inline int mi_add_aor_node(struct mi_node *parent, urecord_t* r, time_t t
if (node==0)
return -1;
/* ruid */
if (c->ruid.len) {
node = add_mi_node_child( cnode, MI_DUP_VALUE, "Ruid", 4,
c->ruid.s, c->ruid.len);
if (node==0)
return -1;
}
/* instance */
if (c->instance.len) {
node = add_mi_node_child( cnode, MI_DUP_VALUE, "Instance", 8,
c->instance.s, c->instance.len);
if (node==0)
return -1;
}
/* reg-id */
p = int2str((unsigned long)c->reg_id, &len);
node = add_mi_node_child( cnode, MI_DUP_VALUE, "Reg-Id", 6, p, len);
if (node==0)
return -1;
} /* for */
return 0;

@ -78,7 +78,7 @@ int new_urecord(str* _dom, str* _aor, urecord_t** _r)
memcpy((*_r)->aor.s, _aor->s, _aor->len);
(*_r)->aor.len = _aor->len;
(*_r)->domain = _dom;
(*_r)->aorhash = core_hash(_aor, 0, 0);
(*_r)->aorhash = ul_get_aorhash(_aor);
return 0;
}
@ -628,3 +628,49 @@ int get_ucontact(urecord_t* _r, str* _c, str* _callid, str* _path, int _cseq,
return 1;
}
/*
* Get pointer to ucontact with given info (by address or sip.instance)
*/
int get_ucontact_by_instance(urecord_t* _r, str* _c, ucontact_info_t* _ci,
ucontact_t** _co)
{
ucontact_t* ptr;
str i1;
str i2;
if (_ci->instance.s == NULL || _ci->instance.len <= 0) {
return get_ucontact(_r, _c, _ci->callid, _ci->path, _ci->cseq, _co);
}
/* find by instance */
ptr = _r->contacts;
while(ptr) {
if (ptr->instance.len>0 && _ci->reg_id==ptr->reg_id)
{
i1 = _ci->instance;
i2 = ptr->instance;
if(i1.s[0]=='<' && i1.s[i1.len-1]=='>') {
i1.s++;
i1.len-=2;
}
if(i2.s[0]=='<' && i2.s[i2.len-1]=='>') {
i2.s++;
i2.len-=2;
}
if(i1.len==i2.len && memcmp(i1.s, i2.s, i2.len)==0) {
*_co = ptr;
return 0;
}
}
ptr = ptr->next;
}
return 1;
}
unsigned int ul_get_aorhash(str *_aor)
{
return core_hash(_aor, 0, 0);
}

@ -162,6 +162,16 @@ int get_ucontact(urecord_t* _r, str* _c, str* _callid, str* _path,
*/
void release_urecord(urecord_t* _r);
/*!
* \brief Get pointer to ucontact with given contact
* \param _r record where to search the contacts
* \param _c contact string
* \param _ci contact info (callid, cseq, instance, ...)
* \param _co found contact
* \return 0 - found, 1 - not found, -1 - invalid found,
* -2 - found, but to be skipped (same cseq)
*/
int get_ucontact_by_instance(urecord_t* _r, str* _c, ucontact_info_t* _ci,
ucontact_t** _co);
#endif

@ -34,12 +34,12 @@
*/
#include "../usrloc/usrloc.h"
#include "../../sr_module.h"
#include "p_usrloc_mod.h"
#include "ucontact.h"
#include "udomain.h"
#include "dlist.h"
#include "urecord.h"
#include "ucontact.h"
#include "udomain.h"
#include "../../sr_module.h"
#include "p_usrloc_mod.h"
/*! nat branch flag */
extern unsigned int nat_bflag;
@ -58,7 +58,6 @@ int bind_usrloc(usrloc_api_t* api)
LM_ERR("invalid parameter value\n");
return -1;
}
if (init_flag==0) {
LM_ERR("configuration error - trying to bind to usrloc module"
" before being initialized\n");
@ -78,6 +77,10 @@ int bind_usrloc(usrloc_api_t* api)
api->get_ucontact = get_ucontact;
api->update_ucontact = update_ucontact;
api->register_ulcb = register_ulcb;
api->get_aorhash = ul_get_aorhash;
api->get_urecord_by_ruid = get_urecord_by_ruid;
api->get_ucontact_by_instance = get_ucontact_by_instance;
api->use_domain = use_domain;
api->db_mode = db_mode;

@ -2777,6 +2777,14 @@ int process_dialogs(int round, int presence_winfo)
result_cols[updated_winfo_col = n_result_cols++] = &str_updated_winfo_col;
result_cols[expires_col = n_result_cols++] = &str_expires_col;
/* Need to redo this here as we might have switched to the
presentity table during a previous iteration. */
if (pa_dbf.use_table(pa_db, &active_watchers_table) < 0)
{
LM_ERR("use table failed\n");
goto error;
}
if (pa_dbf.start_transaction)
{
if (pa_dbf.start_transaction(pa_db) < 0)

@ -101,20 +101,6 @@
...
modparam("pua_bla", "default_domain", "kamailio.org")
...
</programlisting>
</example>
</section>
<section>
<title><varname>default_domain</varname>(str)</title>
<para>
The domain to be used to publish information about a user.
</para>
<example>
<title>Set <varname>default_domain</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("pua_reginfo", "default_domain", "kamailio.org")
...
</programlisting>
</example>
</section>

@ -162,7 +162,7 @@ str* build_reginfo_full(urecord_t * record, str uri, ucontact_t* c, int type) {
memset(buf, 0, sizeof(buf));
buf_len = snprintf(buf, sizeof(buf), "%.*s", ptr->user_agent.len, ptr->user_agent.s);
xmlNewProp(contact_node, BAD_CAST "user_agent", BAD_CAST buf);
/* URI-Node */
memset(buf, 0, sizeof(buf));
buf_len = snprintf(buf, sizeof(buf), "%.*s", ptr->c.len, ptr->c.s);

@ -16,7 +16,7 @@ Edited by
Bogdan-Andre Iancu
Copyright © 2003 FhG FOKUS
Copyright © 2003 FhG FOKUS
__________________________________________________________________
Table of Contents
@ -111,9 +111,9 @@ Bogdan-Andre Iancu
1.24. lookup usage
1.25. registered usage
1.26. add_sock_hdr usage
1.27. registered usage
1.28. registered usage
1.29. registered usage
1.27. unregister usage
1.28. reg_fetch_contacts usage
1.29. reg_free_contacts usage
1.30. $ulc(name) usage
Chapter 1. Admin Guide
@ -197,8 +197,8 @@ Chapter 1. Admin Guide
* off - stores the value of the Path headers into usrloc without
passing it back to the UAC in the reply.
* lazy - stores the Path header and passes it back to the UAC if
Path-support is indicated by the "path" param in the Supported HF.
* strict - rejects the registration with "420 Bad Extension" if
Path-support is indicated by the “path” param in the Supported HF.
* strict - rejects the registration with “420 Bad Extension” if
there's a Path header but no support for it is indicated by the
UAC. Otherwise it's stored and passed back to the UAC.
@ -210,8 +210,8 @@ Chapter 1. Admin Guide
client's NAT).
The whole process is transparent to the user, so no config changes are
required beside setting the registrar-parameters "use_path" and
"path_mode".
required beside setting the registrar-parameters “use_path” and
“path_mode”.
1.2. GRUU Support
@ -273,7 +273,7 @@ Chapter 1. Admin Guide
contact parameters, this value will be used for newly created usrloc
records. The parameter contains number of second to expire (for example
use 3600 for one hour). If it is set to a lower value than the
"min_expires" parameter then it will be ignored. This parameter can be
“min_expires” parameter then it will be ignored. This parameter can be
modified via ser config framework. A random value in a specific
interval can be selected by using the default_expires_range parameter
@ -287,9 +287,9 @@ modparam("registrar", "default_expires", 1800)
3.2. default_expires_range (integer)
This parameter specifies that the expiry used for newly created usrloc
records are not fixed(when "default_expires" applies), but a random
value in the interval "[default_expires-default_expires_range%,
default_expires+default_expires_range%]". The value is between 0 and
records are not fixed(when “default_expires” applies), but a random
value in the interval [default_expires-default_expires_range%,
default_expires+default_expires_range%]. The value is between 0 and
100 and represent the maximim percentage from default_expires that will
be substracted or added when computing the value. Default in 0, meaning
default_expires is left unmodified. This parameter can be modified via
@ -507,7 +507,7 @@ modparam("registrar", "method_filtering", 1)
3.17. use_path (integer)
If set to 1, the Path header is handled according to the parameter This
parameter can be modified via ser config framework. "path_mode".
parameter can be modified via ser config framework. “path_mode”.
Default value is 0 (disabled).
@ -524,12 +524,12 @@ modparam("registrar", "use_path", 1)
the reply.
* 1 - The Path header is saved into usrloc, but is only included in
the reply if path support is indicated in the registration request
by the "path" option of the "Supported" header.
by the “path” option of the “Supported” header.
* 2 - The path header is only saved into usrloc, if path support is
indicated in the registration request by the "path" option of the
"Supported" header. If no path support is indicated, the request is
rejected with "420 - Bad Extension" and the header "Unsupported:
path" is included in the reply along with the received "Path"
indicated in the registration request by the “path” option of the
“Supported” header. If no path support is indicated, the request is
rejected with “420 - Bad Extension” and the header “Unsupported:
path” is included in the reply along with the received “Path”
header. This mode is the one recommended by RFC-3327.
Default value is 2.
@ -541,10 +541,10 @@ modparam("registrar", "path_mode", 0)
3.19. path_use_received (integer)
If set to 1, the "received" parameter of the first Path URI of a
If set to 1, the “received” parameter of the first Path URI of a
registration is set as received-uri and the NAT branch flag is set for
this contact. This is useful if the registrar is placed behind a SIP
loadbalancer, which passes the nat'ed UAC address as "received"
loadbalancer, which passes the nat'ed UAC address as “received”
parameter in it's Path uri.
Default value is 0 (disabled).
@ -605,7 +605,7 @@ modparam("registrar", "xavp_cfg", "ulrcd")
3.23. gruu_enabled (integer)
If set to 1 and GRUU "+sip.instance" parameter to Contact header of
If set to 1 and GRUU “+sip.instance” parameter to Contact header of
REGISTER is present, then the value of the parameter is saved to
location and pub-gruu and temp-gruu addresses are generated.
@ -628,7 +628,7 @@ modparam("registrar", "gruu_enabled", 0)
4.6. reg_fetch_contacts(domain, uri, profile)
4.7. reg_free_contacts(profile)
4.1. save(domain, [, flags [, uri]])
4.1. save(domain, [, flags [, uri]])
The function processes a REGISTER message. It can add, remove or modify
usrloc records depending on Contact and Expires HFs in the REGISTER
@ -672,7 +672,7 @@ save("location", "0x01");
save("location", "0x00", "sip:test@kamailio.org");
...
4.2. lookup(domain [, uri])
4.2. lookup(domain [, uri])
The functions extracts username from Request-URI and tries to find all
contacts for the username in usrloc. If there are no such contacts, -1
@ -712,7 +712,7 @@ switch ($retcode) {
};
...
4.3. registered(domain [, uri])
4.3. registered(domain [, uri])
The function returns true if the AOR in the Request-URI is registered,
false otherwise. The function does not modify the message being
@ -734,9 +734,9 @@ if (registered("location")) {
};
...
4.4. add_sock_hdr(hdr_name)
4.4. add_sock_hdr(hdr_name)
Adds to the current REGISTER request a new header with "hdr_name" which
Adds to the current REGISTER request a new header with “hdr_name” which
contains the description of the received socket (proto:ip:port)
This make sens only in multiple replicated servers scenarios.
@ -751,7 +751,7 @@ if (registered("location")) {
add_sock_hdr("Sock-Info");
...
4.5. unregister(domain, uri)
4.5. unregister(domain, uri)
The function remove all the contact associated to 'uri'.
@ -764,13 +764,13 @@ add_sock_hdr("Sock-Info");
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
Example 1.27. registered usage
Example 1.27. unregister usage
...
unregister("location", "$ru");
unregister("location", "sip:user@kamailio.org");
...
4.6. reg_fetch_contacts(domain, uri, profile)
4.6. reg_fetch_contacts(domain, uri, profile)
The function fetches the contacts for 'uri' from table 'domain' to
pseudo-variable $ulc(profile).
@ -786,13 +786,13 @@ unregister("location", "sip:user@kamailio.org");
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
Example 1.28. registered usage
Example 1.28. reg_fetch_contacts usage
...
reg_fetch_contacts("location", "$ru", "callee");
reg_fetch_contacts("location", "sip:user@kamailio.org", "caller");
...
4.7. reg_free_contacts(profile)
4.7. reg_free_contacts(profile)
The function frees the contacts from pseudo-variable $ulc(profile).
Should be called to release the content of a profile. Anyhow, fetching
@ -805,7 +805,7 @@ reg_fetch_contacts("location", "sip:user@kamailio.org", "caller");
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
Example 1.29. registered usage
Example 1.29. reg_free_contacts usage
...
reg_free_contacts("callee");
...
@ -845,12 +845,12 @@ reg_free_contacts("callee");
6.1. $ulc(profile=>attr)
Access the attributes of contact addresses stored in 'profile'. It must
be used after a call of "reg_fetch_contacts()".
be used after a call of “reg_fetch_contacts()”.
The "profile" has to be one of the values used with
"reg_fetch_contacts()".
The “profile” has to be one of the values used with
“reg_fetch_contacts()”.
The "attr" can be:
The “attr” can be:
* aor - address of record
* domain - use location domain name
* aorhash - hash id for the record
@ -903,9 +903,9 @@ if(reg_fetch_contacts("location", "$fu", "caller"))
Chapter 2. Frequently Asked Questions
2.1. What happend with the old "nat_flag" module parameter?
2.2. What happend with the old "use_domain" module parameter?
2.3. What happend with the old "save_noreply" and "save_memory"
2.1. What happend with the old “nat_flag” module parameter?
2.2. What happend with the old “use_domain” module parameter?
2.3. What happend with the old “save_noreply” and “save_memory”
functions?
2.4. Where can I find more about Kamailio?
@ -915,23 +915,23 @@ Chapter 2. Frequently Asked Questions
2.1.
What happend with the old "nat_flag" module parameter?
What happend with the old “nat_flag” module parameter?
In was removed, as the module internally loads this value from the
"USRLOC" module (see the "nat_bflag" USRLOC parameter).
“USRLOC” module (see the “nat_bflag” USRLOC parameter).
2.2.
What happend with the old "use_domain" module parameter?
What happend with the old “use_domain” module parameter?
In was removed, as the module internally loads this option from the
"USRLOC" module. This was done in order to simplify the configuration.
“USRLOC” module. This was done in order to simplify the configuration.
2.3.
What happend with the old "save_noreply" and "save_memory" functions?
What happend with the old “save_noreply” and “save_memory” functions?
There functions were merged into the new "save(domain,flags)"
There functions were merged into the new “save(domain,flags)”
functions. If a reply should be sent or if the DB should be updated
also is controlled via the flags.

@ -985,7 +985,7 @@ add_sock_hdr("Sock-Info");
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
</para>
<example>
<title><function>registered</function> usage</title>
<title><function>unregister</function> usage</title>
<programlisting format="linespecific">
...
unregister("location", "$ru");
@ -1028,7 +1028,7 @@ unregister("location", "sip:user@kamailio.org");
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
</para>
<example>
<title><function>registered</function> usage</title>
<title><function>reg_fetch_contacts</function> usage</title>
<programlisting format="linespecific">
...
reg_fetch_contacts("location", "$ru", "callee");
@ -1060,7 +1060,7 @@ reg_fetch_contacts("location", "sip:user@kamailio.org", "caller");
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
</para>
<example>
<title><function>registered</function> usage</title>
<title><function>reg_free_contacts</function> usage</title>
<programlisting format="linespecific">
...
reg_free_contacts("callee");

@ -302,6 +302,10 @@ static inline ucontact_info_t* pack_ci( struct sip_msg* _m, contact_t* _c,
}
if(_c!=0) {
/* hook uri address - should be more than 'sip:' chars */
if(_c->uri.s!=NULL && _c->uri.len>4)
ci.c = &_c->uri;
/* Calculate q value of the contact */
if (calc_contact_q(_c->q, &ci.q) < 0) {
rerrno = R_INV_Q;
@ -651,6 +655,12 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r,
/* calculate expires */
calc_contact_expires(_m, _c->expires, &expires);
/* pack the contact info */
if ( (ci=pack_ci( 0, _c, expires, 0))==0 ) {
LM_ERR("failed to pack contact specific info\n");
goto error;
}
/* search for the contact*/
ret = ul.get_ucontact_by_instance( _r, &_c->uri, ci, &c);
if (ret==-1) {
@ -668,12 +678,6 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r,
if (expires==0)
continue;
/* pack the contact_info */
if ( (ci=pack_ci( 0, _c, expires, 0))==0 ) {
LM_ERR("failed to extract contact info\n");
goto error;
}
if (ul.insert_ucontact( _r, &_c->uri, ci, &c) < 0) {
rerrno = R_UL_INS_C;
LM_ERR("failed to insert contact\n");
@ -710,12 +714,6 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r,
rc = 3;
} else {
/* do update */
/* pack the contact specific info */
if ( (ci=pack_ci( 0, _c, expires, 0))==0 ) {
LM_ERR("failed to pack contact specific info\n");
goto error;
}
if(_mode)
{
ptr=_r->contacts;

@ -101,6 +101,7 @@ int send_full_notify(subs_t* subs, xmlNodePtr rl_node, str* rl_uri,
int len_est;
res_param_t param;
int resource_added = 0; /* Flag to indicate that we have added at least one resource */
multipart_body = NULL;
LM_DBG("start\n");
/* query in alfabetical order */

@ -49,6 +49,9 @@
#define RR_DRIVEN 1 /*!< The next hop is determined from the route set */
#define NOT_RR_DRIVEN -1 /*!< The next hop is not determined from the route set */
#define RR_ROUTE_PREFIX ROUTE_PREFIX "<"
#define RR_ROUTE_PREFIX_LEN (sizeof(RR_ROUTE_PREFIX)-1)
#define ROUTE_SUFFIX ">\r\n" /*!< SIP header suffix */
#define ROUTE_SUFFIX_LEN (sizeof(ROUTE_SUFFIX)-1)
@ -307,7 +310,8 @@ static inline int save_ruri(struct sip_msg* _m)
}
/* Create buffer for new lump */
len = ROUTE_PREFIX_LEN + _m->first_line.u.request.uri.len + ROUTE_SUFFIX_LEN;
len = RR_ROUTE_PREFIX_LEN + _m->first_line.u.request.uri.len
+ ROUTE_SUFFIX_LEN;
s = (char*)pkg_malloc(len);
if (!s) {
LM_ERR("No memory pkg left\n");
@ -315,9 +319,11 @@ static inline int save_ruri(struct sip_msg* _m)
}
/* Create new header field */
memcpy(s, ROUTE_PREFIX, ROUTE_PREFIX_LEN);
memcpy(s + ROUTE_PREFIX_LEN, _m->first_line.u.request.uri.s, _m->first_line.u.request.uri.len);
memcpy(s + ROUTE_PREFIX_LEN + _m->first_line.u.request.uri.len, ROUTE_SUFFIX, ROUTE_SUFFIX_LEN);
memcpy(s, RR_ROUTE_PREFIX, RR_ROUTE_PREFIX_LEN);
memcpy(s + RR_ROUTE_PREFIX_LEN, _m->first_line.u.request.uri.s,
_m->first_line.u.request.uri.len);
memcpy(s + ROUTE_PREFIX_LEN + _m->first_line.u.request.uri.len,
ROUTE_SUFFIX, ROUTE_SUFFIX_LEN);
LM_DBG("New header: '%.*s'\n", len, ZSW(s));

@ -435,15 +435,12 @@ static int fixup_replace_disp_uri(void** param, int param_no)
s.len += 2;
}
}
// if(s.len!=0)
// {
if(pv_parse_format(&s ,&model)<0)
{
LM_ERR("wrong format [%s] for param no %d!\n", s.s, param_no);
pkg_free(s.s);
return E_UNSPEC;
}
// }
if(pv_parse_format(&s ,&model)<0)
{
LM_ERR("wrong format [%s] for param no %d!\n", s.s, param_no);
pkg_free(s.s);
return E_UNSPEC;
}
*param = (void*)model;
return 0;

@ -218,9 +218,14 @@ int mem_update_ucontact(ucontact_t* _c, ucontact_info_t* _ci)
char* ptr;
/* No need to update Callid as it is constant
* per ucontact (set at insert time) -bogdan */
if(_ci->instance.s!=NULL && _ci->instance.len>0)
{
/* when we have instance set, update contact address and call-id */
if(_ci->c!=NULL && _ci->c->s!=NULL && _ci->c->len>0)
update_str( &_c->c, _ci->c);
if(_ci->callid!=NULL && _ci->callid->s!=NULL && _ci->callid->len>0)
update_str( &_c->callid, _ci->callid);
}
update_str( &_c->user_agent, _ci->user_agent);
if (_ci->received.s && _ci->received.len) {

@ -525,10 +525,8 @@ struct mi_root* mi_usrloc_add(struct mi_root *cmd, void *param)
if (str2q( &ci.q, node->value.s, node->value.len) < 0)
goto bad_syntax;
/* path value (param 6) */
/* unused value (param 6) FIXME */
node = node->next;
if(strncmp(node->value.s, "0", 1) != 0 && node->value.len > 1)
ci.path = &node->value;
/* flags value (param 7) */
node = node->next;

@ -94,6 +94,7 @@ typedef struct ucontact {
/*! \brief Informations related to a contact */
typedef struct ucontact_info {
str ruid; /*!< Pointer to record internal unique id */
str *c; /*!< Contact address */
str received; /*!< Received interface */
str* path; /*!< Path informations */
time_t expires; /*!< Contact expires */

@ -0,0 +1,150 @@
Index: modules/uac/from.c
===================================================================
diff -u -r1.3 modules/uac/from.c
--- modules/uac/from.c 26 Feb 2005 18:04:20 -0000 1.3
+++ modules/uac/from.c 24 Mar 2005 16:29:27 -0000
@@ -39,7 +39,6 @@
#include "../tm/tm_load.h"
#include "from.h"
-#define FL_FROM_ALTERED (1<<31)
extern str from_param;
extern int from_restore_mode;
Index: parser/msg_parser.h
===================================================================
RCS file: /cvsroot/ser/sip_router/parser/msg_parser.h,v
retrieving revision 1.56
diff -u -r1.56 msg_parser.h
--- parser/msg_parser.h 28 Feb 2005 15:28:24 -0000 1.56
+++ parser/msg_parser.h 24 Mar 2005 22:13:04 -0000
@@ -73,8 +73,8 @@
#define FL_FORCE_ACTIVE 2 /* force active SDP */
#define FL_SDP_IP_AFS 4 /* SDP IP rewritten */
#define FL_SDP_PORT_AFS 8 /* SDP port rewritten */
-#define FL_SHM_CLONE 16 /* msg cloned in SHM as a single chunk */
-
+#define FL_SHM_CLONE 16 /* msg cloned in SHM as a single chunk */
+#define FL_FROM_ALTERED 32 /* from is altered */
#define IFISMETHOD(methodname,firstchar) \
if ( (*tmp==(firstchar) || *tmp==((firstchar) | 32)) && \
Index: modules/tm/t_msgbuilder.c
===================================================================
RCS file: /cvsroot/ser/sip_router/modules/tm/t_msgbuilder.c,v
retrieving revision 1.41
diff -u -r1.41 t_msgbuilder.c
--- modules/tm/t_msgbuilder.c 23 Feb 2005 17:16:06 -0000 1.41
+++ modules/tm/t_msgbuilder.c 24 Mar 2005 22:13:04 -0000
@@ -75,6 +75,72 @@
(_p)+=(_str).len; \
} while(0);
+#define LC(_cp) ((*(_cp))|0x20)
+static int extract_from( char *buf, int len, str *from)
+{
+ char *end, *p;
+ char *b;
+ int state;
+
+ p = buf;
+ end = buf+len;
+ state = 1;
+ b = 0;
+
+ while(p<end) {
+ switch (*p) {
+ case '\n':
+ case '\r':
+ switch (state) {
+ case 4: state=5;break;
+ case 5: case 6: state=6;break;
+ default : state=2;break;
+ }
+ break;
+ case ' ':
+ case '\t':
+ switch (state) {
+ case 4: case 6: state=5; break;
+ case 2: state=1; break;/*folded line*/
+ }
+ break;
+ case ':':
+ switch (state) {
+ case 4: state=5;break;
+ case 6: goto found;
+ case 2: state=1;break;
+ }
+ break;
+ case 'f':
+ case 'F':
+ if (state==5) break;
+ if (state==6) goto found;
+ if (state!=2) {state = 1;break;}
+ /* hdr starting with 'f' */
+ b = p;
+ if (p+3<end && LC(p+1)=='r' && LC(p+2)=='o' && LC(p+3)=='m')
+ p+=3;
+ state = 4; /* "f" or "from" found */
+ break;
+ default:
+ switch (state) {
+ case 2:case 4: state=1; break;
+ case 6: ;goto found;
+ }
+ }
+ p++;
+ }
+
+ LOG(L_CRIT,"BUG:tm:extract_from: no from found in outgoing buffer\n");
+ return -1;
+found:
+ from->s = b;
+ from->len = p-b;
+ DBG("-----from= <%.*s>\n",from->len,from->s);
+ return 0;
+}
+
+
/* Build a local request based on a previous request; main
customers of this function are local ACK and local CANCEL
*/
@@ -88,6 +154,7 @@
int branch_len;
str branch_str;
struct hostport hp;
+ str from;
#ifdef _OBSO
if ( Trans->uac[branch].last_received<100)
@@ -98,6 +165,12 @@
}
#endif
+ if (!Trans->uas.request || !(Trans->uas.request->msg_flags&FL_FROM_ALTERED)
+ || extract_from( Trans->uac[branch].request.buffer,
+ Trans->uac[branch].request.buffer_len, &from)!=0) {
+ from = Trans->from;
+ }
+
/* method, separators, version: "CANCEL sip:p2@iptel.org SIP/2.0" */
*len=SIP_VERSION_LEN + method_len + 2 /* spaces */ + CRLF_LEN;
*len+=Trans->uac[branch].uri.len;
@@ -119,7 +192,7 @@
}
*len+= via_len;
/*headers*/
- *len+=Trans->from.len+Trans->callid.len+to->len+
+ *len+=from.len+Trans->callid.len+to->len+
+Trans->cseq_n.len+1+method_len+CRLF_LEN;
@@ -154,7 +227,7 @@
append_mem_block(p,via,via_len);
/*other headers*/
- append_str( p, Trans->from );
+ append_str( p, from );
append_str( p, Trans->callid );
append_str( p, *to );

@ -1998,10 +1998,13 @@ void print_all_socket_lists()
si->name.s);
if (!si->flags & SI_IS_IP)
printf(" [%s]", si->address_str.s);
printf( ":%s%s%s\n",
printf( ":%s%s%s",
si->port_no_str.s,
si->flags & SI_IS_MCAST ? " mcast" : "",
si->flags & SI_IS_MHOMED? " mhomed" : "");
if (si->useinfo.name.s)
printf(" advertise %s", si->useinfo.name.s);
printf("\n");
}
}
}while((proto=next_proto(proto)));

@ -0,0 +1,172 @@
#
# $Id$
#
# iptel.org real world configuration
#
# ----------- global configuration parameters ------------------------
# we're debugging now
debug=9 # debug level (cmd line: -dddddddddd)
fork=no
log_stderror=yes # (cmd line: -E)
#fork=yes
#children=16
#log_stderror=no # (cmd line: -E)
check_via=yes # (cmd. line: -v)
dns=on # (cmd. line: -r)
rev_dns=yes # (cmd. line: -R)
# experimental usage at port 5060
#port=9060
#port=8060
port=5060
# advertise IP address in Via (as opposed to advertising DNS name
# which is annoying for downstream servers and some phones can
# not handle DNS at all)
#listen=195.37.77.101
#listen=193.175.135.170
# ------------------ module loading ----------------------------------
loadmodule "../sip_router/modules/sl/sl.so"
loadmodule "../sip_router/modules/print/print.so"
loadmodule "../sip_router/modules/tm/tm_mod.so"
#loadmodule "../sip_router/modules/acc/acc.so"
loadmodule "../sip_router/modules/rr/rr.so"
loadmodule "../sip_router/modules/maxfwd/maxfwd.so"
#loadmodule "../sip_router/modules/mysql/mysql.so"
loadmodule "../sip_router/modules/usrloc/usrloc.so"
#loadmodule "../sip_router/modules/auth/auth.so"
#loadmodule "../sip_router/modules/cpl/cpl.so"
loadmodule "../sip_router/modules/radius_acc/radius_acc.so"
loadmodule "../sip_router/modules/registrar/registrar.so"
# ----------------- setting module-specific parameters ---------------
# -- usrloc params --
# use in-RAM usrloc
#modparam("usrloc", "use_db", 0)
# -- acc params --
# report ACKs too for sake of completeness -- as we account PSTN
# destinations which are RR, ACKs should show up
#modparam("acc", "report_ack", 1)
# don't bother me with early media reports (I don't like 183
# too much anyway...ever thought of timer C hitting after
# listening to music-on-hold for five minutes?)
#modparam("acc", "early_media", 0)
#modparam("acc", "log_level", 1)
# that is the flag for which we will account -- don't forget to
# set the same one :-)
#modparam("acc", "acc_flag", 1 )
# we are interested only in succesful transactions
#modparam("acc", "failed_transactions", 0 )
# -- acc params --
# report ACKs too for sake of completeness -- as we account PSTN
# destinations which are RR, ACKs should show up
modparam("radius_acc", "report_ack", 1)
# don't bother me with early media reports (I don't like 183
# too much anyway...ever thought of timer C hitting after
# listening to music-on-hold for five minutes?)
modparam("radius_acc", "early_media", 0)
modparam("radius_acc", "log_level", 1)
# that is the flag for which we will account -- don't forget to
# set the same one :-)
modparam("radius_acc", "acc_flag", 1 )
# we are interested only in succesful transactions
modparam("radius_acc", "failed_transactions", 0 )
# -- tm params --
modparam("tm", "fr_timer", 30 )
modparam("tm", "fr_inv_timer", 60 )
# ------------------------- request routing logic -------------------
# main routing logic
route{
# filter local stateless ACK generated by authentication of mf replies
sl_filter_ACK();
# filter too old messages
log("LOG: Checking maxfwd\n");
if (!mf_process_maxfwd_header("10")) {
log("LOG: Too many hops\n");
sl_send_reply("483","Too Many Hops");
break;
};
# len_gt *after* max_fwd, otherwise an "INVITE sip:sos@0.0.0.0"
# will cause "message too big" for a short message
if (len_gt( max_len )) {
sl_send_reply("513", "Riesengross -- Message too large");
break;
};
# Do strict routing if route headers present
if (method=="INVITE") {
addRecordRoute();
} else {
rewriteFromRoute();
};
# that is outbound request...
if (!(uri=~"fox\.iptel\.org([;:].*)*"
| uri=~"[@:\.]195\.37\.77\.101([;:].*)*" )) {
route(2);
# break from route (2) return -- stop then !
break;
};
# here we continue with requests for our domain...
if (method=="REGISTER") {
# update Contact database
log("LOG: REGISTER is authorized, saving location\n");
save("location");
break;
};
# native SIP destinations are handled using our USRLOC DB
if (!lookup("location")) {
if (method=="ACK") {
log("Ooops -- an ACK made it here -- probably UAC screwed up to-tags\n");
break;
};
log("LOG: Unable to lookup contact, sending 404\n");
sl_send_reply("404", "Not Found");
break;
};
# label for accounting
setflag(1);
# we now know we may, we know where, let it go out now!
if (!t_relay()) {
sl_reply_error();
break;
};
}
#---------------------------------------------------------------------
# routing logic for outbound requests targeted out of our domain
# -- use outbound proxy iptel.org (note that except to FOKUS/PBX,
# or itpel.org users, requests will be challenged)
route[2] {
log("LOG: that's a request to outside");
# label for accounting
setflag(1);
if (!t_relay_to("fox.iptel.org", "5060")) {
sl_reply_error();
break;
};
}

@ -0,0 +1,102 @@
/*
*
* simple atomic ops testing program
* (no paralel stuff, just see if the opcodes are "legal")
*
* Compile with: gcc -Wall -O3 -D__CPU_i386 on x86 machines
* gcc -Wall -O3 -D__CPU_x86_64 on amd64 machines
* gcc -mips2 -Wall -O2 -D__CPU_mips2 on mips machines
* gcc -m64 -Wall -O2 -D__CPU_mips64 on mips64 machines
* gcc -O3 -Wall -D__CPU_ppc on powerpc machines
* gcc -m64 -O3 -Wall -D__CPU_ppc64 on powerpc machines
* gcc -m64 -O3 -Wall -D__CPU_sparc64 -DSPARC64_MODE on
* ultrasparc machines
* -- andrei
*
*
*/
#include <stdio.h>
#define CC_GCC_LIKE_ASM
#include "../atomic_ops.h"
#ifdef ATOMIC_OPS_USE_LOCK
/* hack to make lock work */
#include "../lock_ops.h"
gen_lock_t* _atomic_lock;
gen_lock_t dummy_lock;
#endif
int main(int argc, char** argv)
{
int r;
atomic_t v;
#ifdef ATOMIC_OPS_USE_LOCK
/* init the lock (emulate atomic_ops.c) */
_atomic_lock=&dummy_lock;
if (lock_init(_atomic_lock)==0){
fprintf(stderr, "ERROR: failed to initialize the lock\n");
goto error;
}
#endif
#ifdef NOSMP
printf("no-smp mode\n");
#else
printf("smp mode\n");
#endif
printf("starting memory barrier opcode tests...\n");
membar();
printf(" membar() .............................. ok\n");
membar_write();
printf(" membar_write() ........................ ok\n");
membar_read();
printf(" membar_read() ......................... ok\n");
printf("\nstarting atomic ops basic tests...\n");
mb_atomic_set(&v, 1);
printf(" atomic_set, v should be 1 ............. %2d\n", mb_atomic_get(&v));
mb_atomic_inc(&v);
printf(" atomic_inc, v should be 2 ............. %2d\n", mb_atomic_get(&v));
r=mb_atomic_inc_and_test(&v);
printf(" atomic_inc_and_test, v should be 3 ... %2d\n", mb_atomic_get(&v));
printf(" r should be 0 ... %2d\n", r);
mb_atomic_dec(&v);
printf(" atomic_dec, v should be 2 ............. %2d\n", mb_atomic_get(&v));
r=mb_atomic_dec_and_test(&v);
printf(" atomic_dec_and_test, v should be 1 ... %2d\n", mb_atomic_get(&v));
printf(" r should be 0 ... %2d\n", r);
r=mb_atomic_dec_and_test(&v);
printf(" atomic_dec_and_test, v should be 0 ... %2d\n", mb_atomic_get(&v));
printf(" r should be 1 ... %2d\n", r);
r=mb_atomic_dec_and_test(&v);
printf(" atomic_dec_and_test, v should be -1 ... %2d\n", mb_atomic_get(&v));
printf(" r should be 0 ... %2d\n", r);
mb_atomic_and(&v, 2);
printf(" atomic_and, v should be 2 ............. %2d\n", mb_atomic_get(&v));
mb_atomic_or(&v, 5);
r=mb_atomic_get_and_set(&v, 0);
printf(" atomic_or, v should be 7 ............. %2d\n", r);
printf(" atomic_get_and_set, v should be 0 ..... %2d\n", mb_atomic_get(&v));
printf("\ndone.\n");
#ifdef ATOMIC_OPS_USE_LOCK
lock_destroy(_atomic_lock);
#endif
return 0;
#ifdef ATOMIC_OPS_USE_LOCK
error:
return -1;
#endif
}

@ -0,0 +1,301 @@
/*
*
* simple atomic ops testing program
* (no paralel stuff, just see if the opcodes are "legal")
*
* Defines: TYPE - not defined => use atomic_t and the corresponding
* atomic functions
* - long => use volatile long* and the atomic_*_long functions
* - int => use volatile int* and the atomic_*_int functions
* MEMBAR - if defined use mb_atomic_* instead of atomic_*
* NOSMP - use non smp versions
* NOASM - don't use asm inline version
* __CPU_xxx - use __CPU_xxx code
* SPARC64_MODE - compile for a sparc 64 in 64 bit mode (gcc -m64
* must be used on solaris in this case)
* Example:
* gcc -Wall -O3 -D__CPU_i386 -DNOSMP -DMEMBAR -DTYPE=long atomic_test2.c
*
* Compile with: gcc -Wall -O3 -D__CPU_i386 ... on x86 machines
* gcc -Wall -O3 -D__CPU_x86_64 ... on amd64 machines
* gcc -mips2 -Wall -O2 -D__CPU_mips2 ... on mips machines
* gcc -m64 -Wall -O2 -D__CPU_mips64 ... on mips64 machines
* gcc -O3 -Wall -D__CPU_ppc ... on powerpc machines
* gcc -m64 -O3 -Wall -D__CPU_ppc64 ... on powerpc machines
* gcc -m64 -O3 -Wall -D__CPU_sparc64 -DSPARC64_MODE ... on
* ultrasparc machines
* gcc -mcpu=v9 -O3 -Wall -D__CPU_sparc64 ... for 32 bit code
* (sparc32plus) on
* ultrasparc machines
* gcc -O3 -Wall -D__CPU_sparc ... on sparc v8 machines
* -- andrei
*
*
*/
#include <stdio.h>
#ifndef NOASM
#define CC_GCC_LIKE_ASM
#endif
#include "../atomic_ops.h"
#if defined ATOMIC_OPS_USE_LOCK || defined MEMBAR_USES_LOCK || \
defined ATOMIC_OPS_USE_LOCK_SET
/* hack to make lock work */
#include "../lock_ops.h"
#endif
#ifdef MEMBAR_USES_LOCK
gen_lock_t* __membar_lock=0; /* init in atomic_ops.c */
gen_lock_t dummy_membar_lock;
#endif
#ifdef ATOMIC_OPS_USE_LOCK_SET
gen_lock_set_t* _atomic_lock_set=0;
gen_lock_set_t dummy_atomic_lock_set;
gen_lock_t locks_array[_ATOMIC_LS_SIZE];
#elif defined ATOMIC_OPS_USE_LOCK
gen_lock_t* _atomic_lock=0;
gen_lock_t dummy_atomic_lock;
#endif /* ATOMIC_OPS_USE_LOCK / _SET */
#if defined MB || defined MEMBAR
#undef MB
#define MB mb_
#define MEMBAR_STR "membar "
#else
#define MB /* empty */
#define MEMBAR_STR ""
#endif
#ifndef TYPE
#define SUF
#define ATOMIC_TYPE atomic_t
#define VALUE_TYPE volatile int
#define get_val(v) (v->val)
#else
#define _SUF(T) _##T
#define _SUF1(T) _SUF(T)
#define SUF _SUF1(TYPE)
#define ATOMIC_TYPE volatile TYPE
#define VALUE_TYPE ATOMIC_TYPE
#define get_val(v) (*v)
#endif
#define _STR(S) #S
#define STR(S) _STR(S)
static char* flags=
#ifdef NOASM
"no_inline_asm "
#endif
#ifdef NOSMP
"nosmp "
#else
"smp "
#endif
MEMBAR_STR
#ifndef HAVE_ASM_INLINE_MEMBAR
"no_asm_membar(slow) "
#endif
#ifndef HAVE_ASM_INLINE_ATOMIC_OPS
"no_asm_atomic_ops"
#ifdef ATOMIC_OPS_USE_LOCK_SET
":use_lock_set"
#elif defined ATOMIC_OPS_USE_LOCK
":use_lock"
#endif
" "
#endif
#ifdef TYPE
STR(TYPE) " "
#else
"atomic_t "
#endif
;
/* macros for atomic_* functions */
#define _AT_DECL(OP, P, S) \
P##atomic_##OP##S
/* to make sure all the macro passed as params are expanded,
* go through a 2 level deep macro decl. */
#define _AT_DECL1(OP, P, S) _AT_DECL(OP, P, S)
#define AT_DECL(OP) _AT_DECL1(OP, MB, SUF)
#define at_set AT_DECL(set)
#define at_get AT_DECL(get)
#define at_inc AT_DECL(inc)
#define at_dec AT_DECL(dec)
#define at_inc_and_test AT_DECL(inc_and_test)
#define at_dec_and_test AT_DECL(dec_and_test)
#define at_and AT_DECL(and)
#define at_or AT_DECL(or)
#define at_get_and_set AT_DECL(get_and_set)
#define at_cmpxchg AT_DECL(cmpxchg)
#define at_add AT_DECL(add)
#define CHECK_ERR(txt, x, y) \
if (x!=y) { \
fprintf(stderr, "ERROR: line %d: %s failed: expected 0x%02x but got "\
"0x%02x.\n", \
__LINE__, #txt, (unsigned) x, (unsigned) y);\
goto error; \
}
#define VERIFY(ops, y) \
ops ; \
CHECK_ERR( ops, y, get_val(v))
int main(int argc, char** argv)
{
ATOMIC_TYPE var;
VALUE_TYPE r;
ATOMIC_TYPE* v;
v=&var;
#ifdef MEMBAR_USES_LOCK
__membar_lock=&dummy_membar_lock;
if (lock_init(__membar_lock)==0){
fprintf(stderr, "ERROR: failed to initialize membar_lock\n");
__membar_lock=0;
goto error;
}
_membar_lock; /* start with the lock "taken" so that we can safely use
unlock/lock sequences on it later */
#endif
#ifdef ATOMIC_OPS_USE_LOCK_SET
/* init the lock (emulate atomic_ops.c) */
dummy_atomic_lock_set.locks=&locks_array[0];
_atomic_lock_set=&dummy_atomic_lock_set;
if (lock_set_init(_atomic_lock_set)==0){
fprintf(stderr, "ERROR: failed to initialize atomic_lock\n");
_atomic_lock_set=0;
goto error;
}
#elif defined ATOMIC_OPS_USE_LOCK
/* init the lock (emulate atomic_ops.c) */
_atomic_lock=&dummy_atomic_lock;
if (lock_init(_atomic_lock)==0){
fprintf(stderr, "ERROR: failed to initialize atomic_lock\n");
_atomic_lock=0;
goto error;
}
#endif
printf("%s\n", flags);
printf("starting memory barrier opcode tests...\n");
membar();
printf(" membar() .............................. ok\n");
membar_write();
printf(" membar_write() ........................ ok\n");
membar_read();
printf(" membar_read() ......................... ok\n");
membar_depends();
printf(" membar_depends() ...................... ok\n");
membar_enter_lock();
printf(" membar_enter_lock() ................... ok\n");
membar_leave_lock();
printf(" membar_leave_lock() ................... ok\n");
membar_atomic_op();
printf(" membar_atomic_op() .................... ok\n");
membar_atomic_setget();
printf(" membar_atomic_setget() ................ ok\n");
membar_read_atomic_op();
printf(" membar_read_atomic_op() ............... ok\n");
membar_read_atomic_setget();
printf(" membar_read_atomic_setget() ........... ok\n");
membar_write_atomic_op();
printf(" membar_write_atomic_op() .............. ok\n");
membar_write_atomic_setget();
printf(" membar_write_atomic_setget() .......... ok\n");
printf("\nstarting atomic ops basic tests...\n");
VERIFY(at_set(v, 1), 1);
printf(" atomic_set, v should be 1 ............. %2d\n", (int)at_get(v));
VERIFY(at_inc(v), 2);
printf(" atomic_inc, v should be 2 ............. %2d\n", (int)at_get(v));
VERIFY(r=at_inc_and_test(v), 3);
printf(" atomic_inc_and_test, v should be 3 ... %2d\n", (int)at_get(v));
printf(" r should be 0 ... %2d\n", (int)r);
VERIFY(at_dec(v), 2);
printf(" atomic_dec, v should be 2 ............. %2d\n", (int)at_get(v));
VERIFY(r=at_dec_and_test(v), 1);
printf(" atomic_dec_and_test, v should be 1 ... %2d\n", (int)at_get(v));
printf(" r should be 0 ... %2d\n", (int)r);
VERIFY(r=at_dec_and_test(v), 0);
printf(" atomic_dec_and_test, v should be 0 ... %2d\n", (int)at_get(v));
printf(" r should be 1 ... %2d\n", (int)r);
VERIFY(r=at_dec_and_test(v), -1);
printf(" atomic_dec_and_test, v should be -1 ... %2d\n", (int)at_get(v));
printf(" r should be 0 ... %2d\n", (int)r);
VERIFY(at_and(v, 2), 2);
printf(" atomic_and, v should be 2 ............. %2d\n", (int)at_get(v));
VERIFY(at_or(v, 5), 7);
printf(" atomic_or, v should be 7 ............. %2d\n", (int)at_get(v));
VERIFY(r=at_get_and_set(v, 0), 0);
printf(" atomic_get_and_set, v should be 0 ..... %2d\n", (int)at_get(v));
VERIFY(r=at_cmpxchg(v, 0, 7), 7);
CHECK_ERR(cmpxchg, r, 0);
printf(" atomic_cmpxchg, v should be 7 ......... %2d\n", (int)at_get(v));
printf(" r should be 0 ......... %2d\n", (int)r);
VERIFY(r=at_cmpxchg(v, 2, 3), 7);
CHECK_ERR(cmpxchg, r, 7);
printf(" atomic_cmpxchg (fail), v should be 7 .. %2d\n", (int)at_get(v));
printf(" r should be 7 .. %2d\n", (int)r);
VERIFY(r=at_add(v, 2), 9);
CHECK_ERR(atomic_add, r, 9);
printf(" atomic_add, v should be 9 ............. %2d\n", (int)at_get(v));
printf(" r should be 9 ............. %2d\n", (int)r);
VERIFY(r=at_add(v, -10), -1);
CHECK_ERR(atomic_add, r, -1);
printf(" atomic_add, v should be -1 ............ %2d\n", (int)at_get(v));
printf(" r should be -1 ............ %2d\n", (int)r);
printf("\ndone.\n");
#ifdef MEMBAR_USES_LOCK
lock_destroy(__membar_lock);
#endif
#ifdef ATOMIC_OPS_USE_LOCK_SET
lock_set_destroy(_atomic_lock_set);
#elif defined ATOMIC_OPS_USE_LOCK
lock_destroy(_atomic_lock);
#endif
return 0;
error:
#ifdef MEMBAR_USES_LOCK
if (__membar_lock)
lock_destroy(__membar_lock);
#endif
#ifdef ATOMIC_OPS_USE_LOCK_SET
if (_atomic_lock_set)
lock_set_destroy(_atomic_lock_set);
#elif defined ATOMIC_OPS_USE_LOCK
if (_atomic_lock)
lock_destroy(_atomic_lock);
#endif
return -1;
}

@ -0,0 +1,444 @@
/* test program -> switch speed */
/*
*
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of ser, a free SIP server.
*
* ser 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
*
* For a license to use the ser software under conditions
* other than those described here, or to purchase support for this
* software, please contact iptel.org by e-mail at the following addresses:
* info@iptel.org
*
* ser 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
*/
/* parsing: compact form:
* Via: v:
* From: f:
* To: t:
* Cseq: n/a
* Call-ID: i:
* Contact: m:
* Max-Forwards: n/a
* Route: n/a
*/
enum { INITIAL=0,
VIA1, VIA2,
FROM1, FROM2, FROM3,
TO1,
C_START, CSEQ2, CSEQ3,
CALLID2, CALLID3, CALLID4, CALLID5, CALLID6,
CONTACT2, CONTACT3, CONTACT4, CONTACT5, CONTACT6,
M_START, MAXFORWARDS2, MAXFORWARDS3, MAXFORWARDS4, MAXFORWARDS5,
MAXFORWARDS6, MAXFORWARDS7, MAXFORWARDS8, MAXFORWARDS9, MAXFORWARDS10,
MAXFORWARDS11,
ROUTE1, ROUTE2, ROUTE3, ROUTE4,
/* final states*/
F_VIA=1000, F_FROM, F_TO, F_CSEQ, F_CALLID, F_CONTACT, F_MAXFORWARDS,
F_ROUTE,
I_START,
UNKNOWN_HEADER=200,
BODY=220,
LF=25000,
};
#include <stdio.h>
int main(int argc, char** argv)
{
char* t;
register int state;
int i;
int err;
err=0;
state=INITIAL;
printf(" %s (%d)\n", argv[0], argc);
if (argc<2){
fprintf(stderr, " no parameters\n");
exit(-1);
}
for (i=0;i<10000000;i++){
for(t=argv[1];*t;t++){
switch(*t){
case 'V':
case 'v':
switch(state){
case INITIAL:
state=VIA1;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'I':
case 'i':
switch(state){
case VIA1:
state=VIA2;
break;
case CALLID5:
state=CALLID6;
break;
case INITIAL:
state=I_START;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'A':
case 'a':
switch(state){
case VIA2:
state=F_VIA;
break;
case C_START: /*CALLID1*/
state=CALLID2;
break;
case CONTACT4:
state=CONTACT5;
break;
case M_START:
state=MAXFORWARDS2;
break;
case MAXFORWARDS8:
state=MAXFORWARDS9;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'F':
case 'f':
switch(state){
case INITIAL:
state=FROM1;
break;
case MAXFORWARDS4:
state=MAXFORWARDS5;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'R':
case 'r':
switch(state){
case INITIAL:
state=ROUTE1;
break;
case FROM1:
state=FROM2;
break;
case MAXFORWARDS6:
state=MAXFORWARDS7;
break;
case MAXFORWARDS9:
state=MAXFORWARDS10;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'O':
case 'o':
switch(state){
case FROM2:
state=FROM3;
break;
case TO1:
state=F_TO;
break;
case C_START: /*CONTACT1 */
state=CONTACT2;
break;
case ROUTE1:
state=ROUTE2;
break;
case MAXFORWARDS5:
state=MAXFORWARDS6;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'M':
case 'm':
switch(state){
case INITIAL:
state=M_START;
break;
case FROM3:
state=F_FROM;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'T':
case 't':
switch(state){
case INITIAL:
state=TO1;
break;
case CONTACT3:
state=CONTACT4;
break;
case CONTACT6:
state=F_CONTACT;
break;
case ROUTE3:
state=ROUTE4;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'C':
case 'c':
switch(state){
case INITIAL:
state=C_START;
break;
case CONTACT5:
state=CONTACT6;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'S':
case 's':
switch(state){
case C_START:
state=CSEQ2;
break;
case MAXFORWARDS11:
state=F_MAXFORWARDS;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'E':
case 'e':
switch(state){
case CSEQ2:
state=CSEQ3;
break;
case ROUTE4:
state=F_ROUTE;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'Q':
case 'q':
switch(state){
case CSEQ3:
state=F_CSEQ;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'L':
case 'l':
switch(state){
case CALLID2:
state=CALLID3;
break;
case CALLID3:
state=CALLID4;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'D':
case 'd':
switch(state){
case CALLID6:
state=F_CALLID;
break;
case MAXFORWARDS10:
state=MAXFORWARDS11;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'N':
case 'n':
switch(state){
case CONTACT2:
state=CONTACT3;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'X':
case 'x':
switch(state){
case MAXFORWARDS2:
state=MAXFORWARDS3;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case '-':
switch(state){
case CALLID4:
state=CALLID5;
break;
case MAXFORWARDS3:
state=MAXFORWARDS4;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'W':
case 'w':
switch(state){
case MAXFORWARDS7:
state=MAXFORWARDS8;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case 'U':
case 'u':
switch(state){
case ROUTE2:
state=ROUTE3;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case ' ':
switch(state){
case INITIAL:
break; /*eat space */
case F_VIA:
case F_FROM:
case F_TO:
case F_CSEQ:
case F_CALLID:
case F_CONTACT:
case F_MAXFORWARDS:
case F_ROUTE:
break; /* eat trailing space*/
case VIA1:
/*compact form: v: */
state=F_VIA;
break;
case FROM1:
/*compact form f:*/
state=F_FROM;
break;
case TO1:
/*compact form t:*/
state=F_TO;
break;
case I_START:
/*compact form i: (Call-ID)*/
state=F_CALLID;
break;
case M_START:
/*compact form m: (Contact)*/
state=F_CONTACT;
break;
case UNKNOWN_HEADER: break;
default:
state=UNKNOWN_HEADER;
}
break;
case ':':
switch(state){
case F_VIA:
case VIA1: /* compact form*/
case F_FROM:
case FROM1: /*compact form*/
case F_TO:
case TO1: /*compact form*/
case F_CSEQ:
case F_CALLID:
case I_START: /*compact form*/
case F_CONTACT:
case M_START: /*compact form*/
case F_MAXFORWARDS:
case F_ROUTE:
// printf("found header, state=%d\n", state);
state=INITIAL; /* reset to test*/
break;
case UNKNOWN_HEADER:
default:
/*printf("found unknown header, state=%d\n",
state);*/
err=1;
state=INITIAL;
}
break;
default:
/*fprintf(stderr, "Unexpected char <%c> encountered"
" state=%d\n", *t, state);
exit(-1);*/
state=UNKNOWN_HEADER;
}
}
} //for i
if (err) printf("Error unknown header\n");
printf("final state=%d\n", state);
exit(0);
}

@ -0,0 +1 @@
" unterminated string

@ -0,0 +1,32 @@
INVITE sip:jiri@bat.iptel.org SIP/2.0
Max-Forwards: 10
From: "jiri" <sip:jiri@iptel.org>;tag=76ff7a07-c091-4192-84a0-d56e91fe104f
To: <sip:jiri@bat.iptel.org>
Call-ID: d10815e0-bf17-4afa-8412-d9130a793d96@213.20.128.35
CSeq: 2 INVITE
Contact: <sip:213.20.128.35:9315>
User-Agent: Windows RTC/1.0
Proxy-Authorization: Digest username="jiri", realm="iptel.org", algorithm="MD5", uri="sip:jiri@bat.iptel.org", nonce="3cef753900000001771328f5ae1b8b7f0d742da1feb5753c", response="53fe98db10e1074b03b3e06438bda70f"
Content-Type: application/sdp
Content-Length: 451
v=0
o=jku2 0 0 IN IP4 213.20.128.35
s=session
c=IN IP4 213.20.128.35
b=CT:1000
t=0 0
m=audio 54742 RTP/AVP 97 111 112 6 0 8 4 5 3 101
a=rtpmap:97 red/8000
a=rtpmap:111 SIREN/16000
a=fmtp:111 bitrate=16000
a=rtpmap:112 G7221/16000
a=fmtp:112 bitrate=24000
a=rtpmap:6 DVI4/16000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:5 DVI4/8000
a=rtpmap: 3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16

@ -0,0 +1,6 @@
INVITE sip:x@y.z SIP/2.0
Via : SIP / 2.0
/UDP
193.175.133.193

@ -0,0 +1,4 @@
INVITE sip:x@y.z SIP/2.0/UDP
V: SIP/2.0/UDP 193.175.133.193

@ -0,0 +1,3 @@
INVITE sip:x@y.z SIP/2.0/UDP

@ -0,0 +1,401 @@
/*
* $Id$
*
* Tests for basex.h
*
* Copyright (C) 2008 iptelorg GmbH
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*#define NO_BASE64_LOOKUP_TABLE
#define SINGLE_REG */
#include "../basex.h"
#include "profile.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
#define BASE64 64
#define Q_BASE64 640
#define BASE16 16
#ifndef BASEX
#define BASEX BASE16
#endif
#if BASEX == Q_BASE64
#warning Q_BASE64
#define B_ENC q_base64_enc
#define B_DEC q_base64_dec
#define B_ENC_LEN(l) (((l)+2)/3*4)
#elif BASEX == BASE16
#warning BASE16
#define B_ENC base16_enc
#define B_DEC base16_dec
#define B_ENC_LEN(l) ((l)*2)
#else
#warning BASE64
#define B_ENC base64_enc
#define B_DEC base64_dec
#define B_ENC_LEN(l) (((l)+2)/3*4)
#endif
#define QUOTE_MACRO(x) QUOTEME(x)
#define QUOTEME(x) #x
static char* id="$Id$";
static char* version="basex test 0.1 "
"BASE" QUOTE_MACRO(BASEX) ": " QUOTE_MACRO(B_ENC) ", " QUOTE_MACRO(B_DEC) ""
#if defined BASE64_LOOKUP_TABLE
#ifdef BASE64_LOOKUP_LARGE
" (large b64 lookup table)"
#else
" (lookup b64 table)"
#endif
#else
" (no b64 lookup table)"
#endif
#if defined BASE16_LOOKUP_TABLE
#ifdef BASE16_LOOKUP_LARGE
" (large b16 lookup table)"
#else
" (lookup b16 table)"
#endif
#else
" (no b16 lookup table)"
#endif
#if defined BASE64_READ_WHOLE_INTS || defined BASE16_READ_WHOLE_INTS
" (read 4 bytes at a time)"
#else
" (read 1 byte at a time)"
#endif
;
static char* help_msg="\
Usage: basex [-hv] ... [options]\n\
Options:\n\
-m min minimum length\n\
-M max maximum length\n\
-o offset offset from the start of the buffer (alignment tests)\n\
-e offset offset from the start of the dst. buf. (alignment tests)\n\
-n no. number of test loops\n\
-v increase verbosity\n\
-V version number\n\
-h this help message\n\
";
/* profiling */
struct profile_data pf1, pf2, pf3, pf4, pf5, pf6;
void dump_profile_info(struct profile_data* pd)
{
printf("profiling for %s (%ld/%ld): %lld/%lld/%lld (max/avg/last),"
" total %lld\n",
pd->name, pd->entries, pd->exits, pd->max_cycles,
pd->entries?pd->total_cycles/pd->entries:0, pd->cycles,
pd->total_cycles);
}
int seed_prng()
{
int seed, rfd;
if ((rfd=open("/dev/urandom", O_RDONLY))!=-1){
try_again:
if (read(rfd, (void*)&seed, sizeof(seed))==-1){
if (errno==EINTR) goto try_again; /* interrupted by signal */
fprintf(stderr, "WARNING: could not read from /dev/urandom: "
" %s (%d)\n", strerror(errno), errno);
}
close(rfd);
}else{
fprintf(stderr, "WARNING: could not open /dev/urandom: %s (%d)\n",
strerror(errno), errno);
}
seed+=getpid()+time(0);
srand(seed);
return 0;
}
/* fill buf with random data*/
void fill_rand(unsigned char* buf, int len)
{
unsigned char* end;
int v;
/* find out how many random bytes we can get from rand() */
#if RAND_MAX >= 0xffffffff
#define RAND_BYTES 4
#warning RAND_BYTES is 4
#elif RAND_MAX >= 0xffffff
#define RAND_BYTES 3
#warning RAND_BYTES is 3
#elif RAND_MAX >= 0xffff
#define RAND_BYTES 2
#warning RAND_BYTES is 2
#else
#define RAND_BYTES 1
#endif
end=buf+len/RAND_BYTES*RAND_BYTES;
for(;buf<end;buf+=RAND_BYTES){
v=rand();
buf[0]=v;
#if RAND_BYTES > 1
buf[1]=v>>8;
#endif
#if RAND_BYTES > 2
buf[2]=v>>16;
#endif
#if RAND_BYTES > 4
buf[3]=v>>24;
#endif
}
v=rand();
switch(end-buf){
case 3:
#if RAND_BYTES > 2
buf[2]=v>>16;
#else
buf[2]=rand();
#endif
case 2:
#if RAND_BYTES > 1
buf[1]=v>>8;
#else
buf[1]=rand();
#endif
case 1:
buf[0]=v;
case 0:
break;
}
}
int main(int argc, char** argv)
{
int loops, min_len, max_len, offset, e_offset;
unsigned char* ibuf;
unsigned char* enc_buf;
unsigned char* dec_buf;
int ibuf_len, enc_buf_len, dec_buf_len;
int offs, c_len, e_len, l;
int r;
int verbose;
int c;
char* tmp;
verbose=0;
min_len=max_len=offset=-1;
e_offset=0;
loops=1024;
opterr=0;
while ((c=getopt(argc, argv, "n:m:M:o:e:vhV"))!=-1){
switch(c){
case 'n':
loops=strtol(optarg, &tmp, 0);
if ((tmp==0)||(*tmp)||(loops<0)){
fprintf(stderr, "bad number: -%c %s\n", c, optarg);
goto error;
}
break;
case 'm':
min_len=strtol(optarg, &tmp, 0);
if ((tmp==0)||(*tmp)||(min_len<0)){
fprintf(stderr, "bad number: -%c %s\n", c, optarg);
goto error;
}
break;
case 'M':
max_len=strtol(optarg, &tmp, 0);
if ((tmp==0)||(*tmp)||(max_len<0)){
fprintf(stderr, "bad number: -%c %s\n", c, optarg);
goto error;
}
break;
case 'o':
offset=strtol(optarg, &tmp, 0);
if ((tmp==0)||(*tmp)||(offset<0)){
fprintf(stderr, "bad number: -%c %s\n", c, optarg);
goto error;
}
break;
case 'e':
e_offset=strtol(optarg, &tmp, 0);
if ((tmp==0)||(*tmp)||(e_offset<0)){
fprintf(stderr, "bad number: -%c %s\n", c, optarg);
goto error;
}
break;
case 'v':
verbose++;
break;
case 'V':
printf("version: %s\n", version);
printf("%s\n", id);
exit(0);
break;
case 'h':
printf("version: %s\n", version);
printf("%s", help_msg);
exit(0);
break;
case '?':
if (isprint(optopt))
fprintf(stderr, "Unknown option `-%c\n", optopt);
else
fprintf(stderr, "Unknown character `\\x%x\n", optopt);
goto error;
case ':':
fprintf(stderr, "Option `-%c requires an argument.\n",
optopt);
goto error;
break;
default:
abort();
}
}
if (min_len==-1 && max_len==-1){
min_len=0;
max_len=4*1024*1024;
}else if (min_len==-1)
min_len=0;
else if (max_len==-1)
max_len=min_len;
/* init */
ibuf_len=max_len;
ibuf=malloc(ibuf_len);
if (ibuf==0){
fprintf(stderr, "ERROR: 1. memory allocation error (%d bytes)\n",
ibuf_len);
exit(-1);
}
enc_buf_len=B_ENC_LEN(ibuf_len);
enc_buf=malloc(enc_buf_len+e_offset);
if (enc_buf==0){
fprintf(stderr, "ERROR: 2. memory allocation error (%d bytes)\n",
enc_buf_len);
exit(-1);
}
enc_buf+=e_offset; /* make sure it's off by e_offset bytes from the
aligned stuff malloc returns */
dec_buf_len=ibuf_len;
dec_buf=malloc(dec_buf_len+e_offset);
if (dec_buf==0){
fprintf(stderr, "ERROR: 3. memory allocation error (%d bytes)\n",
dec_buf_len+e_offset);
exit(-1);
}
dec_buf+=e_offset; /* make sure it's off by e_offset bytes from the
aligned stuff malloc returns */
seed_prng();
/* profile */
profile_init(&pf1, "encode");
profile_init(&pf2, "decode");
init_basex();
if (verbose)
printf("starting (loops %d, min size %d, max size %d, offset %d,"
", e_offset %d, buffer sizes %d %d %d)\n",
loops, min_len, max_len, offset, e_offset, ibuf_len,
enc_buf_len, dec_buf_len);
for (r=0; r<loops; r++){
if (min_len!=max_len)
/* test encode/decode random data w/ random length*/
c_len= min_len+(int)((float)(max_len-min_len+1)*
(rand()/(RAND_MAX+1.0)));
else
/* test encode /decode random data w/ fixed lenght*/
c_len=max_len;
if (offset==-1)
/* offset between 0 & MIN(clen,3) */
offs= (int)((float)(MIN(c_len,3)+1)*(rand()/(RAND_MAX+1.0)));
else if (offset>c_len)
offs=0;
else
offs=offset;
if (verbose>2)
printf("loop %d, current len %d, offset %d, start %p\n",
r, c_len-offs, offs, &ibuf[offs]);
else if ((verbose >1) && (r %10==0)) putchar('.');
fill_rand(ibuf, c_len);
c_len-=offs;
e_len=B_ENC_LEN(c_len);
profile_start(&pf1);
l=B_ENC(&ibuf[offs], c_len, enc_buf, e_len);
profile_end(&pf1);
if (l != e_len){
fprintf(stderr, "ERROR: invalid length for encoding: %d "
"instead of %d (loops=%d)\n", l, e_len, r);
exit(-1);
}
profile_start(&pf2);
l=B_DEC(enc_buf, e_len, dec_buf, c_len);
profile_end(&pf2);
if (l != c_len){
fprintf(stderr, "ERROR: invalid length for decoding: %d "
"instead of %d (loops=%d)\n", l, c_len, r);
exit(-1);
}
if (memcmp(&ibuf[offs], dec_buf, c_len)!=0){
fprintf(stderr, "ERROR: decoding mismatch "
"(loops=%d, c_len=%d)\n", r, c_len);
abort();
exit(-1);
}
}
if (verbose >1) putchar('\n');
/* encode len data and decode it, print profiling info*/
dump_profile_info(&pf1);
dump_profile_info(&pf2);
return 0;
error:
exit(-1);
}

@ -0,0 +1,60 @@
# test results for basex.c
pentium-m (core2):
gcc -g -Wall -O9 -mtune=pentium-m -mcpu=pentium-m -D__CPU_x86 ${DEFS} \
../basex.c basex.c -o basex
4 8 16 32 40 64 80 128
lookup:
base16_enc4 83 96 125 177 205 291 345 509
base16_dec4
base16_enc 79 97 150 208 240 326 390 559
base16_dec 76 96 152 217 249 350 402 588
lookup(DEFS=-DBASEX=BASE64)::
base16_enc4 211
base16_dec4 252
base16_enc 231
base16_dec 251
lookup_Large (DEFS=-DBASE16_LOOKUP_LARGE -DBASEX=BASE64):
base16_enc4 218
base16_dec4 236
base16_enc 199
base16_dec 236
no lookup (DEFS=NO_BASE64_LOOKUP_TABLE -DBASEX=BASE64):
base64_enc 156 1005
181 1242
lookup (DEFS=-DBASEX=BASE64):
base64_enc 82 101 120 185 209 302 335 521
base64_dec 89 103 140 198 208 289 359 546
lookup_large (DEFS=-DBASE64_LOOKUP_LARGE -DBASEX=BASE64):
base64_enc 79 85 103 157 186 268 276 421
base64_dec 93 103 126 188 207 281 348 510
lookup_8k (DEFS=-DBASE64_LOOKUP_8K -DBASEX=BASE64), -e 1
base64_enc 77 94 177 422
lookup_8k words (like above but -e 0)
base64_enc 77 156 329
ultrasparc:
gcc -g -Wall -O9 -mtune=ultrasparc -mcpu=ultrasparc -D__CPU_sparc64 ${DEFS} \
../basex.c basex.c -o basex
no lookup (DEFS=-DNO_BASE64_LOOKUP_TABLE -DBASEX=BASE64):
base64_enc 728
1425
lookup (DEFS=-DBASEX=BASE64):
base64_enc 314
260
lookup_large (DEFS=-DBASE64_LOOKUP_LARGE -DBASEX=BASE64):
base64_enc 295
lookup_8k (DEFS=-DBASE64_LOOKUP_8K -DBASEX=BASE64), -e 1
base64_enc 323
250
lookup_8k words (like above but -e 0)
base64_enc 91 118 296
101 117 249

@ -0,0 +1,10 @@
BYE sip:211111948@195.37.77.101;transport=tcp;r2=on;ftag=e495220a31344eb39a6bf44ee3b01303;lr=on SIP/2.0
Max-Forwards: 10
Via: SIP/2.0/UDP 192.246.69.223;branch=z9hG4bK1ac2.64b19ee4.0
From: <sip:xxx@iptel.org>;tag=as38468f70
To: "christian@iptel.org" <sip:christian@iptel.org>;tag=e495220a31344eb39a6bf44ee3b01303;epid=f15c896fef
Contact: <sip:404@65.39.205.112:5028>
Call-ID: axxxxxef5cec10dd5f4dca871b764cb83ee73c@192.168.1.100
CSeq: 102 BYE
Content-Length: 0

@ -0,0 +1,207 @@
/* $Id$
*
* test bit_scan operations from bit_scan.h
* (both for correctness and speed)
*
* Copyright (C) 2007 iptelorg GmbH
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Example gcc command line:
* gcc -O9 -Wall -DCC_GCC_LIKE_ASM -D__CPU_x86 bit_scan_test.c ../bit_scan.c
* -o bit_scan_test
*
* History:
* --------
* 2007-06-23 created by andrei
*/
#include <stdlib.h>
#include <stdio.h>
#define BIT_SCAN_DEBRUIJN
#define BIT_SCAN_BRANCH
#define BIT_SCAN_SLOW
#include "../bit_scan.h"
#ifdef NO_PROFILE
#define profile_init(x,y) do{}while(0)
#define profile_start(x) do{}while(0)
#define profile_end(x) do{}while(0)
#define PROFILE_PRINT(x) do{}while(0)
#else
#include "profile.h"
#endif
#define CHECK(txt, v1, val, f, pd) \
do{ \
unsigned long long ret; \
profile_start(pd); \
ret=(unsigned long long)f(val); \
profile_end(pd); \
if ((unsigned long long)v1!=ret){ \
fprintf(stderr, "ERROR:" #f ": %s, expected %llx (%llx), got"\
" %llx\n", \
(txt), (unsigned long long)v1, \
(unsigned long long)val, ret); \
exit(-1); \
} \
}while(0)
#ifndef PROFILE_PRINT
#define PROFILE_PRINT(pd) \
do{ \
printf("profile: %s (%ld/%ld) total %llu max %llu average %llu\n", \
(pd)->name, (pd)->entries, (pd)->exits, \
(pd)->total_cycles, (pd)->max_cycles, \
(pd)->entries? \
(pd)->total_cycles/(unsigned long long)(pd)->entries:0ULL ); \
}while(0)
#endif
int main(int argc, char** argv)
{
int r;
unsigned int v;
unsigned long long ll;
int i;
#ifndef NO_PROFILE
struct profile_data pdf1, pdf2, pdf4, pdf5, pdf6, pdf8;
struct profile_data pdl1, pdl2, pdl4, pdl5, pdl6, pdl8;
#ifdef HAS_BIT_SCAN_ASM
struct profile_data pdf3, pdf7, pdl3, pdl7;
#endif
struct profile_data pdf_32, pdf_64, pdl_32, pdl_64;
struct profile_data pdf_long, pdl_long;
#endif /* NO_PROFILE */
profile_init(&pdf1, "first_debruijn32");
profile_init(&pdf2, "first_slow32");
#ifdef HAS_BIT_SCAN_ASM
profile_init(&pdf3, "first_asm32");
#endif
profile_init(&pdf4, "first_br32");
profile_init(&pdf5, "first_debruijn64");
profile_init(&pdf6, "first_slow64");
#ifdef HAS_BIT_SCAN_ASM
profile_init(&pdf7, "first_asm64");
#endif
profile_init(&pdf8, "first_br64");
profile_init(&pdl1, "last_debruijn32");
profile_init(&pdl2, "last_slow32");
#ifdef HAS_BIT_SCAN_ASM
profile_init(&pdl3, "last_asm32");
#endif
profile_init(&pdl4, "last_br32");
profile_init(&pdl5, "last_debruijn64");
profile_init(&pdl6, "last_slow64");
#ifdef HAS_BIT_SCAN_ASM
profile_init(&pdl7, "last_asm64");
#endif
profile_init(&pdl8, "last_br64");
profile_init(&pdf_32, "scan_forward32");
profile_init(&pdf_64, "scan_forward64");
profile_init(&pdl_32, "scan_reverse32");
profile_init(&pdl_64, "scan_reverse64");
profile_init(&pdf_long, "scan_forward_l");
profile_init(&pdl_long, "scan_reverse_l");
for (i=0; i<100; i++){
for (r=0; r<32; r++){
v=(1U<<r);
CHECK("first debruijn 32bit", r, v, bit_scan_forward_debruijn32, &pdf1);
CHECK("first slow 32bit", r, v, bit_scan_forward_slow32, &pdf2);
#ifdef HAS_BIT_SCAN_ASM
CHECK("first asm 32bit", r, v, bit_scan_forward_asm32, &pdf3);
#endif
CHECK("first br 32bit", r, v, bit_scan_forward_br32, &pdf4);
CHECK("scan_forward32", r, v, bit_scan_forward32, &pdf_32);
if (sizeof(long)<=4){
CHECK("scan_forward_l", r, v, bit_scan_forward, &pdf_long);
}
v+=(v-1);
CHECK("last debruijn 32bit", r, v, bit_scan_reverse_debruijn32, &pdl1);
CHECK("last slow 32bit", r, v, bit_scan_reverse_slow32, &pdl2);
#ifdef HAS_BIT_SCAN_ASM
CHECK("last asm 32bit", r, v, bit_scan_reverse_asm32, &pdl3);
#endif
CHECK("last br 32bit", r, v, bit_scan_reverse_br32, &pdl4);
CHECK("scan_reverse32", r, v, bit_scan_reverse32, &pdl_32);
if (sizeof(long)<=4){
CHECK("scan_reverse_l", r, v, bit_scan_reverse, &pdl_long);
}
}
for (r=0; r<64; r++){
ll=(1ULL<<r);
CHECK("first debruijn 64bit", r, ll, bit_scan_forward_debruijn64, &pdf5);
CHECK("first slow 64bit", r, ll, bit_scan_forward_slow64, &pdf6);
#ifdef HAS_BIT_SCAN_ASM
CHECK("first asm 64bit", r, ll, bit_scan_forward_asm64, &pdf7);
#endif
CHECK("first br 64bit", r, ll, bit_scan_forward_br64, &pdf8);
CHECK("scan_forward64", r, ll, bit_scan_forward64, &pdf_64);
if (sizeof(long)>4){
CHECK("scan_forward_l", r, ll, bit_scan_forward, &pdf_long);
}
ll+=ll-1;
CHECK("last debruijn 64bit", r, ll, bit_scan_reverse_debruijn64, &pdl5);
CHECK("last slow 64bit", r, ll, bit_scan_reverse_slow64, &pdl6);
#ifdef HAS_BIT_SCAN_ASM
CHECK("last asm 64bit", r, ll, bit_scan_reverse_asm64, &pdl7);
#endif
CHECK("last br 64bit", r, ll, bit_scan_reverse_br64, &pdl8);
CHECK("scan_reverse64", r, ll, bit_scan_reverse64, &pdl_64);
if (sizeof(long)>4){
CHECK("scan_reverse_l", r, ll, bit_scan_reverse, &pdl_long);
}
}
}
PROFILE_PRINT(&pdf1);
PROFILE_PRINT(&pdf2);
#ifdef HAS_BIT_SCAN_ASM
PROFILE_PRINT(&pdf3);
#endif
PROFILE_PRINT(&pdf4);
PROFILE_PRINT(&pdl1);
PROFILE_PRINT(&pdl2);
#ifdef HAS_BIT_SCAN_ASM
PROFILE_PRINT(&pdl3);
#endif
PROFILE_PRINT(&pdl4);
PROFILE_PRINT(&pdf5);
PROFILE_PRINT(&pdf6);
#ifdef HAS_BIT_SCAN_ASM
PROFILE_PRINT(&pdf7);
#endif
PROFILE_PRINT(&pdf8);
PROFILE_PRINT(&pdl5);
PROFILE_PRINT(&pdl6);
#ifdef HAS_BIT_SCAN_ASM
PROFILE_PRINT(&pdl7);
#endif
PROFILE_PRINT(&pdl8);
PROFILE_PRINT(&pdf_32);
PROFILE_PRINT(&pdf_64);
PROFILE_PRINT(&pdf_long);
PROFILE_PRINT(&pdl_32);
PROFILE_PRINT(&pdl_64);
PROFILE_PRINT(&pdl_long);
return 0;
}

@ -0,0 +1,2 @@
backtrace

@ -0,0 +1,14 @@
BYE sip:jiri@bat.iptel.org SIP/2.0
Max-Forwards: 0
Via: SIP/2.0/UDP 195.37.77.100;branch=df6250bb14ccda4a69dc0502173d02b2.e0e.0
Via: SIP/2.0/UDP 213.20.228.21:13671
From: "jiri" <sip:jiri@iptel.org>;tag=9c77afe9-71ec-4c52-a009-f2869fba848b
To: <sip:jiri@bat.iptel.org>;tag=9c77afe9-71ec-4c52-a009-f2869fba848b
Call-ID: bcd1134d-a36f-4647-ae9f-124c157d2db1@213.20.228.21
CSeq: 4 BYE
Contact: <sip:213.20.228.21:13671>
User-Agent: Windows RTC/10
Proxy-Authorization: Digest username="jiri", realm="iptel.org", algorithm="MD5", uri="sip:jiri@bat.iptel.org", nonce="3ceffa4400000001d587052d1c8c510923023da8846e64fa", response="daaa8ef489b5ac91420b8a818bf5581d"
Content-Length: 0

@ -0,0 +1,14 @@
BYE sip:christian@iptel.org SIP/2.0
Max-Forwards: 10
Record-Route: <sip:christian@192.246.69.223;ftag=as38468f70;lr=on>
Via: SIP/2.0/UDP 192.246.69.223;branch=z9hG4bK1ac2.64b19ee4.0
Via: SIP/2.0/UDP 65.39.205.112:5028;branch=z9hG4bK28091bb9
Route: <sip:211111948@195.37.77.101;r2=on;ftag=e495220a31344eb39a6bf44ee3b01303;lr=on>,<sip:211111948@195.37.77.101;transport=tcp;r2=on;ftag=e495220a31344eb39a6bf44ee3b01303;lr=on>
From: <sip:xxx@iptel.org>;tag=as38468f70
To: "christian@iptel.org" <sip:christian@iptel.org>;tag=e495220a31344eb39a6bf44ee3b01303;epid=f15c896fef
Contact: <sip:404@65.39.205.112:5028>
Call-ID: xxxef5cec10dd5f4dca871b764cb83ee73c@192.168.1.100
CSeq: 102 BYE
User-Agent: Asterisk PBX
Content-Length: 0

@ -0,0 +1,14 @@
# config file for centauri
route{
src_ip=~"testing" log("packet from fokus\n"); route(1);
/* drop all others */
}
route[1]{
(src_ip==192.168.46.0/24 or src_ip=~"^dorian") forward("fox.iptel.org");
src_ip=="centauri.fokus.gmd.de" log("Possible loop, dropping\n"); drop
src_ip==0.0.0.0/0 log("forwarding denied\n"); drop
}

@ -0,0 +1,24 @@
OPTIONS sip:henrxx@iptel.com SIP/2.0
Via: SIP/2.0/UDP 195.37.77.101:9
From: "GMD FOKUS iptlab" <sip:jiri@iptel.org>;tag=b96b0300ed30f1286-2f5d
Call-ID: b96b0300-88d30f-66da-63aa@195.37.78.190
CSeq: 101 OPTIONS
To: sip:tester@iptel.org
Expires: 180
Max-Forwards: 9
User-Agent: Cisco-SIP-IP-Phone/2
Accept: application/sdp
Contact: sip:jiri@195.37.78.190:5060
Content-Type: application/sdp
Content-Length: 225
v=0
o=CiscoSystemsSIP-IPPhone-UserAgent 14474 8233 IN IP4 195.37.78.190
s=SIP Call
c=IN IP4 195.37.78.190
t=0 0
m=audio 18456 RTP/AVP 0 8 18 101
a=rtpmap:0 pcmu/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11

@ -0,0 +1,221 @@
/*
* $Id$
*
* tests for ../resolver.c
*
* Compile with:
* gcc -o dns_query2 dns_query.c ../resolve.o ../dprint.o ../mem/ *.o -lresolv
* (and first compile ser with qm_malloc)
*
*
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of ser, a free SIP server.
*
* ser 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
*
* For a license to use the ser software under conditions
* other than those described here, or to purchase support for this
* software, please contact iptel.org by e-mail at the following addresses:
* info@iptel.org
*
* ser 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
*/
/*
* tester for ser resolver (andrei) */
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include "../resolve.h"
#include "../mem/q_malloc.h"
/* symbols needed by dprint */
int log_stderr=1;
int debug=0;
int pids[1];
int process_no=0;
long shm_mem_size=0;
char mem_pool[1024*1024];
struct qm_block* mem_block;
int log_facility=0;
int memlog=0;
int memdbg=0;
int ser_error=0;
struct process_table* pt=0;
static char* id="$Id$";
static char* version="dns_query 0.1";
static char* help_msg="\
Usage: dns_query [-t type] [-hV] -n host\n\
Options:\n\
-n host host name\n\
-t type query type (default A)\n\
-V version number\n\
-h this help message\n\
";
int main(int argc, char** argv)
{
char c;
char* name;
char* type_str;
int type;
int r;
struct rdata* head;
struct rdata* l;
struct srv_rdata* srv;
struct naptr_rdata* naptr;
struct a_rdata* ip;
name=type_str=0;
opterr=0;
while ((c=getopt(argc, argv, "n:t:hV"))!=-1){
switch(c){
case 'n':
name=optarg;
break;
case 't':
type_str=optarg;
break;
case 'V':
printf("version: %s\n", version);
printf("%s\n", id);
exit(0);
break;
case 'h':
printf("version: %s\n", version);
printf("%s", help_msg);
exit(0);
break;
case '?':
if (isprint(optopt))
fprintf(stderr, "Unknown option `-%c´\n", optopt);
else
fprintf(stderr, "Unknown character `\\x%x´\n", optopt);
goto error;
case ':':
fprintf(stderr, "Option `-%c´ requires an argument.\n",
optopt);
goto error;
break;
default:
abort();
}
}
if (name==0){
fprintf(stderr, "Missing domain name (-n name)\n");
goto error;
}
type=T_A;
if (type_str){
if (strcasecmp(type_str, "A")==0) type=T_A;
else if (strcasecmp(type_str, "NS")==0) type=T_NS;
else if (strcasecmp(type_str, "MD")==0) type=T_MD;
else if (strcasecmp(type_str, "MF")==0) type=T_MF;
else if (strcasecmp(type_str, "CNAME")==0) type=T_CNAME;
else if (strcasecmp(type_str, "SOA")==0) type=T_SOA;
else if (strcasecmp(type_str, "PTR")==0) type=T_PTR;
else if (strcasecmp(type_str, "HINFO")==0) type=T_HINFO;
else if (strcasecmp(type_str, "MINFO")==0) type=T_MINFO;
else if (strcasecmp(type_str, "MX")==0) type=T_MX;
else if (strcasecmp(type_str, "TXT")==0) type=T_TXT;
else if (strcasecmp(type_str, "AAAA")==0) type=T_AAAA;
else if (strcasecmp(type_str, "SRV")==0) type=T_SRV;
else if (strcasecmp(type_str, "NAPTR")==0) type=T_NAPTR;
else if (strcasecmp(type_str, "AXFR")==0) type=T_AXFR;
else{
fprintf(stderr, "Unknown query type %s\n", type_str);
goto error;
}
}
/* init mallocs*/
mem_block=qm_malloc_init(mem_pool, 1024*1024);
printf("calling get_record...\n");
head=get_record(name, type);
if (head==0) printf("no answer\n");
else{
printf("records:\n");
for(l=head; l; l=l->next){
switch(l->type){
case T_SRV:
srv=(struct srv_rdata*)l->rdata;
printf("SRV type= %d class=%d ttl=%d\n",
l->type, l->class, l->ttl);
printf(" prio= %d weight=%d port=%d\n",
srv->priority, srv->weight, srv->port);
printf(" name_len= %d (%d), name= [%.*s]\n",
srv->name_len, strlen(srv->name),
srv->name_len, srv->name);
break;
case T_CNAME:
printf("CNAME type= %d class=%d ttl=%d\n",
l->type, l->class, l->ttl);
printf(" name=[%s]\n",
((struct cname_rdata*)l->rdata)->name);
break;
case T_A:
ip=(struct a_rdata*)l->rdata;
printf("A type= %d class=%d ttl=%d\n",
l->type, l->class, l->ttl);
printf(" ip= %d.%d.%d.%d\n",
ip->ip[0], ip->ip[1], ip->ip[2], ip->ip[3]);
break;
case T_AAAA:
printf("AAAA type= %d class=%d ttl=%d\n",
l->type, l->class, l->ttl);
printf(" ip6= ");
for(r=0;r<16;r++)
printf("%x ", ((struct aaaa_rdata*)l->rdata)->ip6[r]);
printf("\n");
break;
case T_NAPTR:
naptr=(struct naptr_rdata*)l->rdata;
printf("NAPTR type= %d class=%d ttl=%d\n",
l->type, l->class, l->ttl);
printf(" order= %d pref=%d\n",
naptr->order, naptr->pref);
printf(" flags_len= %d, flags= [%.*s]\n",
naptr->flags_len,
naptr->flags_len, naptr->flags);
printf(" services_len= %d, services= [%.*s]\n",
naptr->services_len,
naptr->services_len, naptr->services);
printf(" regexp_len= %d, regexp= [%.*s]\n",
naptr->regexp_len,
naptr->regexp_len, naptr->regexp);
printf(" repl_len= %d, repl= [%s]\n",
naptr->repl_len, naptr->repl);
break;
default:
printf("UNKN type= %d class=%d ttl=%d\n",
l->type, l->class, l->ttl);
printf(" rdata=%p\n", l->rdata);
}
}
}
printf("done\n");
exit(0);
error:
exit(-1);
}

@ -0,0 +1,54 @@
#
#
# $Id$
#
# echo: rewrite userpart or r-uri to value from From header field
#
debug=3 # debug level (cmd line: -dddddddddd)
fork=no
log_stderror=yes
memlog=4
check_via=no # (cmd. line: -v)
dns=no # (cmd. line: -r)
rev_dns=no # (cmd. line: -R)
port=5060
children=4
fifo="/tmp/ser_fifo"
listen=192.168.2.16
# ------------------ module loading ----------------------------------
# Uncomment this if you want to use SQL database
#loadmodule "/usr/local/lib/ser/modules/mysql.so"
loadmodule "modules/sl/sl.so"
loadmodule "modules/exec/exec.so"
route {
log(1, "request received\n");
if (method=="REGISTER") {
log(1, "register received\n");
sl_send_reply("200", "ok happy registratiion");
break;
};
if (exec_dset('
set -x
SIP_UID_FROM=`echo $SIP_HF_FROM | sed -e "s/^.*sip:\([a-zA-Z0-9_\.]*\)@.*$/\1/g"`
echo sip:$SIP_UID_FROM@vm04.foobar.com
echo sip:$SIP_UID_FROM@proxy01.foobar.com
echo>/dev/null ')) {
log(1, "trying to rewrite\n");
sl_send_reply("300", "redirect");
} else {
sl_send_reply("500", "exec error");
log(1, "alas, rewriting failed\n");
};
}

@ -0,0 +1,173 @@
/*
* $Id$
*
* Copyright (C) 2008 iptelorg GmbH
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* endianness.h tests
* compile/run with:
* gcc -Wall endian_test.c ../endianness.c -o endian_test; ./endian_test
*/
/*
* History:
* --------
* 2008-06-13 created by andrei
*/
/*
*
* Macro names:
* linux: __BYTE_ORDER == __LITTLE_ENDIAN | __BIG_ENDIAN
* BYTE_ORDER == LITTLE_ENDIAN | BIG_ENDIAN
* bsd: _BYTE_ORDER == _LITTLE_ENDIAN | _BIG_ENDIAN
* BYTE_ORDER == LITTLE_ENDIAN | BIG_ENDIAN
* solaris: _LITTLE_ENDIAN | _BIG_ENDIAN
*
* Note: BIG_ENDIAN, LITTLE_ENDIAN, _BIG_ENDIAN, _LITTLE_ENDIAN cannot be
* used always, some OSes define both of them for BYTE_ORDER use
* (e.g. linux defines both BIG_ENDIAN & LITTLE_ENDIAN, bsds define
* _BIG_ENDIAN, _LITTLE_ENDIAN, BIG_ENDIAN, LITTLE_ENDIAN)
*
* is sys/param.h universal ?
*/
#include <stdio.h>
#include "../endianness.h"
/*
* Tested:
* linux: y
* freebsd: y
* openbsd:
* netbsd:
* solaris: y
* darwin:
* cygwin:
*
* Header files:
* linux: <endian.h> , <sys/param.h>
* bsd: <sys/param.h> or <sys/endian.h>
* solaris: <sys/param.h>
* openbsd
* netbsd
* solaris
* cywin
*/
/*
*
* Macro names:
* linux: __BYTE_ORDER == __LITTLE_ENDIAN | __BIG_ENDIAN
* BYTE_ORDER == LITTLE_ENDIAN | BIG_ENDIAN
* bsd: _BYTE_ORDER == _LITTLE_ENDIAN | _BIG_ENDIAN
* BYTE_ORDER == LITTLE_ENDIAN | BIG_ENDIAN
* solaris: _LITTLE_ENDIAN | _BIG_ENDIAN
*
* Note: BIG_ENDIAN, LITTLE_ENDIAN, _BIG_ENDIAN, _LITTLE_ENDIAN cannot be
* used always, some OSes define both of them for BYTE_ORDER use
* (e.g. linux defines both BIG_ENDIAN & LITTLE_ENDIAN, bsds define
* _BIG_ENDIAN, _LITTLE_ENDIAN, BIG_ENDIAN, LITTLE_ENDIAN)
*
* is sys/param.h universal ?
*/
/* test only */
#if defined __BYTE_ORDER && defined __LITTLE_ENDIAN
#if __BYTE_ORDER == __LITTLE_ENDIAN
#warning little endian (via __BYTE_ORDER)
#define __BYTE_ORDER_FOUND
#endif
#endif
#if defined __BYTE_ORDER && defined __BIG_ENDIAN
#if __BYTE_ORDER == __BIG_ENDIAN
#warning big endian (via __BYTE_ORDER)
#define __BYTE_ORDER_FOUND
#endif
#endif
#if defined __BYTE_ORDER && !defined __BYTE_ORDER_FOUND
#error __BYTE_ORDER defined, but w/ a strange value
#endif
#if defined _BYTE_ORDER && defined _LITTLE_ENDIAN
#if _BYTE_ORDER == _LITTLE_ENDIAN
#warning little endian (via _BYTE_ORDER)
#define _BYTE_ORDER_FOUND
#endif
#endif
#if defined _BYTE_ORDER && defined _BIG_ENDIAN
#if _BYTE_ORDER == _BIG_ENDIAN
#warning big endian (via _BYTE_ORDER)
#define _BYTE_ORDER_FOUND
#endif
#endif
#if defined _BYTE_ORDER && !defined _BYTE_ORDER_FOUND
#error _BYTE_ORDER defined, but w/ a strange value
#endif
#if defined BYTE_ORDER && defined LITTLE_ENDIAN
#if BYTE_ORDER == LITTLE_ENDIAN
#warning little endian (via BYTE_ORDER)
#define BYTE_ORDER_FOUND
#endif
#endif
#if defined BYTE_ORDER && defined BIG_ENDIAN
#if BYTE_ORDER == BIG_ENDIAN
#warning big endian (via BYTE_ORDER)
#define BYTE_ORDER_FOUND
#endif
#endif
#if defined BYTE_ORDER && !defined BYTE_ORDER_FOUND
#error BYTE_ORDER defined, but w/ a strange value
#endif
#if defined _LITTLE_ENDIAN
#warning _LITTLE_ENDIAN defined
#endif
#if defined _BIG_ENDIAN
#warning _BIG_ENDIAN defined
#endif
#if defined LITTLE_ENDIAN
#warning LITTLE_ENDIAN defined
#endif
#if defined BIG_ENDIAN
#warning BIG_ENDIAN defined
#endif
int main(int argc, char** argv)
{
int ret;
ret=0;
if (endianness_sanity_check()!=0){
printf("ERROR: sanity checks failed\n");
ret=-1;
}
if (is_little_endian()){
#ifdef __IS_LITTLE_ENDIAN
printf("OK: little endian confirmed\n");
#else
printf("ERROR: macro claims BIG ENDIAN, but it's little\n");
return -1;
#endif
}else{
#ifdef __IS_BIG_ENDIAN
printf("OK: big endian confirmed\n");
#else
printf("ERROR: macro claims LITTLE ENDIAN, but it's big\n");
return -1;
#endif
}
return ret;
}

@ -0,0 +1,24 @@
/*
* Copyright (C) 2001-2004 FhG Fokus
*
* This file is part of ser, a free SIP server.
*
* ser 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.
*
* For a license to use the ser software under conditions
* other than those described here, or to purchase support for this
* software, please contact iptel.org by e-mail at the following addresses:
* info@iptel.org
*
* ser 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
*/

@ -0,0 +1,33 @@
#
# configuration for Stress testing
#
# $ID: $
#
debug=3 # debug level (cmd line: -dddddddddd)
#fork=yes # (cmd. line: -D)
fork=yes
fork=no
log_stderror=yes # (cmd line: -E)
#log_stderror=no # (cmd line: -E)
children=4
check_via=no # (cmd. line: -v)
dns=off # (cmd. line: -r)
rev_dns=off # (cmd. line: -R)
#port=5070
listen=10.0.0.179
#listen=127.0.0.1
#listen=192.168.57.33
loop_checks=0
# for more info: sip_router -h
#modules
route{
#forward(uri:host, uri:port);
forward(127.0.0.1, 5090);
}

@ -0,0 +1,17 @@
#!/bin/sh
#
# wrapper arroung gcc, that intercepts --version and reports instead
# $GCC_VERSION
#
if [ -n "$GCC_VERSION" ]; then
for o in $@; do
if [ "$o" = "--version" ] ; then
echo $GCC_VERSION
exit 0
fi
done
fi
gcc $@

@ -0,0 +1,26 @@
#!/bin/sh
# test make cfg with all the gcc versions in gcc_versions.txt
# should be run from the main sip-router directory
# Depends on: test/gcc_version.sh and test/gcc_versions.txt
if [ ! -e test/gcc_version.sh -o ! -r test/gcc_versions.txt -o ! -r Makefile ]
then
echo "ERROR: wrong path, this test must be run from the main"\
" sip-router directory"
exit 1
fi
while read v ; do
GCC_VERSION=$v make CC=test/gcc_version.sh cfg-defs >/dev/null
if [ $? -ne 0 -o ! -r config.mak ]; then
echo "ERROR: make cfg failed for version \"$v\""
exit 1
fi
COMPILER=`egrep -o -- "-DCOMPILER='\"[^\"' ]+ [2-9]\.[0-9]{1,2}(\.[0-9]{1,2})?\"'" config.mak`
if [ $? -ne 0 -o -z "$COMPILER" ]; then
echo "ERROR: bad ver: \"$v\" => `egrep -o -- "-DCOMPILER='[^']*'" config.mak`"
exit 1
fi
echo "ok: \"$v\" => $COMPILER"
done < test/gcc_versions.txt

@ -0,0 +1,25 @@
2.7.1
2.8.1
egcs-2.91.66
2.95.3
2.95.4
3.0.4
gcc (GCC) 3.2
gcc-3.2 (GCC) 3.2.3 (Debian)
gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1809)
gcc (GCC) 3.3.3 (NetBSD nb3 20040520)
gcc (GCC) 3.3.5 (propolice)
gcc-3.3 (GCC) 3.3.5 (Debian 1:3.3.5-6)
gcc-3.3 (GCC) 3.3.5 (Debian 1:3.3.5-13)
gcc (GCC) 3.4.2 [FreeBSD] 20040728
gcc (GCC) 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
gcc-3.4 (GCC) 3.4.4 20041218 (prerelease) (Debian 3.4.3-7)
powerpc-apple-darwin8-gcc-3.5.0 (GCC) 3.5.0 20041026 (Apple Computer, Inc. build 4059)
powerpc-apple-darwin8-gcc-4.0.0 (GCC) 4.0.0 20041026 (Apple Computer, Inc. build 4061)
gcc-4.0 (GCC) 4.0.2 20050821 (prerelease) (Debian 4.0.1-6)
gcc-4.0 (GCC) 4.0.4 20060904 (prerelease) (Debian 4.0.3-7)
gcc-4.0.1 (GCC) 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)
gcc-4.1 (GCC) 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)
gcc-4.2 (GCC) 4.2.4 (Debian 4.2.4-6)
gcc-4.3 (Debian 4.3.3-8) 4.3.3
gcc (SUSE Linux) 4.3.2 [gcc-4_3-branch revision 141291]

@ -0,0 +1,43 @@
#
# configuration for Stress testing
#
# $ID: $
#
debug=9 # debug level (cmd line: -dddddddddd)
#fork=yes # (cmd. line: -D)
fork=no
log_stderror=yes # (cmd line: -E)
#log_stderror=no # (cmd line: -E)
children=4
check_via=no # (cmd. line: -v)
dns=off # (cmd. line: -r)
rev_dns=off # (cmd. line: -R)
#port=5070
#listen=10.0.0.179
#listen=192.168.57.33
loop_checks=0
# for more info: sip_router -h
#modules
#loadmodule "modules/print/print.so"
loadmodule "modules/textops/textops.so"
loadmodule "modules/tm/tm.so"
loadmodule "modules/maxfwd/maxfwd.so"
loadmodule "modules/sl/sl.so"
route{
sl_filter_ACK();
if ( !mf_process_maxfwd_header("10") )
{
sl_send_reply("483","To Many Hops");
drop();
};
t_relay();
}

@ -0,0 +1,113 @@
/*
* $Id$
*
*
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of ser, a free SIP server.
*
* ser 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
*
* For a license to use the ser software under conditions
* other than those described here, or to purchase support for this
* software, please contact iptel.org by e-mail at the following addresses:
* info@iptel.org
*
* ser 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
*/
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <netdb.h>
static char* id="$Id$";
static char* version="gethostbyaddr 0.1";
static char* help_msg="\
Usage: gethostbyaddr [-hV] -n host\n\
Options:\n\
-n host host name\n\
-V version number\n\
-h this help message\n\
";
int main(int argc, char** argv)
{
char c;
char* name;
struct hostent* he;
unsigned char** h;
name=0;
opterr=0;
while ((c=getopt(argc, argv, "n:hV"))!=-1){
switch(c){
case 'n':
name=optarg;
break;
case 'V':
printf("version: %s\n", version);
printf("%s\n", id);
exit(0);
break;
case 'h':
printf("version: %s\n", version);
printf("%s", help_msg);
exit(0);
break;
case '?':
if (isprint(optopt))
fprintf(stderr, "Unknown option `-%c´\n", optopt);
else
fprintf(stderr, "Unknown character `\\x%x´\n", optopt);
goto error;
case ':':
fprintf(stderr, "Option `-%c´ requires an argument.\n",
optopt);
goto error;
break;
default:
abort();
}
}
if (name==0){
fprintf(stderr, "Missing domain name (-n name)\n");
goto error;
}
he=gethostbyname(name);
if (he==0){
printf("bad address <%s>\n", name);
goto error;
}
he=gethostbyaddr(he->h_addr_list[0], he->h_length, he->h_addrtype);
if (he==0) printf("no answer\n");
else{
printf("h_name=%s\n", he->h_name);
for(h=he->h_aliases;*h;h++)
printf(" alias=%s\n", *h);
for(h=he->h_addr_list;*h;h++)
printf(" ip=%d.%d.%d.%d\n", (*h)[0],(*h)[1],(*h)[2],(*h)[3] );
}
printf("done\n");
exit(0);
error:
exit(-1);
}

@ -0,0 +1,108 @@
/*
* $Id$
*
*
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of ser, a free SIP server.
*
* ser 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
*
* For a license to use the ser software under conditions
* other than those described here, or to purchase support for this
* software, please contact iptel.org by e-mail at the following addresses:
* info@iptel.org
*
* ser 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
*/
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <netdb.h>
static char* id="$Id$";
static char* version="gethostbyname 0.1";
static char* help_msg="\
Usage: gethostbyname [-hV] -n host\n\
Options:\n\
-n host host name\n\
-V version number\n\
-h this help message\n\
";
int main(int argc, char** argv)
{
char c;
char* name;
struct hostent* he;
unsigned char** h;
name=0;
opterr=0;
while ((c=getopt(argc, argv, "n:hV"))!=-1){
switch(c){
case 'n':
name=optarg;
break;
case 'V':
printf("version: %s\n", version);
printf("%s\n", id);
exit(0);
break;
case 'h':
printf("version: %s\n", version);
printf("%s", help_msg);
exit(0);
break;
case '?':
if (isprint(optopt))
fprintf(stderr, "Unknown option `-%c´\n", optopt);
else
fprintf(stderr, "Unknown character `\\x%x´\n", optopt);
goto error;
case ':':
fprintf(stderr, "Option `-%c´ requires an argument.\n",
optopt);
goto error;
break;
default:
abort();
}
}
if (name==0){
fprintf(stderr, "Missing domain name (-n name)\n");
goto error;
}
he=gethostbyname(name);
if (he==0) printf("no answer\n");
else{
printf("h_name=%s\n", he->h_name);
for(h=he->h_aliases;*h;h++)
printf(" alias=%s\n", *h);
for(h=he->h_addr_list;*h;h++)
printf(" ip=%d.%d.%d.%d\n", (*h)[0],(*h)[1],(*h)[2],(*h)[3] );
}
printf("done\n");
exit(0);
error:
exit(-1);
}

@ -0,0 +1,6 @@
#!/bin/sh
for i in `find . -name '*.[hc]'` ; do
mv $i $i.pregpl
awk -f test/gplize.awk $i.pregpl > $i
done

@ -0,0 +1,62 @@
# add copyright banner after the first comment
#
# text taken from file_copyright.txt
BEGIN {
status=0;
}
status==1 {
print
next
}
# end of comment not encountered yet
{ comment_begin=0 }
/\/\*/ { comment_begin=1; }
/\*\// {
status=1
# if it was a one-line comment print it and start a new comment
if (comment_begin==1) {
print
print "/*"
}
print " *"
print " * Copyright (C) 2001-2004 FhG Fokus"
print " *"
print " * This file is part of ser, a free SIP server."
print " *"
print " * ser is free software; you can redistribute it and/or modify"
print " * it under the terms of the GNU General Public License as published by"
print " * the Free Software Foundation; either version 2 of the License, or"
print " * (at your option) any later version"
print " *"
print " * For a license to use the ser software under conditions"
print " * other than those described here, or to purchase support for this"
print " * software, please contact iptel.org by e-mail at the following addresses:"
print " * info@iptel.org"
print " *"
print " * ser is distributed in the hope that it will be useful,"
print " * but WITHOUT ANY WARRANTY; without even the implied warranty of"
print " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
print " * GNU General Public License for more details."
print " *"
print " * You should have received a copy of the GNU General Public License "
print " * along with this program; if not, write to the Free Software "
print " * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"
print " */"
print ""
# don't print the original end of comment
next
}
# end of comment not encountered yet -- print the line
{ print }

@ -0,0 +1,350 @@
/* $Id$
*
*
* test programs, list all interfaces and their ip address
*
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of ser, a free SIP server.
*
* ser 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
*
* For a license to use the ser software under conditions
* other than those described here, or to purchase support for this
* software, please contact iptel.org by e-mail at the following addresses:
* info@iptel.org
*
* ser 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
*/
/*
* History:
* --------
* 2002-09-09 created by andrei
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <net/if.h>
#ifdef __sun__
#include <sys/sockio.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#define FLAGS 1
#define IF_DOWN 2
#define IF_UP 4
static char* version="ifls 0.1";
static char* id="$Id$";
static char* help_msg="\
Usage: ifls [-6hV} [interface...]\n\
(if no interface name is specified it will list all the interfaces)\n\
Options:\n\
-a list both ipv4 and ipv6 interfaces (default)\n\
-4 list only ipv4 interfaces\n\
-6 list only ipv6 interfaces\n\
-f show also the interface flags\n\
-U brings all the matching interfaces up\n\
-D brings all the matching interfaces down\n\
-V version number\n\
-h this help message\n\
";
#define MAX(a,b) ( ((a)>(b))?(a):(b))
void print_sockaddr(struct sockaddr* sa)
{
unsigned char* buf;
int r;
switch(sa->sa_family){
case AF_INET:
buf=(char*)&(((struct sockaddr_in*)sa)->sin_addr).s_addr;
printf("%d.%d.%d.%d\n", buf[0], buf[1], buf[2], buf[3]);
break;
case AF_INET6:
buf=(((struct sockaddr_in6*)sa)->sin6_addr).s6_addr;
for(r=0; r<16; r++)
printf("%02x%s", buf[r], ((r%2)&&(r!=15))?":":"" );
printf("\n");
break;
default:
printf("unknown af %d\n", sa->sa_family);
#ifdef __FreeBSD__
for (r=0; r<sa->sa_len; r++)
printf("%02x ", ((unsigned char*)sa)[r]);
printf("\n");
#endif
}
}
int ls_ifflags(char* name, int family , int options)
{
struct ifreq ifr;
int s;
memset(&ifr, 0, sizeof(ifr)); /* init to 0 (check if filled)*/
s=socket(family, SOCK_DGRAM, 0);
strncpy(ifr.ifr_name, name, IFNAMSIZ);
#if 0
if (ioctl(s, SIOCGIFADDR, &ifr)==-1){
if(errno==EBADF) return 0; /* invalid descriptor => no address*/
fprintf(stderr, "ls_if: ioctl for %s failed: %s\n", name,
strerror(errno));
goto error;
};
printf("%s:\n", ifr.ifr_name);
printf(" dbg: family=%d", ifr.ifr_addr.sa_family);
#ifdef __FreeBSD__
printf(", len=%d\n", ifr.ifr_addr.sa_len);
#else
printf("\n");
#endif
if (ifr.ifr_addr.sa_family==0){
printf("ls_if: OS BUG: SIOCGIFADDR doesn't work!\n");
goto error;
}
printf(" ");
print_sockaddr(&ifr.ifr_addr);
if (ifr.ifr_addr.sa_family!=family){
printf("ls_if: strange family %d\n", ifr.ifr_addr.sa_family);
/*goto error;*/
}
#endif
if (options & (FLAGS|IF_DOWN|IF_UP)){
if (ioctl(s, SIOCGIFFLAGS, &ifr)==-1){
fprintf(stderr, "ls_if: flags ioctl for %s failed: %s\n",
name, strerror(errno));
goto error;
}
if (ifr.ifr_flags & IFF_UP) printf ("UP ");
if (ifr.ifr_flags & IFF_BROADCAST) printf ("BROADCAST ");
if (ifr.ifr_flags & IFF_DEBUG) printf ("DEBUG ");
if (ifr.ifr_flags & IFF_LOOPBACK) printf ("LOOPBACK ");
if (ifr.ifr_flags & IFF_POINTOPOINT) printf ("POINTOPOINT ");
if (ifr.ifr_flags & IFF_RUNNING) printf ("RUNNING ");
if (ifr.ifr_flags & IFF_NOARP) printf ("NOARP ");
if (ifr.ifr_flags & IFF_PROMISC) printf ("PROMISC ");
/*if (ifr.ifr_flags & IFF_NOTRAILERS) printf ("NOTRAILERS ");*/
if (ifr.ifr_flags & IFF_ALLMULTI) printf ("ALLMULTI ");
/*if (ifr.ifr_flags & IFF_MASTER) printf ("MASTER ");*/
/*if (ifr.ifr_flags & IFF_SLAVE) printf ("SLAVE ");*/
if (ifr.ifr_flags & IFF_MULTICAST) printf ("MULTICAST ");
/*if (ifr.ifr_flags & IFF_PORTSEL) printf ("PORTSEL ");*/
/*if (ifr.ifr_flags & IFF_AUTOMEDIA) printf ("AUTOMEDIA ");*/
/*if (ifr.ifr_flags & IFF_DYNAMIC ) printf ("DYNAMIC ");*/
printf ("\n");
if (options & IF_DOWN){
ifr.ifr_flags &= ~IFF_UP;
}
if (options & IF_UP){
ifr.ifr_flags |= IFF_UP;
}
if (options & (IF_UP|IF_DOWN)){
if (ioctl(s, SIOCSIFFLAGS, &ifr)==-1){
fprintf(stderr, "ls_if: set flags ioctl for %s failed: %s\n",
name, strerror(errno));
goto error;
}
}
};
close(s);
return 0;
error:
close(s);
return -1;
}
int ls_ifs(char* name, int family, int options)
{
struct ifconf ifc;
struct ifreq* ifr;
char* last;
int size;
int lastlen;
int s;
/* ipv4 or ipv6 only*/
s=socket(family, SOCK_DGRAM, 0);
lastlen=0;
for (size=2; ; size*=2){
ifc.ifc_len=size*sizeof(struct ifreq);
ifc.ifc_req=(struct ifreq*) malloc(size*sizeof(struct ifreq));
if (ifc.ifc_req==0){
fprintf(stderr, "memory allocation failure\n");
goto error;
}
if (ioctl(s, SIOCGIFCONF, &ifc)==-1){
if(errno==EBADF) return 0; /* invalid descriptor => no such ifs*/
fprintf(stderr, "ioctl failed: %s\n", strerror(errno));
goto error;
}
if ((lastlen) && (ifc.ifc_len==lastlen)) break; /*success,
len not changed*/
lastlen=ifc.ifc_len;
/* try a bigger array*/
free(ifc.ifc_req);
}
last=(char*)ifc.ifc_req+ifc.ifc_len;
for(ifr=ifc.ifc_req; (char*)ifr<last;
ifr=(struct ifreq*)((char*)ifr+sizeof(ifr->ifr_name)+
#ifdef __FreeBSD__
MAX(ifr->ifr_addr.sa_len, sizeof(struct sockaddr))
#else
( (ifr->ifr_addr.sa_family==AF_INET)?
sizeof(struct sockaddr_in):
((ifr->ifr_addr.sa_family==AF_INET6)?
sizeof(struct sockaddr_in6):sizeof(struct sockaddr)) )
#endif
)
)
{
/*
printf("\nls_all dbg: %s family=%d", ifr->ifr_name,
ifr->ifr_addr.sa_family);
#ifdef __FreeBSD__
printf(", len=%d\n", ifr->ifr_addr.sa_len);
#else
printf("\n");
#endif
*/
if (ifr->ifr_addr.sa_family!=family){
/*printf("strange family %d skipping...\n",
ifr->ifr_addr.sa_family);*/
continue;
}
if ((name==0)||
(strncmp(name, ifr->ifr_name, sizeof(ifr->ifr_name))==0)){
printf("%s:\n", ifr->ifr_name);
printf(" ");
print_sockaddr(&(ifr->ifr_addr));
printf(" ");
ls_ifflags(ifr->ifr_name, family, options);
printf("\n");
}
}
free(ifc.ifc_req); /*clean up*/
close(s);
return 0;
error:
close(s);
return -1;
}
int main(int argc, char**argv)
{
char** name;
int no;
int options;
int ipv6, ipv4;
int r;
char c;
options=0;
ipv6=ipv4=1;
name=0;
no=0;
opterr=0;
while((c=getopt(argc, argv, "a46fhVUD"))!=-1){
switch(c){
case 'a':
ipv6=ipv4=1;
break;
case '4':
ipv6=0;
ipv4=1;
break;
case '6':
ipv4=0;
ipv6=1;
break;
case 'f':
options|=FLAGS;
break;
case 'V':
printf("version: %s\n", version);
printf("%s\n", id);
exit(0);
break;
case 'D':
options|=IF_DOWN;
break;
case 'U':
options|=IF_UP;
break;
case 'h':
printf("version: %s\n", version);
printf("%s", help_msg);
exit(0);
break;
case '?':
if (isprint(optopt))
fprintf(stderr, "Unknown option `-%c´\n", optopt);
else
fprintf(stderr, "Unknown character `\\x%x´\n", optopt);
goto error;
case ':':
fprintf(stderr, "Option `-%c´ requires an argument\n",
optopt);
goto error;
default:
abort();
};
};
/* check if we have non-options */
if( optind < argc){
no=argc-optind;
name=&argv[optind];
}
if (no==0){
/* list all interfaces */
if (ipv4) ls_ifs(0, AF_INET, options);
if (ipv6) ls_ifs(0, AF_INET6, options);
}else{
for(r=0; r<no; r++){
if (ipv4) ls_ifs(name[r], AF_INET, options);
if (ipv6) ls_ifs(name[r], AF_INET6, options);
}
};
exit(0);
error:
exit(-1);
};

@ -0,0 +1,21 @@
INVITE sip:andrei@mobile69 SIP/2.0
Via: SIP/2.0/UDP dorian.fokus.gmd.de
From: "test" <sip:andrei@iptel.org>;tag=b96b0300ed30f1286-2f5d
Call-ID: b96b0300-88d30f-66da-63aa@195.37.78.190
CSeq: 101 INVITE
Expires: 180
Max-Forwards: 0
User-Agent: testing lookups
Accept: application/sdp
Content-Length: 225
v=0
o=CiscoSystemsSIP-IPPhone-UserAgent 14474 8233 IN IP4 195.37.78.190
s=SIP Call
c=IN IP4 195.37.78.190
t=0 0
m=audio 18456 RTP/AVP 0 8 18 101
a=rtpmap:0 pcmu/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11

@ -0,0 +1,33 @@
INVITE sip:7170@iptel.org SIP/2.0
Via: SIP/2.0/UDP 195.37.77.100:5040; rport
Max-Forwards: 10
From: "jiri" <sip:jiri@iptel.org>;tag=76ff7a07-c091-4192-84a0-d56e91fe104f
To: <sip:jiri@bat.iptel.org>
Call-ID: d10815e0-bf17-4afa-8412-d9130a793d96@213.20.128.35
CSeq: 2 INVITE
Contact: <sip:213.20.128.35:9315>
User-Agent: Windows RTC/1.0
Proxy-Authorization: Digest username="jiri", realm="iptel.org", algorithm="MD5", uri="sip:jiri@bat.iptel.org", nonce="3cef753900000001771328f5ae1b8b7f0d742da1feb5753c", response="53fe98db10e1074b03b3e06438bda70f"
Content-Type: application/sdp
Content-Length: 451
v=0
o=jku2 0 0 IN IP4 213.20.128.35
s=session
c=IN IP4 213.20.128.35
b=CT:1000
t=0 0
m=audio 54742 RTP/AVP 97 111 112 6 0 8 4 5 3 101
a=rtpmap:97 red/8000
a=rtpmap:111 SIREN/16000
a=fmtp:111 bitrate=16000
a=rtpmap:112 G7221/16000
a=fmtp:112 bitrate=24000
a=rtpmap:6 DVI4/16000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:5 DVI4/8000
a=rtpmap: 3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16

@ -0,0 +1,33 @@
INVITE sip:7271@iptel.org SIP/2.0
Via: SIP/2.0/UDP 195.37.77.100:5040
Max-Forwards: 10
From: "jiri" <sip:jiri@iptel.org>;tag=76ff7a07-c091-4192-84a0-d56e91fe104f
To: <sip:jiri@bat.iptel.org>
Call-ID: d10815e0-bf17-4afa-8412-d9130a793d96@213.20.128.35
CSeq: 2 INVITE
Contact: <sip:213.20.128.35:9315>
User-Agent: Windows RTC/1.0
Proxy-Authorization: Digest username="jiri", realm="iptel.org", algorithm="MD5", uri="sip:jiri@bat.iptel.org", nonce="3cef753900000001771328f5ae1b8b7f0d742da1feb5753c", response="53fe98db10e1074b03b3e06438bda70f"
Content-Type: application/sdp
Content-Length: 452
v=0
o=jku2 0 0 IN IP4 213.20.128.35
s=session
c=IN IP4 213.20.128.35
b=CT:1000
t=0 0
m=audio 54742 RTP/AVP 97 111 112 6 0 8 4 5 3 101
a=rtpmap:97 red/8000
a=rtpmap:111 SIREN/16000
a=fmtp:111 bitrate=16000
a=rtpmap:112 G7221/16000
a=fmtp:112 bitrate=24000
a=rtpmap:6 DVI4/16000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:5 DVI4/8000
a=rtpmap: 3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16

@ -0,0 +1,33 @@
INVITE sip:7271@iptel.org SIP/2.0
Via: SIP/2.0/UDP 195.37.77.99:5040
Max-Forwards: 1
From: "jiri" <sip:jiri@iptel.org>;tag=76ff7a07-c091-4192-84a0-d56e91fe104f
To: <sip:jiri@bat.iptel.org>
Call-ID: r10815e0-bf17-4afa-8412-d9130a793d96@213.20.128.35
CSeq: 2 INVITE
Contact: <sip:213.20.128.35:9315>
User-Agent: Windows RTC/1.0
Proxy-Authorization: Digest username="jiri", realm="iptel.org", algorithm="MD5", uri="sip:jiri@bat.iptel.org", nonce="3cef753900000001771328f5ae1b8b7f0d742da1feb5753c", response="53fe98db10e1074b03b3e06438bda70f"
Content-Type: application/sdp
Content-Length: 451
v=0
o=jku2 0 0 IN IP4 213.20.128.35
s=session
c=IN IP4 213.20.128.35
b=CT:1000
t=0 0
m=audio 54742 RTP/AVP 97 111 112 6 0 8 4 5 3 101
a=rtpmap:97 red/8000
a=rtpmap:111 SIREN/16000
a=fmtp:111 bitrate=16000
a=rtpmap:112 G7221/16000
a=fmtp:112 bitrate=24000
a=rtpmap:6 DVI4/16000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:5 DVI4/8000
a=rtpmap: 3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16

@ -0,0 +1,33 @@
INVITE sip:7271@iptel.org SIP/2.0
Via: SIP/2.0/UDP 195.37.77.100:5040
Max-Forwards: 3
From: "jiri" <sip:jiri@iptel.org>;tag=76ff7a07-c091-4192-84a0-d56e91fe104f
To: <sip:jiri@bat.iptel.org>
Call-ID: r10815e0-bf17-4afa-8412-d9130a793d96@213.20.128.35
CSeq: 2 INVITE
Contact: <sip:213.20.128.35:9315>
User-Agent: Windows RTC/1.0
Proxy-Authorization: Digest username="jiri", realm="iptel.org", algorithm="MD5", uri="sip:jiri@bat.iptel.org", nonce="3cef753900000001771328f5ae1b8b7f0d742da1feb5753c", response="53fe98db10e1074b03b3e06438bda70f"
Content-Type: application/sdp
Content-Length: 451
v=0
o=jku2 0 0 IN IP4 213.20.128.35
s=session
c=IN IP4 213.20.128.35
b=CT:1000
t=0 0
m=audio 54742 RTP/AVP 97 111 112 6 0 8 4 5 3 101
a=rtpmap:97 red/8000
a=rtpmap:111 SIREN/16000
a=fmtp:111 bitrate=16000
a=rtpmap:112 G7221/16000
a=fmtp:112 bitrate=24000
a=rtpmap:6 DVI4/16000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:5 DVI4/8000
a=rtpmap: 3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16

@ -0,0 +1,33 @@
INVITE sip:7170@bat.iptel.org:9 SIP/2.0
Via: SIP/2.0/UDP 195.37.77.100:5040
Max-Forwards: 1
From: "jiri" <sip:jiri@iptel.org>;tag=76ff7a07-c091-4192-84a0-d56e91fe104f
To: <sip:jiri@bat.iptel.org>
Call-ID: r10815e0-bf17-4afa-8412-d9130a793d96@213.20.128.35
CSeq: 2 INVITE
Contact: <sip:213.20.128.35:9315>
User-Agent: Windows RTC/1.0
Proxy-Authorization: Digest username="jiri", realm="iptel.org", algorithm="MD5", uri="sip:jiri@bat.iptel.org", nonce="3cef753900000001771328f5ae1b8b7f0d742da1feb5753c", response="53fe98db10e1074b03b3e06438bda70f"
Content-Type: application/sdp
Content-Length: 451
v=0
o=jku2 0 0 IN IP4 213.20.128.35
s=session
c=IN IP4 213.20.128.35
b=CT:1000
t=0 0
m=audio 54742 RTP/AVP 97 111 112 6 0 8 4 5 3 101
a=rtpmap:97 red/8000
a=rtpmap:111 SIREN/16000
a=fmtp:111 bitrate=16000
a=rtpmap:112 G7221/16000
a=fmtp:112 bitrate=24000
a=rtpmap:6 DVI4/16000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:5 DVI4/8000
a=rtpmap: 3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16

@ -0,0 +1,33 @@
INVITE sip:7170@bat.iptel.org:9 SIP/2.0
Via: SIP/2.0/UDP 195.37.77.100:5040
Max-Forwards: 1
From: "jiri" <sip:jiri@iptel.org>;tag=76ff7a07-c091-4192-84a0-d56e91fe104f
To: <sip:jiri@bat.iptel.org>
Call-ID: r10815e0-bf17-4afa-8412-d9130a793d96@213.20.128.35
CSeq: 2 INVITE
Contact: <sip:213.20.128.35:9315>
User-Agent: Windows RTC/1.0
Proxy-Authorization: Digest username="jiri", realm="iptel.org", algorithm="MD5", uri="sip:jiri@bat.iptel.org", nonce="3cef753900000001771328f5ae1b8b7f0d742da1feb5753c", response="53fe98db10e1074b03b3e06438bda70f"
Content-Type: application/sdp
Content-Length: 451
v=0
o=jku2 0 0 IN IP4 213.20.128.35
s=session
c=IN IP4 213.20.128.35
b=CT:1000
t=0 0
m=audio 54742 RTP/AVP 97 111 112 6 0 8 4 5 3 101
a=rtpmap:97 red/8000
a=rtpmap:111 SIREN/16000
a=fmtp:111 bitrate=16000
a=rtpmap:112 G7221/16000
a=fmtp:112 bitrate=24000
a=rtpmap:6 DVI4/16000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:5 DVI4/8000
a=rtpmap: 3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16

@ -0,0 +1,23 @@
INVITE sip:p2@iptel.org SIP/2.0
Via: SIP/2.0/UDP 192.168.99.100:5040
From: "GMD FOKUS iptlab" <sip:jiri@iptel.org>;tag=b96b0300ed30f1286-2f5d
Call-ID: b96b0300-88d30f-66da-63aa@195.37.78.190
CSeq: 101 INVITE
Expires: 180
Max-Forwards: 0
User-Agent: Cisco-SIP-IP-Phone/2
Accept: application/sdp
Contact: sip:jiri@195.37.78.190:5060
Content-Type: application/sdp
Content-Length: 218
v=0
o=CiscoSystemsSIP-IPPhone-UserAgent 14474 8233 IN IP4 195.37.78.190
s=SIP Call
c=IN IP4 195.37.78.190
t=0 0
m=audio 18456 RTP/AVP 0 8 18 101
a=rtpmap:0 pcmu/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11

@ -0,0 +1,23 @@
INVITE sip:p2@iptel.org SIP/2.0
Via: SIP/2.0/UDP 193.175.133.193
From: "GMD FOKUS iptlab" <sip:jiri@iptel.org>;tag=b96b0300ed30f1286-2f5d
To: <sip:p2@iptel.org>
Call-ID: b96b0300-88d30f-66da-63aa@195.37.78.190
CSeq: 101 INVITE
Expires: 180
User-Agent: Cisco-SIP-IP-Phone/2
Accept: application/sdp
Contact: sip:jiri@195.37.78.190:5060
Content-Type: application/sdp
Content-Length: 225
v=0
o=CiscoSystemsSIP-IPPhone-UserAgent 14474 8233 IN IP4 195.37.78.190
s=SIP Call
c=IN IP4 195.37.78.190
t=0 0
m=audio 18456 RTP/AVP 0 8 18 101
a=rtpmap:0 pcmu/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11

@ -0,0 +1,23 @@
INVITE sip:p2@iptel.org SIP/2.0
Via: SIP/2.0/UDP 193.175.133.193
From: "GMD FOKUS iptlab" <sip:jiri@iptel.org>;tag=b96b0300ed30f1286-2f5d
To: <sip:p2@iptel.org>
Call-ID: b96b0300-88d30f-66da-63aa@195.37.78.190
CSeq:101
Expires: 180
User-Agent: Cisco-SIP-IP-Phone/2
Accept: application/sdp
Contact: sip:jiri@195.37.78.190:5060
Content-Type: application/sdp
Content-Length: 225
v=0
o=CiscoSystemsSIP-IPPhone-UserAgent 14474 8233 IN IP4 195.37.78.190
s=SIP Call
c=IN IP4 195.37.78.190
t=0 0
m=audio 18456 RTP/AVP 0 8 18 101
a=rtpmap:0 pcmu/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11

@ -0,0 +1,23 @@
INVITE sip:p2@iptel.org SIP/2.0
Via: SIP/2.0/UDP 193.175.133.193
From: "GMD FOKUS iptlab" <sip:jiri@iptel.org>;tag=b96b0300ed30f1286-2f5d
To: <sip:p2@iptel.org>
Call-ID; b96b0300-88d30f-66da-63aa@195.37.78.190
CSeq: 101 INVITE
Expires: 180
User-Agent: Cisco-SIP-IP-Phone/2
Accept: application/sdp
Contact: sip:jiri@195.37.78.190:5060
Content-Type: application/sdp
Content-Length: 225
v=0
o=CiscoSystemsSIP-IPPhone-UserAgent 14474 8233 IN IP4 195.37.78.190
s=SIP Call
c=IN IP4 195.37.78.190
t=0 0
m=audio 18456 RTP/AVP 0 8 18 101
a=rtpmap:0 pcmu/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11

@ -0,0 +1,23 @@
INVITE sip:p2@iptel.org SIP/2.0
Via: SIP/2.0/UDP 193.175.133.193;branch=
From: "GMD FOKUS iptlab" <sip:jiri@iptel.org>;tag=b96b0300ed30f1286-2f5d
To: <sip:p2@iptel.org>
Call-ID: b96b0300-88d30f-66da-63aa@195.37.78.190
CSeq: 101 INVITE
Expires: 180
User-Agent: Cisco-SIP-IP-Phone/2
Accept: application/sdp
Contact: sip:jiri@195.37.78.190:5060
Content-Type: application/sdp
Content-Length: 225
v=0
o=CiscoSystemsSIP-IPPhone-UserAgent 14474 8233 IN IP4 195.37.78.190
s=SIP Call
c=IN IP4 195.37.78.190
t=0 0
m=audio 18456 RTP/AVP 0 8 18 101
a=rtpmap:0 pcmu/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11

@ -0,0 +1,44 @@
/*
* $Id$
*
* simple locking test program
* (no paralles stuff)
*
* Compile with: gcc -D__CPU_i386 -O3 on x86 machines and
* gcc -mips2 -O2 -D__CPU_mips2 on mips machines.
* -- andrei
*
*
*/
#include <stdio.h>
#include "../fastlock.h"
int main(int argc, char** argv)
{
fl_lock_t lock;
int r;
lock=0;
printf("starting locking basic tests...\n");
r=try_lock(&lock);
printf(" try_lock should return 0 ... %d\n", r);
printf(" lock should be 1 now ... %d\n", lock);
r=try_lock(&lock);
printf(" tsl should return -1 ... %d\n", r);
printf(" lock should still be 1 now ... %d\n", lock);
release_lock(&lock);
printf(" release_lock: lock should be 0 now ... %d\n", lock);
printf("try_lock once more...\n");
r=try_lock(&lock);
printf(" try_lock should return 0 ... %d\n", r);
printf(" lock should be 1 now ... %d\n", lock);
release_lock(&lock);
get_lock(&lock);
printf(" get_lock, lock should be 1 now ... %d\n", lock);
printf("\ndone.\n");
return 0;
}

@ -0,0 +1,63 @@
#
# $Id$
#
NAME=locking_test
CC=gcc
CFLAGS= -O2 -Wall
DEFS=
LIBS=
INCLUDE=
PTHREAD_LIBS= -lpthread
OS = $(shell uname -s)
ifeq ($(OS), SunOS)
LIBS+= -lrt
CFLAGS+=-mv8 -Wa,-xarch=v8plus
PTHREAD_LIBS= -lpthread
endif
ifeq ($(OS), FreeBSD)
PTHREAD_LIBS= -lc_r
endif
$(NAME): $(NAME).c
gcc $(CFLAGS) $(DEFS) -DNO_LOCK -o $@ $< $(LIBS)
$(NAME)_sysv: $(NAME).c
gcc $(CFLAGS) $(DEFS) -DSYSV_SEM -o $@ $(INCLUDE) $< $(LIBS)
$(NAME)_flock: $(NAME).c
gcc $(CFLAGS) $(DEFS) -DFLOCK -o $@ $(INCLUDE) $< $(LIBS)
$(NAME)_posix: $(NAME).c
gcc $(CFLAGS) $(DEFS) -DPOSIX_SEM -o $@ $(INCLUDE) $< $(LIBS) \
$(PTHREAD_LIBS)
$(NAME)_pmutex: $(NAME).c
gcc $(CFLAGS) $(DEFS) -DPTHREAD_MUTEX -o $@ $(INCLUDE) $< $(LIBS) \
$(PTHREAD_LIBS)
$(NAME)_fastlock: $(NAME).c
gcc $(CFLAGS) $(DEFS) -DFAST_LOCK -o $@ $(INCLUDE) $< $(LIBS)
$(NAME)_futex: $(NAME).c
gcc $(CFLAGS) $(DEFS) -DFUTEX -o $@ $(INCLUDE) $< $(LIBS)
all: $(NAME) $(NAME)_sysv $(NAME)_posix $(NAME)_pmutex \
$(NAME)_fastlock
ifneq ($(OS), SunOS)
all: $(NAME)_flock
endif
clean:
-@rm $(NAME) $(NAME)_sysv $(NAME)_flock $(NAME)_posix \
$(NAME)_pmutex $(NAME)_fastlock

@ -0,0 +1,304 @@
/* $Id$ */
/*
*
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of ser, a free SIP server.
*
* ser 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
*
* For a license to use the ser software under conditions
* other than those described here, or to purchase support for this
* software, please contact iptel.org by e-mail at the following addresses:
* info@iptel.org
*
* ser 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
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#ifdef FLOCK
#include <sys/file.h>
static int lock_fd;
#endif
#ifdef POSIX_SEM
#include <semaphore.h>
static sem_t sem;
#endif
#ifdef PTHREAD_MUTEX
#include <pthread.h>
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
#ifdef FAST_LOCK
#include "../../fastlock.h"
fl_lock_t lock;
#endif
#ifdef FUTEX
#define USE_FUTEX
#include "../../futexlock.h"
futex_lock_t lock;
#endif
#ifdef SYSV_SEM
#include <sys/ipc.h>
#include <sys/sem.h>
#if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) || \
defined(__FreeBSD__)
/* union semun is defined by including <sys/sem.h> */
#else
/* according to X/OPEN we have to define it ourselves */
union semun {
int val; /* value for SETVAL */
struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */
unsigned short int *array; /* array for GETALL, SETALL */
struct seminfo *__buf; /* buffer for IPC_INFO */
};
#endif
static int semid=-1;
#endif
#ifdef NO_LOCK
#define LOCK()
#define UNLOCK()
#elif defined SYSV_SEM
#define LOCK() \
{\
struct sembuf sop; \
sop.sem_num=0; \
sop.sem_op=-1; /*down*/ \
sop.sem_flg=0 /*SEM_UNDO*/; \
semop(semid, &sop, 1); \
}
#define UNLOCK() \
{\
struct sembuf sop;\
sop.sem_num=0;\
sop.sem_op=1; /*up*/\
sop.sem_flg=0 /*SEM_UNDO*/;\
semop(semid, &sop, 1);\
}
#elif defined FLOCK
#define LOCK() \
flock(lock_fd, LOCK_EX)
#define UNLOCK() \
flock(lock_fd, LOCK_UN)
#elif defined POSIX_SEM
#define LOCK() \
sem_wait(&sem)
#define UNLOCK() \
sem_post(&sem);
#elif defined PTHREAD_MUTEX
#define LOCK() \
pthread_mutex_lock(&mutex)
#define UNLOCK() \
pthread_mutex_unlock(&mutex)
#elif defined FAST_LOCK
#define LOCK() \
get_lock(&lock)
#define UNLOCK() \
release_lock(&lock)
#elif defined FUTEX
#define LOCK() \
futex_get(&lock)
#define UNLOCK() \
futex_release(&lock)
#endif
static char *id="$Id$";
static char *version="locking_test 0.1-"
#ifdef NO_LOCK
"nolock"
#elif defined SYSV_SEM
"sysv_sem"
#elif defined FLOCK
"flock"
#elif defined POSIX_SEM
"posix_sem"
#elif defined PTHREAD_MUTEX
"pthread_mutex"
#elif defined FAST_LOCK
"fast_lock"
#elif defined FUTEX
"futex"
#endif
;
static char* help_msg="\
Usage: locking_test -n address [-c count] [-v]\n\
Options:\n\
-c count how many times to try lock/unlock \n\
-v increase verbosity level\n\
-V version number\n\
-h this help message\n\
";
int main (int argc, char** argv)
{
int c;
int r;
char *tmp;
int count;
int verbose;
char *address;
#ifdef SYSV_SEM
union semun su;
#endif
/* init */
count=0;
verbose=0;
address=0;
opterr=0;
while ((c=getopt(argc,argv, "c:vhV"))!=-1){
switch(c){
case 'v':
verbose++;
break;
case 'c':
count=strtol(optarg, &tmp, 10);
if ((tmp==0)||(*tmp)){
fprintf(stderr, "bad count: -c %s\n", optarg);
goto error;
}
break;
case 'V':
printf("version: %s\n", version);
printf("%s\n",id);
exit(0);
break;
case 'h':
printf("version: %s\n", version);
printf("%s", help_msg);
exit(0);
break;
case '?':
if (isprint(optopt))
fprintf(stderr, "Unknown option `-%c´\n", optopt);
else
fprintf(stderr, "Unknown character `\\x%x´\n", optopt);
goto error;
case ':':
fprintf(stderr, "Option `-%c´ requires an argument.\n",
optopt);
goto error;
break;
default:
abort();
}
}
/* check if all the required params are present */
if(count==0){
fprintf(stderr, "Missing count (-c number)\n");
exit(-1);
}else if(count<0){
fprintf(stderr, "Invalid count (-c %d)\n", count);
exit(-1);
}
#ifdef SYSV_SEM
/*init*/
puts("Initializing SYS V semaphores\n");
semid=semget(IPC_PRIVATE,1,0700);
if(semid==-1){
fprintf(stderr, "ERROR: could not init semaphore: %s\n",
strerror(errno));
goto error;
}
/*set init value to 1 (mutex)*/
su.val=1;
if (semctl(semid, 0, SETVAL, su)==-1){
fprintf(stderr, "ERROR: could not set initial semaphore value: %s\n",
strerror(errno));
semctl(semid, 0, IPC_RMID, (union semun)0);
goto error;
}
#elif defined FLOCK
puts("Initializing flock\n");
lock_fd=open("/dev/zero", O_RDONLY);
if (lock_fd==-1){
fprintf(stderr, "ERROR: could not open file: %s\n", strerror(errno));
goto error;
}
#elif defined POSIX_SEM
puts("Initializing semaphores\n");
if (sem_init(&sem, 0, 1)<0){
fprintf(stderr, "ERROR: could not initialize semaphore: %s\n",
strerror(errno));
goto error;
}
#elif defined PTHREAD_MUTEX
puts("Initializing mutex -already initialized (statically)\n");
/*pthread_mutext_init(&mutex, 0 );*/
#elif defined FAST_LOCK
puts("Initializing fast lock\n");
init_lock(lock);
#elif defined FUTEX
puts("Initializing futex lock\n");
futex_init(&lock);
#endif
/* loop */
for (r=0; r<count; r++){
LOCK();
if ((verbose>1)&&(r%1000)) putchar('.');
UNLOCK();
}
printf("%d loops\n", count);
#ifdef SYSV_SEM
semctl(semid, 0, IPC_RMID, (union semun)0);
#elif defined LIN_SEM
sem_destroy(&sem);
#endif
exit(0);
error:
exit(-1);
}

@ -0,0 +1,40 @@
nolock flock sysv posix pmutex fastl
Linux 2* Athlon 1200, 2.4.16:
real 0.044/ 14.713 9.330 2.670 1.730 0.400
user 0.040 2.610 2.950 2.670 1.720 0.400
sys 0.000 12.110 6.370 0.000 0.010 0.000
* 1 334.386 212.045 60.681 39.318 9.090
Linux 2*PIII, 2.4.17:
real 0.056 17.771 14.476 3.099 1.902 0.603
user 0.050 4.130 5.120 3.100 1.900 0.600
sys 0.000 13.650 9.350 0.000 0.000 0.000
* 1 317.339 258.500 55.339 33.964 10.767
Solaris 8:
real 0.105 n/a 48.490 27.492 3.602 1.284
user 0.090 n/a 29.330 27.410 3.590 1.270
sys 0.010 n/a 19.110 0.010 0.010 0.020
* 1 n/a 461.809 257.142 34.304 12.228
FreeBSD, PII 333:
real: 0.147 43.952 54.428 37.385 15.706 1.863
user: 0.121 12.761 13.131 31.958 13.402 1.606
sys: 0.001 25.149 33.732 0.017 0.017 0.001
* 1 299.061 370.258 254.319 106.843 12.673
nolock= no locking, just a loop
flock= using flock
sysv = using SYSV semaphores
posix = using POSIX1003.1b semaphores (sem_wait, sem_post)
pmutex = using pthread_mutex*
fastl = using fastlock.h from ser (hand made assembler locks)
Test: time ./locking_test* -c 10000000
(sip_router/test/locking/*)

@ -0,0 +1,66 @@
INVITE sip:jiri@bat.iptel.org SIP/2.0
Max-Forwards: 10
Via: SIP/2.0/UDP 195.37.77.100;branch=4848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=4848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=4848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=4848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=4848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=4848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=4848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=1848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=2848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=3848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=4848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=8848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=9848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=5848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=6848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=7848eaf6f622ebaf1762f34e5d08ec2e.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=b03d645a795fe2572631dbe15438fabd.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=59c7c421d731de1ce1e1e4c6e83150f2.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=3b33b0d029964ec5330922ff50b34c79.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=781aa36a12b7b99b2316a8ed32123fc9.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=a93680d322702022416a5a661aaf573d.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=5a94858405aeaae679632efed7e1ff0b.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=70509dba8d202a0116d2e51cd474a1d4.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=7056d40a2cfa30ff299705fc791f4303.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=ac7cf460ba831233121eead26af76d5a.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=2c4d2ac0b10115c704d28c2b360bcb6f.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=e0282bc88aed37191911cbb5ded27379.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=c7d6a97d4b6762877410653db5643775.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=a0c4944760b9f9693209f719e7aa177c.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=4147b5297bc5a8e0c3ec58fe6fd9bf6c.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=557cfe12fa9372a0a309ffebcdef3110.836.0
Via: SIP/2.0/UDP 195.37.77.100;branch=ce741cd8b427d1722d4f746922a9d3a2.836.0
Via: SIP/2.0/UDP 195.37.77.101;branch=838cccacb7d33e12c5e097f9090adfe1.836.0
Via: SIP/2.0/UDP 213.20.128.35:9315
From: "jiri" <sip:jiri@iptel.org>;tag=76ff7a07-c091-4192-84a0-d56e91fe104f
To: <sip:jiri@bat.iptel.org>
Call-ID: d10815e0-bf17-4afa-8412-d9130a793d96@213.20.128.35
CSeq: 2 INVITE
Contact: <sip:213.20.128.35:9315>
User-Agent: Windows RTC/1.0
Proxy-Authorization: Digest username="jiri", realm="iptel.org", algorithm="MD5", uri="sip:jiri@bat.iptel.org", nonce="3cef753900000001771328f5ae1b8b7f0d742da1feb5753c", response="53fe98db10e1074b03b3e06438bda70f"
Content-Type: application/sdp
Content-Length: 451
v=0
o=jku2 0 0 IN IP4 213.20.128.35
s=session
c=IN IP4 213.20.128.35
b=CT:1000
t=0 0
m=audio 54742 RTP/AVP 97 111 112 6 0 8 4 5 3 101
a=rtpmap:97 red/8000
a=rtpmap:111 SIREN/16000
a=fmtp:111 bitrate=16000
a=rtpmap:112 G7221/16000
a=fmtp:112 bitrate=24000
a=rtpmap:6 DVI4/16000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:5 DVI4/8000
a=rtpmap: 3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16

@ -0,0 +1,11 @@
MESSAGE sip:01756843@sms.iptel.org SIP/2.0
Via: SIP/2.0/UDP fesarius.fokus.gmd.de:5000
From: "bogdan" <sip:bogdan@iptel.org>;tag=0e99b1e7-ff50-4875-94ef-4ca5c27e2705
To: sip:cucu@sms.iptel.org;cucu=bau;tag=xyz
Call-ID: 02b1191c-447e-4bd0-b771-c039fc0d9d84@195.37.78.169
CSeq: 7 MESSAGE
Contact: <sip:195.37.78.169:11457>
User-Agent: Windows RTC/1.0
Content-Type: text/plain
Content-Length: 4

@ -0,0 +1,10 @@
MESSAGE sip:756843@iptel.org SIP/2.0
Via: SIP/2.0/UDP bat.iptel.org:9
From: "bogdan" <sip:bogdan@iptel.org>;tag=0e99b1e7-ff50-4875-94ef-4ca5c27e2705
xCall-ID: 02b1191c-447e-4bd0-b771-c039fc0d9d84@195.37.78.169
CSeq: 7 MESSAGE
Contact: <sip:195.37.78.169:11457>
User-Agent: Windows RTC/1.0
text/plain
Content-Length: 4

@ -0,0 +1,14 @@
MESSAGE sip:+49160567535@fesarius.fokus.gmd.de SIP/2.0
Via: SIP/2.0/UDP fesarius.fokus.gmde.de:9
From: sip:bogdan@fesarius.fokus.gmd.de;tag=16df4fe56e8782ecaa5d53ae36fb9240
To: sip:dcm@fesarius.fokus.gmd.de
Call-ID: 02b1191c-447e-4bd0-b771-c039fc0d9d84@195.37.78.169
CSeq: 7 MESSAGE
Contact: <sip:195.37.78.169:11457>
User-Agent: Windows RTC/1.0
Content-Type: text/plain
Content-Length: 13
cucu
bau
miau

@ -0,0 +1,97 @@
/*
*
* simple locking test program
* (no paralles stuff)
*
* Compile with: gcc -D__CPU_i386 -O3 on x86 machines and
* gcc -mips2 -O2 -D__CPU_mips on mips machines.
* -- andrei
*
*
*/
#include <stdio.h>
typedef volatile int fl_lock_t;
int tsl(fl_lock_t* lock)
{
long val;
#ifdef __CPU_mips
long tmp=0;
asm volatile(
".set noreorder\n\t"
"1: ll %1, %2 \n\t"
" li %0, 1 \n\t"
" sc %0, %2 \n\t"
" beqz %0, 1b \n\t"
" nop \n\t"
".set reorder\n\t"
: "=&r" (tmp), "=&r" (val), "=m" (*lock)
: "0" (tmp), "m" (*lock)
: "cc"
);
#elif defined __CPU_i386
val=1;
asm volatile(
" xchg %b1, %0" : "=q" (val), "=m" (*lock) : "0" (val)
);
#else
#error "cpu type not defined, add -D__CPU_<type> when compiling"
#endif
return val;
}
void release_lock(fl_lock_t* lock)
{
#ifdef __CPU_mips
int tmp;
tmp=0;
asm volatile(
".set noreorder \n\t"
" sync \n\t"
" sw $0, %0 \n\t"
".set reorder \n\t"
: /*no output*/ : "m" (*lock) : "memory"
);
#elif defined __CPU_i386
asm volatile(
" movb $0, (%0)" : /*no output*/ : "r"(lock): "memory"
);
#else
#error "cpu type not defined, add -D__CPU_<type> when compiling"
#endif
}
int main(int argc, char** argv)
{
fl_lock_t lock;
int r;
lock=0;
printf("starting locking basic tests...\n");
r=tsl(&lock);
printf(" tsl should return 0 ... %d\n", r);
printf(" lock should be 1 now ... %d\n", lock);
r=tsl(&lock);
printf(" tsl should return 1 ... %d\n", r);
printf(" lock should still be 1 now ... %d\n", lock);
release_lock(&lock);
printf(" release_lock: lock should be 0 now ... %d\n", lock);
printf("trying tsl once more...\n");
r=tsl(&lock);
printf(" tsl should return 0 ... %d\n", r);
printf(" lock should be 1 now ... %d\n", lock);
printf("\ndone.\n");
return 0;
}

@ -0,0 +1,23 @@
route{
(src_ip=~'(dorian)|(ekina)|(terix)' & method=~'^inv') \
forward(centauri.fokus.gmd.de);
src_ip=~"^192\.168\.[0-9]{1,3}\.[0-9]{1,3}$" \
log(1,"msg. from a private network\n"); route(1);
src_ip==0.0.0.0/0 log(1, " droping msg\n"); drop;
}
route[1]{
src_ip==192.168.46.61 log("possible loop, dropping\n"); drop;
(src_ip==192.168.46.0/24) log("routing with rt2\n");route(2); log("we're back\n");
src_ip==0.0.0.0/0 log(1, "we'll drop this one too\n"); drop;
}
route[2]{
(method=~'^ACK' and uri=~'.*fokus') forward("fox.iptel.org");
! method=~'^INV' forward(193.175.135.179); /* dorian */
method=~'.' log("spying...\n"); send(dorian,8000); \
forward("fox.iptel.org");
}

@ -0,0 +1,74 @@
1 linux-i386/gcc2.95
2 linux-i386/gcc3.3
3 linux-i386/icc
4 freebsd_4.5-i386/gcc
5 freebsd_5.0-i386/gcc3.2
6 openbsd_3.1-i386/gcc
7 netbsd_1.6-ultrasparc/gcc
8 solaris_8.0-ultrasparc/gcc
9 solaris_8.0-ultrasparc/sun cc 5.3
W - warnings
E - errors
I - could not compile due to missing includes
L - could not compile due to missing libraries
l - locking problems
o - ok
P - possible proto problems (tcp)
D - dead/not finished
checked:
7 - 2003-05-06
8 - 2003-05-09
1-4 2003-05-23
6 - 2003-05-23
5 - 2003-05-26
module_name 1 2 3 4 5 6 7 8 9
core o o o o o o o o
acc o I I I o* o* I I I
auth o o o o o o o o o
auth_db o o o o o o o o o
auth_radius o I I I I I I I I
cpl P o o o o o o o o o
cpl-c D I I I I I I I I I
dbtext o o o o o o o o o
domain o o o o o o o o o
enum o o o o o o o o o
exec o o o o o o o o o
ext o o o o o o o o o
extcmd o o o o o o o o o
group o o o o o o o o o
group_radius W I I I I I I I I
jabber o o o o o o o W+ W
mangler o o o o o o o o o
maxfwd o o o o o o o o o
msilo o o o o o o o o o
mysql o o o o I o o o o
nathelper o o o o o o o o o
pa o o o o o o o o o
pdt o o o o o o o o o
persmissions o o o o o o o o o
pike o o o o o o o o o
postgress I I I I I I I I I
print o o o o o o o o o
registrar o o o o o o o o o
rr o o o o o o o o o
sl o o o o o o o o o
sms o o o o o o o o o
snmp D I I I I I I I I I
textops o o o o o o o o o
tm o o o o o o o o o
uri o o o o o o o o o
uri_radius o I I I I I I I I
usrloc o o o o o o o o o
vm o o o o o o o o o
[*] - w/o radius & mysql
[+] - -I warning (bad cpp?)

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save