Module: sip-router
Branch: master
Commit: 742ce3ae28a4d1294ce0b7f63f0bc0968bff8ea3
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=742ce3a…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Aug 18 20:01:31 2010 +0200
kstats: cleanup - move type defs. to separate file
- moved kamailio statistics type defs to kstats_types.h (from
lib/kcore/kstats_wrapper.h). This removes core dependency on
lib/kcore include files (the statistics types are needed for the
kamailio module interface defs).
- removed statistics.h (it is obsolete, counters.h should be used
instead and if somebody really needs it, it should include
lib/kcore/kstats_wrapper.h or lib/kcore/statistics.h).
---
kstats_types.h | 69 ++++++++++++++++++++++++++++++++++++++++++++
lib/kcore/kstats_wrapper.h | 27 ++---------------
sr_module.h | 2 +-
statistics.h | 33 ---------------------
4 files changed, 73 insertions(+), 58 deletions(-)
diff --git a/kstats_types.h b/kstats_types.h
new file mode 100644
index 0000000..b8d1629
--- /dev/null
+++ b/kstats_types.h
@@ -0,0 +1,69 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010 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.
+ */
+/** kamailio statistics types.
+ * This file contains type declaration for kamailio statistics.
+ * They are needed when modules are loaded (sr_module.c).
+ * The rest of kamailio stats are in lib/kcore (include
+ * lib/kcore/kstats_wrapper.h or lib/kcore/statistics.h and link with
+ * libkcore).
+ * Note: kamailio statistics are obsolete. Use sr counters in new code
+ * (counters.h).
+ * @file kstats_types.h
+ * @ingroup: core
+ */
+/*
+ * History:
+ * --------
+ * 2010-08-18 initial version (andrei)
+*/
+
+#ifndef __kstats_types_h
+#define __kstats_types_h
+
+#include "counters.h"
+
+/* types */
+
+typedef counter_val_t stat_val;
+/* stat_var is always used as a pointer in k, we missuse
+ stat_var* for holding out counter id */
+typedef void stat_var;
+/* get val callback
+ * TODO: change it to counter_cbk_f compatible callback?
+ */
+typedef counter_val_t (*stat_function)(void);
+
+/* statistic module interface */
+struct stat_export_s {
+ char* name;
+ int flags;
+ stat_var** stat_pointer; /* pointer to the memory location
+ (where a counter handle will be stored)
+ Note: it's a double pointer because of
+ the original k version which needed it
+ allocated in shm. This version
+ will store the counter id at *stat_pointer.
+ */
+};
+
+typedef struct stat_export_s stat_export_t;
+
+
+#endif /*__kstats_types_h*/
+
+/* vi: set ts=4 sw=4 tw=79:ai:cindent: */
diff --git a/lib/kcore/kstats_wrapper.h b/lib/kcore/kstats_wrapper.h
index 1d6ba47..1c9559b 100644
--- a/lib/kcore/kstats_wrapper.h
+++ b/lib/kcore/kstats_wrapper.h
@@ -35,12 +35,15 @@
* History:
* --------
* 2010-08-08 initial version (andrei)
+ * 2010-08-18 type declaration needed by sr_module.c moved to
+ * ../../kstats_types.h (andrei)
*/
#ifndef __kstats_wrapper_h
#define __kstats_wrapper_h
#include "../../counters.h"
+#include "../../kstats_types.h"
/* k stat flags */
#define STAT_NO_RESET 1 /* used in dialog(k), nat_traversal(k),
@@ -49,31 +52,7 @@
#define STAT_SHM_NAME 4 /* used only from usrloc(k) */
#define STAT_IS_FUNC 8
-/* types */
-typedef counter_val_t stat_val;
-/* stat_var is always used as a pointer in k, we missuse
- stat_var* for holding out counter id */
-typedef void stat_var;
-/* get val callback
- * TODO: change it to counter_cbk_f compatible callback?
- */
-typedef counter_val_t (*stat_function)(void);
-
-/* statistic module interface */
-struct stat_export_s {
- char* name;
- int flags;
- stat_var** stat_pointer; /* pointer to the memory location
- (where a counter handle will be stored)
- Note: it's a double pointer because of
- the original k version which needed it
- allocated in shm. This version
- will store the counter id at *stat_pointer.
- */
-};
-
-typedef struct stat_export_s stat_export_t;
#ifdef STATISTICS
diff --git a/sr_module.h b/sr_module.h
index baf1081..4d32514 100644
--- a/sr_module.h
+++ b/sr_module.h
@@ -68,7 +68,7 @@
#include "str.h"
/* kamailio compat */
-#include "statistics.h"
+#include "kstats_types.h"
#include "mi/mi_types.h"
#include "pvar.h"
diff --git a/statistics.h b/statistics.h
deleted file mode 100644
index e9e430a..0000000
--- a/statistics.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * $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.
- */
-/*
- * statistics compatibility wrapper for kamailio
- * for now it doesn't do anything
- * (obsolete, do not use anymore)
- *
- * History:
- * --------
- * 2008-11-17 initial version compatible with kamailio statistics.h (andrei)
- */
-
-#ifndef _STATISTICS_H_
-#define _STATISTICS_H_
-
-#include "lib/kcore/statistics.h"
-
-#endif /* _STATISTICS_H_ */
Module: sip-router
Branch: master
Commit: 66cda7bc5f642ce892124cfb35f1e5effd78e9d6
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=66cda7b…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Aug 18 18:36:14 2010 +0200
tcp: fix double increment for the established stats
The counter/stats for established TCP connections were incremented
twice in the case of accept()-ed connections: once immediately
after the accept() and another time after the first packet
received or sent on the connection.
Now they are incremented only after the first successful send or
receive.
---
tcp_main.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/tcp_main.c b/tcp_main.c
index a1761f6..31fc0fa 100644
--- a/tcp_main.c
+++ b/tcp_main.c
@@ -3973,7 +3973,15 @@ static inline int handle_new_connect(struct socket_info* si)
return 1; /* success, because the accept was succesfull */
}
(*tcp_connections_no)++;
- TCP_STATS_ESTABLISHED(S_CONN_ACCEPT);
+ /* stats for established connections are incremented after
+ the first received or sent packet.
+ Alternatively they could be incremented here for accepted
+ connections, but then the connection state must be changed to
+ S_CONN_OK:
+ TCP_STATS_ESTABLISHED(S_CONN_ACCEPT);
+ ...
+ tcpconn=tcpconn_new(new_sock, &su, dst_su, si, si->proto, S_CONN_OK);
+ */
dst_su=&si->su;
if (unlikely(si->flags & SI_IS_ANY)){
Module: sip-router
Branch: master
Commit: 96e1bc629bc7ed78dd64b221bc54b266cd45e3ca
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=96e1bc6…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Aug 18 18:39:43 2010 +0200
tm: don't reply if the reply dest. is not yet set
- relay_reply() doesn't attempt to send the reply if the reply
destination is not yet fully set. This can happen for example
if reply_to_via is set, Via contains a host name (and not an ip)
and before having a chance to resolve the name a reply must be
sent (reply for a message that hasn't been sent yet: very
unlikely, but possible).
- use a membar_write() in init_rb(), before setting the reply send
socket (the reply send socket is also used as a flag for a fully
initialized reply destination and the membar_write() makes sure
that everything else was written before the send socket and no
re-ordering will take place).
---
modules/tm/t_lookup.c | 17 ++---------------
modules/tm/t_reply.c | 8 +++++---
2 files changed, 7 insertions(+), 18 deletions(-)
diff --git a/modules/tm/t_lookup.c b/modules/tm/t_lookup.c
index b0ddfa6..e69fdec 100644
--- a/modules/tm/t_lookup.c
+++ b/modules/tm/t_lookup.c
@@ -1196,7 +1196,6 @@ int init_rb( struct retr_buf *rb, struct sip_msg *msg)
/*struct socket_info* send_sock;*/
struct via_body* via;
int proto;
- int backup_mhomed;
/* rb. timers are init. init_t()/new_cell() */
via=msg->via1;
@@ -1220,20 +1219,8 @@ int init_rb( struct retr_buf *rb, struct sip_msg *msg)
rb->dst.comp=via->comp_no;
#endif
rb->dst.send_flags=msg->rpl_send_flags;
- /* turn off mhomed for generating replies -- they are ideally sent to where
- request came from to make life with NATs and other beasts easier
- */
- backup_mhomed=mhomed;
- mhomed=0;
- mhomed=backup_mhomed;
- /* use for sending replies the incoming interface of the request -bogdan */
- /*send_sock=get_send_socket(msg, &rb->dst.to, proto);
- if (send_sock==0) {
- LOG(L_ERR, "ERROR: init_rb: cannot fwd to af %d, proto %d "
- "no socket\n", rb->dst.to.s.sa_family, proto);
- ser_error=E_BAD_VIA;
- return 0;
- }*/
+
+ membar_write();
rb->dst.send_sock=msg->rcv.bind_address;
return 1;
}
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index df372e1..1a90844 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -637,7 +637,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
If reply_to_via is set and via contains a host name (and not an ip)
the chances for this increase a lot.
*/
- if (!trans->uas.response.dst.send_sock) {
+ if (unlikely(!trans->uas.response.dst.send_sock)) {
LOG(L_ERR, "ERROR: _reply_light: no resolved dst to send reply to\n");
} else {
if (likely(SEND_PR_BUFFER( rb, buf, len )>=0)){
@@ -1786,7 +1786,8 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
if (reply_status == RPS_COMPLETED) {
start_final_repl_retr(t);
}
- if (SEND_PR_BUFFER( uas_rb, buf, res_len )>=0){
+ if (likely(uas_rb->dst.send_sock &&
+ SEND_PR_BUFFER( uas_rb, buf, res_len ) >= 0)){
if (unlikely(!totag_retr && has_tran_tmcbs(t, TMCB_RESPONSE_OUT))){
run_trans_callbacks( TMCB_RESPONSE_OUT, t, t->uas.request,
relayed_msg, relayed_code);
@@ -1801,7 +1802,8 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
run_onsend_callbacks2(TMCB_RESPONSE_SENT, t, &onsend_params);
}
#endif
- }
+ } else if (unlikely(uas_rb->dst.send_sock == 0))
+ ERR("no resolved dst to send reply to\n");
/* Call put_on_wait() only if we really send out
* the reply. It can happen that the reply has been already sent from
* failure_route or from a callback and the timer has been already
Module: sip-router
Branch: master
Commit: bb5d5155daefe654f1998f61c3a92c07830d9204
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bb5d515…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Aug 18 17:21:14 2010 +0200
pua: updated devel API documentation
- updated documentation to reflect latest source code
- patch by Nikita Kozlov
---
modules_k/pua/README | 18 ++++++++----------
modules_k/pua/doc/pua_devel.xml | 22 +++++++++-------------
2 files changed, 17 insertions(+), 23 deletions(-)
diff --git a/modules_k/pua/README b/modules_k/pua/README
index 97a00bc..99f832a 100644
--- a/modules_k/pua/README
+++ b/modules_k/pua/README
@@ -344,18 +344,9 @@ typedef struct publ_info
should match */
str* extra_headers /* (optional) extra_headers that should be added
to Publish msg*/
- publrpl_cb_t* cbrpl;/* callback function to be called when receiving
- the reply for the sent request */
- void* cbparam; /* extra parameter for tha callback function */
-
}publ_info_t;
...
- The callback function type:
-...
-typedef int (publrpl_cb_t)(struct sip_msg* reply, void* extra_param);
-...
-
3. send_subscribe
Field type:
@@ -422,7 +413,7 @@ typedef int (*register_puacb_t)(int types, pua_cb f, void* param );
...
This function registers a callback to be called on receiving the reply
- message for a sent Subscribe request. The type parameter should be set
+ message for a sent Publish or Subscribe request. The type parameter should be set
the same as the source_flag for that request. The function registered
as callback for pua should be of type pua_cb , which is: typedef void
(pua_cb)(ua_pres_t* hentity, struct msg_start * fl); The parameters are
@@ -438,6 +429,13 @@ typedef int (*register_puacb_t)(int types, pua_cb f, void* param );
}
...
+ The callback function type:
+
+...
+typedef int (pua_cb)(ua_pres_t* hentity, struct sip_msg*);
+...
+
+
6. add_event
Field type:
diff --git a/modules_k/pua/doc/pua_devel.xml b/modules_k/pua/doc/pua_devel.xml
index a5ea3b9..246c17d 100644
--- a/modules_k/pua/doc/pua_devel.xml
+++ b/modules_k/pua/doc/pua_devel.xml
@@ -88,21 +88,9 @@ typedef struct publ_info
should match */
str* extra_headers /* (optional) extra_headers that should be added
to Publish msg*/
- publrpl_cb_t* cbrpl;/* callback function to be called when receiving
- the reply for the sent request */
- void* cbparam; /* extra parameter for tha callback function */
-
}publ_info_t;
...
</programlisting>
- <para>
- The callback function type:
- <programlisting format="linespecific">
-...
-typedef int (publrpl_cb_t)(struct sip_msg* reply, void* extra_param);
-...
- </programlisting>
- </para>
</section>
<section>
@@ -199,7 +187,7 @@ typedef int (*register_puacb_t)(int types, pua_cb f, void* param );
<para>
This function registers a callback to be called on receiving the reply message
- for a sent Subscribe request.
+ for a sent Publish or Subscribe request.
The type parameter should be set the same as the source_flag for that request.
The function registered as callback for pua should be of type pua_cb , which is:
typedef void (pua_cb)(ua_pres_t* hentity, struct msg_start * fl);
@@ -217,6 +205,14 @@ typedef int (*register_puacb_t)(int types, pua_cb f, void* param );
}
...
</programlisting>
+ <para>
+ The callback function type:
+ <programlisting format="linespecific">
+...
+typedef int (pua_cb)(ua_pres_t* hentity, struct sip_msg*);
+...
+ </programlisting>
+ </para>
</example>
</section>
Module: sip-router
Branch: master
Commit: 78beed37b8975e11851553c41c17578481772dad
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=78beed3…
Author: Miklos Tirpak <miklos(a)iptel.org>
Committer: Miklos Tirpak <miklos(a)iptel.org>
Date: Wed Aug 18 15:32:36 2010 +0200
dns cache: fix manually inserted SRV record order
The manually inserted SRV records thought the RPC interface
were not ordered by their priority and weight which resulted in
wrong SRV look-ups, i.e. not the highest priority record
was chosen first.
---
dns_cache.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/dns_cache.c b/dns_cache.c
index 182e61f..ef3a986 100644
--- a/dns_cache.c
+++ b/dns_cache.c
@@ -4221,6 +4221,8 @@ int dns_cache_add_record(unsigned short type,
ticks_t expire;
int err, h;
int size;
+ struct dns_rr *new_rr, **rr_p, **rr_iter;
+ struct srv_rdata *srv_rd;
/* eliminate gcc warnings */
ip_addr = 0;
@@ -4358,6 +4360,7 @@ int dns_cache_add_record(unsigned short type,
/* let the rr point to the new structure */
rr = (struct dns_rr*)translate_pointer((char*)new, (char*)old,
(char*)rr);
+ new_rr = rr;
if (type == T_SRV) {
/* fix the priority, weight, and port */
@@ -4392,6 +4395,7 @@ int dns_cache_add_record(unsigned short type,
"DNS cache entry\n");
goto error;
}
+ new_rr = rr;
switch(type) {
case T_A:
@@ -4409,6 +4413,46 @@ int dns_cache_add_record(unsigned short type,
/* maximum expire value has been already fixed by
* dns_cache_clone_entry() */
}
+
+ if (type == T_SRV) {
+ /* SRV records must be ordered by their priority and weight.
+ * With modifying an exising rr, or adding new rr to the DNS entry,
+ * the ordered list might got broken which needs to be fixed.
+ */
+ rr_p = NULL;
+ for ( rr_iter = &new->rr_lst;
+ *rr_iter;
+ rr_iter = &((*rr_iter)->next)
+ ) {
+ if (*rr_iter == new_rr) {
+ rr_p = rr_iter;
+ continue;
+ }
+ srv_rd = (struct srv_rdata*)(*rr_iter)->rdata;
+ if ((priority < srv_rd->priority) ||
+ ((priority == srv_rd->priority) && (weight > srv_rd->weight))
+ )
+ break; /* insert here */
+ }
+
+ if (!rr_p)
+ for ( rr_p = rr_iter;
+ *rr_p && (*rr_p != new_rr);
+ rr_p = &((*rr_p)->next)
+ );
+ if (!rr_p) {
+ LOG(L_ERR, "ERROR: Failed to correct the orderd list of SRV resource records\n");
+ goto error;
+ }
+
+ if (*rr_iter != new_rr->next) {
+ /* unlink rr from the list */
+ *rr_p = (*rr_p)->next;
+ /* link it before *rr_iter */
+ new_rr->next = *rr_iter;
+ *rr_iter = new_rr;
+ }
+ }
}
}