Module: sip-router
Branch: master
Commit: c5c2bcd6fe8cbcdd825a916aefe232c0a3fe0574
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c5c2bcd…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Mon Mar 9 00:15:31 2009 +0100
K. compatibility members of the branch structure in dset.c
The structure now also contains the buffer and length variable
to store the path header and an unsigned int variable to store
branch flags.
---
config.h | 2 ++
dset.c | 7 +++++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/config.h b/config.h
index a18def8..317ff1c 100644
--- a/config.h
+++ b/config.h
@@ -70,6 +70,8 @@
#define MAX_URI_SIZE 1024 /* used when rewriting URIs */
+#define MAX_PATH_SIZE 256 /* Maximum length of path header buffer */
+
#define MY_VIA "Via: SIP/2.0/UDP "
#define MY_VIA_LEN (sizeof(MY_VIA) - 1)
diff --git a/dset.c b/dset.c
index ab58dca..e4e995a 100644
--- a/dset.c
+++ b/dset.c
@@ -57,9 +57,16 @@ struct branch
char dst_uri[MAX_URI_SIZE];
unsigned int dst_uri_len;
+ /* Path set */
+ char path[MAX_PATH_SIZE];
+ unsigned int path_len;
+
int q; /* Preference of the contact among
* contact within the array */
struct socket_info* force_send_socket;
+
+ /* Branch flags */
+ unsigned int flags;
};
Module: sip-router
Branch: master
Commit: 00c747a1b113b8af4f9e96f99dcde6b14e36eebd
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=00c747a…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Tue Mar 10 17:44:42 2009 +0100
Export get_sock_info_list function to modules
---
socket_info.c | 2 +-
socket_info.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/socket_info.c b/socket_info.c
index 1b260dd..abd3064 100644
--- a/socket_info.c
+++ b/socket_info.c
@@ -301,7 +301,7 @@ static char* get_proto_name(unsigned short proto)
/* returns 0 if support for the protocol is not compiled or if proto is
invalid */
-static struct socket_info** get_sock_info_list(unsigned short proto)
+struct socket_info** get_sock_info_list(unsigned short proto)
{
switch(proto){
diff --git a/socket_info.h b/socket_info.h
index bf36ddb..627e3db 100644
--- a/socket_info.h
+++ b/socket_info.h
@@ -88,7 +88,7 @@ struct socket_info* grep_sock_info_by_port(unsigned short port,
struct socket_info* find_si(struct ip_addr* ip, unsigned short port,
unsigned short proto);
-
+struct socket_info** get_sock_info_list(unsigned short proto);
/* helper function:
* returns next protocol, if the last one is reached return 0
Folks,
As some of you know I have been trying to make kamailio modules
compile with the sip-router core. I wrote several scripts to perform
bulk updates of the source code and commit the changes. That includes
database related changes for libsrdb1, changes of headers that are not
present in the core anymore, and so on.
I keep my changes in a git repository which I just published on
git.sip-router.org. You can browse the repository here:
http://git.sip-router.org/cgi-bin/gitweb.cgi?p=kamailio-3.0/.git;a=summary
And you can clone it using:
git clone git://git.sip-router.org/kamailio-3.0
I'd like to point out that this is a temporary repository only, it
helps me with my merging work, it allows me to keep my patches up to
date on top of moving sip-router core and kamailio modules (using a
set of scripts that I didn't publish), but it is not how it should be
organized in the future.
The repository is fairly big, it contains 91 branches, and is
organized as follows:
* Branch 'sr' contains the contents of the sip-router/master branch
from the main sip-router repository, possibly with some local
changes not yet published on the sip-router/master branch. I pull
into this branch from the main branch. I also use this branch to do
compatibility changes in the sip-router core and those changes are
then pushed into sip-router/master when done.
* Branch 'kcore' contains the contents of sip-router/janakj/kcore
branch, I use this branch to do changes in the libkcore stuff. Local
changes from this branch are then pushed into
sip-router/janakj/kcore
* Branch 'km_module' contains kamailio modules from kamailio svn
trunk, but with the core, tm module and some database drivers
removed. I keep this branch synchronized with the git import of
kamailio trunk and on top of that there are a few commits that
remove everything which would conflict with the sip-router
core. This branch must have no local changes except for the commits
that remove conflicting files.
* Branch 'km_sr' contains all three previous branches merged, that is
sip-router core + libkcore + kamailio modules. This brach serves as
the basis for other per-module branches, module branches base their
changes on top of km_sr.
* A bunch of module branches, there is one branch per kamailio module
that needs to be update, the name of the branch is always the name of
the module. You can get full list here:
http://git.sip-router.org/cgi-bin/gitweb.cgi?p=kamailio-3.0/.git;a=heads
One thing that is special about module branches is that they use
git-rebase to keep local changes on top of all other changes coming
from the branch km_sr. In other words, what happens when you merge
km_sr into a module branch is this:
- All local changes are undone and saved into a temporary area
- Changes from km_sr are applied to the branch
- Changes from the temporary area are applied back on top of the
updated branch
This keeps local changes in module branches on top of all other
changes that might have propagated from the sip-router repository
or kamailio svn repository. In the end we will be using the
repository to generate a set of patches that will be applied either
to the code in the svn repository or in another git repository so I
think this is the way to go.
Here is a diagram showing how changes propagate into individual branches:
svn ---> git:km/trunk --(D)----> km_modules -+
cvs ---> git:sr/master --(L)---> sr ---------+-(O)-> km_sr ---+--(R)-> acc
sr/janakj/kcore -(L)--> kcore ------+ +--(R)-> auth
+--(R)--> ...
(D) is where the kamailio core and conflicting modules get removed,
(L) indicates possible local changes to the sip-router core or
likcore, (O) denotes the place where git octopus merge happends, and
finally (R) marks places where git-rebase is used instead of the
default git merge.
Because the process of updating the repository is quite complex, and,
frankly, brittle, I'd like to ask you that you do not push into this
repository although it is allowed for anyone who has write access on
git.sip-router.org. Instead do all the changes that you would like to
have applied in your local clone and then send patches to the mailing
list, I will apply them to my master copy and then republish.
This is how my typical workflow looks like:
Today I want to work on the presence module, so I checkout the
presence branch:
$ git co presence
I investigate why the module does not compile, do some changes and
commit them into the branch. In this step I try hard to make sure
that the commits are logically split, because it makes reviewing the
changes much easier. A reviewer can typically just decide whether
the patch should be applied or thrown away as a whole.
In the previous step I realized that I might need to do some changes
in the sip-router core to make the module work, so I check out the
'sr' branch:
$ git co sr
and do the changes there. After that I need to propagate the changes
I did to the sr core into the presence branch, I do this in two
steps, first I pull the changes into the km_sr branch:
$ git co km_sr
$ git pull
And secondly I pull the sip-router core change into 'presence' branch:
$ git co presence
$ got pull
After the last step you will see the rebase taking place. There
should be no conflicts because I never modify anything that belongs
to the sip-router core or libkcore on the per-module branch. I
always use 'sr' and 'kcore' branches for that.
That's it, I should also note that I have a bunch of scripts that help
me to keep the whole repository up-to-date, so I'd typically just run
something like km_pull.sh and that updates all branches, also pulling
changes from svn and cvs in the process. The scripts are currently not
ready to be published, they are brittle and would most likely work in
my environment only. But I do offer the service of keeping the
kamailo-3.0 repository up-to-date, so you can just mirror that one and
you wouldn't need the scripts.
I'll send a separate email describing the current state of kamailio
modules.
Jan.
Here's a small patch to fix some compilation error on the sip-router.
There are still issue with respect to the timer registration, but that
is discussed on a separate thread.
$ git diff
diff --git a/modules/ratelimit/ratelimit.c b/modules/ratelimit/ratelimit.c
index a3099cf..8d57243 100644
--- a/modules/ratelimit/ratelimit.c
+++ b/modules/ratelimit/ratelimit.c
@@ -46,6 +46,7 @@
#include "../../data_lump.h"
#include "../../data_lump_rpl.h"
#include "../sl/sl_api.h"
+#include "../../lib/kcore/km_ut.h"
MODULE_VERSION
Regards,
Ovidiu Sas
Hello all,
The SDP parser from the kamailio core needs to be imported into the
sip-router core.
It is located under parser/sdp directory.
Th qos module has a dependency on the SDP parser.
Regards,
Ovidiu Sas
Module: sip-router
Branch: master
Commit: e12b2f1d22db9b2ac08c07cdfa4c9923e7c0de42
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e12b2f1…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Sun Mar 8 04:40:13 2009 +0100
Kamailio compatibility changes: replace_build
List of changes:
* Add support for pseudo variables
* Create a static buffer allocated on the stack that will be used to
print the resulting string, we no longer can determine the final
size of the result in advance because of pseudo-variable support and
thus we print to a fixed-size buffer and copy the result into a
dynamically allocated buffer when done.
* Define macro RBUF_APPEND which is used to add text to the static
buffer, the macro checks if there is enough space in the buffer
before each write
* Remove the call to replace_len at the beginning of the function
* Replace all occurrences of memcpy(...) and dest+=... with
RBUF_APPEND
* At the end create a dynamically allocated buffer for the result and
copy the string from the static buffer into the dynamic buffer.
---
re.c | 56 +++++++++++++++++++++++++++++++++-----------------------
1 files changed, 33 insertions(+), 23 deletions(-)
diff --git a/re.c b/re.c
index 7f1dc23..6b19786 100644
--- a/re.c
+++ b/re.c
@@ -381,30 +381,30 @@ static int replace_build(const char* match, int nmatch, regmatch_t* pmatch,
{
int r;
str* uri;
+ pv_value_t sv;
char* p;
char* dest;
char* end;
int size;
-
- rpl->len=replace_len(match, nmatch, pmatch, se, msg);
- if (rpl->len==0){
- rpl->s=0; /* empty string */
- return 0;
- }
- rpl->s=pkg_malloc(rpl->len);
- if (rpl->s==0){
- LOG(L_ERR, "ERROR: replace_build: out of mem (rpl)\n");
- goto error;
- }
+ static char rbuf[REPLACE_BUFFER_SIZE];
+
+#define RBUF_APPEND(dst, src, size) \
+ if ((dst) - rbuf + (size) >= REPLACE_BUFFER_SIZE - 1) { \
+ ERR("replace_build: Buffer too small\n"); \
+ goto error; \
+ } \
+ memcpy((dst), (src), (size)); \
+ (dst) += (size);
+
p=se->replacement.s;
end=p+se->replacement.len;
- dest=rpl->s;
+ dest=rbuf;
+
for (r=0; r<se->n_escapes; r++){
/* copy the unescaped parts */
size=se->replacement.s+se->replace[r].offset-p;
- memcpy(dest, p, size);
+ RBUF_APPEND(dest, p, size);
p+=size+se->replace[r].size;
- dest+=size;
switch(se->replace[r].type){
case REPLACE_NMATCH:
if ((se->replace[r].u.nmatch<nmatch)&&(
@@ -412,15 +412,13 @@ static int replace_build(const char* match, int nmatch, regmatch_t* pmatch,
/* do the replace */
size=pmatch[se->replace[r].u.nmatch].rm_eo-
pmatch[se->replace[r].u.nmatch].rm_so;
- memcpy(dest,
- match+pmatch[se->replace[r].u.nmatch].rm_so,
- size);
- dest+=size;
+ RBUF_APPEND(dest,
+ match+pmatch[se->replace[r].u.nmatch].rm_so,
+ size);
};
break;
case REPLACE_CHAR:
- *dest=se->replace[r].u.c;
- dest++;
+ RBUF_APPEND(dest, &se->replace[r].u.c, 1);
break;
case REPLACE_URI:
if (msg->first_line.type!=SIP_REQUEST){
@@ -430,8 +428,14 @@ static int replace_build(const char* match, int nmatch, regmatch_t* pmatch,
}
uri= (msg->new_uri.s)?(&msg->new_uri):
(&msg->first_line.u.request.uri);
- memcpy(dest, uri->s, uri->len);
- dest+=uri->len;
+ RBUF_APPEND(dest, uri->s, uri->len);
+ break;
+ case REPLACE_SPEC:
+ if(pv_get_spec_value(msg, &se->replace[r].u.spec, &sv)!=0) {
+ ERR("replace_build: item substitution returned error\n");
+ break; /* ignore, we can continue */
+ }
+ RBUF_APPEND(dest, sv.rs.s, sv.rs.len);
break;
default:
LOG(L_CRIT, "BUG: replace_build: unknown type %d\n",
@@ -439,7 +443,13 @@ static int replace_build(const char* match, int nmatch, regmatch_t* pmatch,
/* ignore it */
}
}
- memcpy(dest, p, end-p);
+ RBUF_APPEND(dest, p, end-p);
+ rpl->len = dest - rbuf;
+ if ((rpl->s = pkg_malloc(rpl->len)) == NULL) {
+ ERR("replace_build: Out of pkg memory\n");
+ goto error;
+ }
+ memcpy(rpl->s, rbuf, rpl->len);
return 0;
error:
return -1;
Module: sip-router
Branch: master
Commit: 578b3a95ec13d1ca934c02fed8291aa5419f2160
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=578b3a9…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Sun Mar 8 04:42:10 2009 +0100
Remove function replace_len which is no longer needed.
This function was originally used to calculate the size of the memory
buffer in replace_build for the resulting string. Since we now print
the result into a static buffer, this function is no longer needed.
---
re.c | 46 ----------------------------------------------
1 files changed, 0 insertions(+), 46 deletions(-)
diff --git a/re.c b/re.c
index 6b19786..2b2f6b0 100644
--- a/re.c
+++ b/re.c
@@ -328,52 +328,6 @@ error:
return 0;
}
-
-
-static int replace_len(const char* match, int nmatch, regmatch_t* pmatch,
- struct subst_expr* se, struct sip_msg* msg)
-{
- int r;
- int len;
- str* uri;
-
- len=se->replacement.len;
- for (r=0; r<se->n_escapes; r++){
- switch(se->replace[r].type){
- case REPLACE_NMATCH:
- len-=se->replace[r].size;
- if ((se->replace[r].u.nmatch<nmatch)&&(
- pmatch[se->replace[r].u.nmatch].rm_so!=-1)){
- /* do the replace */
- len+=pmatch[se->replace[r].u.nmatch].rm_eo-
- pmatch[se->replace[r].u.nmatch].rm_so;
- };
- break;
- case REPLACE_CHAR:
- len-=(se->replace[r].size-1);
- break;
- case REPLACE_URI:
- len-=se->replace[r].size;
- if (msg->first_line.type!=SIP_REQUEST){
- LOG(L_CRIT, "BUG: replace_len: uri substitution on"
- " a reply\n");
- break; /* ignore, we can continue */
- }
- uri= (msg->new_uri.s)?(&msg->new_uri):
- (&msg->first_line.u.request.uri);
- len+=uri->len;
- break;
- default:
- LOG(L_CRIT, "BUG: replace_len: unknown type %d\n",
- se->replace[r].type);
- /* ignore it */
- }
- }
- return len;
-}
-
-
-
/* rpl.s will be alloc'ed with the proper size & rpl.len set
* returns 0 on success, <0 on error*/
static int replace_build(const char* match, int nmatch, regmatch_t* pmatch,