소스 검색

mem: Merge TLSF branch

Camille Oudot 10 년 전
부모
커밋
2f615e19e7

+ 118 - 2
modules/auth_xkeys/auth_xkeys.c

@@ -36,6 +36,8 @@
 #include "../../parser/msg_parser.h"
 #include "../../lib/srutils/shautils.h"
 #include "../../lib/kcore/cmpapi.h"
+#include "../../rpc.h"
+#include "../../rpc_lookup.h"
 
 #include "auth_xkeys.h"
 
@@ -201,7 +203,7 @@ int auth_xkeys_add(sip_msg_t* msg, str *hdr, str *key,
 	char xout[SHA512_DIGEST_STRING_LENGTH];
 	struct lump* anchor;
 
-	if(_auth_xkeys_list==NULL || _auth_xkeys_list==NULL) {
+	if(_auth_xkeys_list==NULL || *_auth_xkeys_list==NULL) {
 		LM_ERR("no stored keys\n");
 		return -1;
 	}
@@ -283,7 +285,7 @@ int auth_xkeys_check(sip_msg_t* msg, str *hdr, str *key,
 	char xout[SHA512_DIGEST_STRING_LENGTH];
 	str hbody;
 
-	if(_auth_xkeys_list==NULL || _auth_xkeys_list==NULL) {
+	if(_auth_xkeys_list==NULL || *_auth_xkeys_list==NULL) {
 		LM_ERR("no stored keys\n");
 		return -1;
 	}
@@ -379,3 +381,117 @@ int auth_xkeys_check(sip_msg_t* msg, str *hdr, str *key,
 	return -1;
 }
 
+
+static const char* auth_xkeys_rpc_list_doc[2] = {
+	"List existing keys",
+	0
+};
+
+/*
+ * RPC command to list the keys
+ */
+static void auth_xkeys_rpc_list(rpc_t* rpc, void* ctx)
+{
+	void* th;
+	void* ih;
+	void* vh;
+	auth_xkey_t *itc;
+	auth_xkey_t *itd;
+
+	if(_auth_xkeys_list==NULL || *_auth_xkeys_list==NULL) {
+		rpc->fault(ctx, 500, "No keys");
+		return;
+	}
+	/* add entry node */
+	if (rpc->add(ctx, "{", &th) < 0) {
+		rpc->fault(ctx, 500, "Internal error root reply");
+		return;
+	}
+	for(itc = *_auth_xkeys_list; itc; itc = itc->next_id) {
+		if(rpc->struct_add(th, "S[",
+					"KID", &itc->kid,
+					"KEYS",  &ih)<0) {
+			rpc->fault(ctx, 500, "Internal error keys array");
+			return;
+		}
+
+		for(itd=itc; itd; itd = itd->next) {
+			if(rpc->struct_add(ih, "{",
+						"KEY", &vh)<0) {
+				rpc->fault(ctx, 500, "Internal error creating keys data");
+				return;
+			}
+			if(rpc->struct_add(vh, "SDd",
+						"NAME",  &itd->kname,
+						"VALUE", &itd->kvalue,
+						"EXPIRES", itd->kexpires)<0)
+			{
+				rpc->fault(ctx, 500, "Internal error creating dest struct");
+				return;
+			}
+		}
+	}
+	return;
+}
+
+static const char* auth_xkeys_rpc_set_doc[2] = {
+	"Set expires of existing key or add a new key",
+	0
+};
+
+/*
+ * RPC command to set the expires of a key or add a new key
+ */
+static void auth_xkeys_rpc_set(rpc_t* rpc, void* ctx)
+{
+	auth_xkey_t tmp;
+	auth_xkey_t *itc;
+
+	memset(&tmp, 0, sizeof(auth_xkey_t));
+
+	if(rpc->scan(ctx, ".SSSd", &tmp.kid, &tmp.kname,
+				&tmp.kvalue, &tmp.kexpires)<4)
+	{
+		rpc->fault(ctx, 500, "Invalid Parameters");
+		return;
+	}
+	for(itc = *_auth_xkeys_list; itc; itc = itc->next_id) {
+		if(itc->kid.len==tmp.kid.len
+				&& strncasecmp(itc->kid.s, tmp.kid.s, tmp.kid.len)==0)
+			break;
+	}
+	if(itc==NULL) {
+		LM_DBG("no key chain id [%.*s]\n", tmp.kid.len, tmp.kid.s);
+		/* add one */
+		if(authx_xkey_insert(&tmp)<0) {
+			LM_ERR("unable to insert the key [%.*s:%.*s]\n",
+				tmp.kid.len, tmp.kid.s, tmp.kname.len, tmp.kname.s);
+			rpc->fault(ctx, 500, "Insert failure");
+			return;
+		}
+		return;
+	}
+	itc->kexpires = time(NULL) + tmp.kexpires;
+	return;
+}
+
+rpc_export_t auth_xkeys_rpc_cmds[] = {
+	{"auth_xkeys_.list",   auth_xkeys_rpc_list,
+		auth_xkeys_rpc_list_doc,   0},
+	{"auth_xkeys_.set",   auth_xkeys_rpc_set,
+		auth_xkeys_rpc_set_doc,   0},
+	{0, 0, 0, 0}
+};
+
+/**
+ *
+ */
+int auth_xkeys_init_rpc(void)
+{
+	if (rpc_register_array(auth_xkeys_rpc_cmds)!=0)
+	{
+		LM_ERR("failed to register RPC commands\n");
+		return -1;
+	}
+	return 0;
+}

+ 1 - 0
modules/auth_xkeys/auth_xkeys.h

@@ -30,5 +30,6 @@ int auth_xkeys_add(sip_msg_t* msg, str *hdr, str *key,
 		str *alg, str *data);
 int auth_xkeys_check(sip_msg_t* msg, str *hdr, str *key,
 		str *alg, str *data);
+int auth_xkeys_init_rpc(void);
 
 #endif

+ 5 - 0
modules/auth_xkeys/auth_xkeys_mod.c

@@ -93,6 +93,11 @@ struct module_exports exports = {
  */
 static int mod_init(void)
 {
+	if(auth_xkeys_init_rpc()<0)
+	{
+		LM_ERR("failed to register RPC commands\n");
+		return -1;
+	}
 	return 0;
 }
 

+ 2 - 2
modules/ims_qos/mod.c

@@ -362,8 +362,8 @@ void callback_dialog(struct dlg_cell* dlg, int type, struct dlg_cb_params * para
     
     LM_DBG("Dialog callback of type %d received\n", type);
     
-    if(type == DLGCB_TERMINATED || type == DLGCB_DESTROY || type == DLGCB_EXPIRED){
-	   LM_DBG("Dialog has ended - we need to terminate Rx bearer session\n");
+    if(type == DLGCB_TERMINATED || type == DLGCB_DESTROY || type == DLGCB_EXPIRED || type == DLGCB_FAILED){
+	   LM_DBG("Dialog has ended or failed - we need to terminate Rx bearer session\n");
 
 	LM_DBG("Received notification of termination of dialog with Rx session ID: [%.*s]\n",
 		rx_session_id->len, rx_session_id->s);

+ 1 - 1
modules/ims_qos/rx_aar.c

@@ -154,7 +154,7 @@ void async_aar_callback(int is_timeout, void *param, AAAMessage *aaa, long elaps
 	    STR_SHM_DUP(*passed_rx_session_id, aaa->sessionId->data, "cb_passed_rx_session_id");
 	    LM_DBG("passed rx session id [%.*s]", passed_rx_session_id->len, passed_rx_session_id->s);
 
-	    dlgb.register_dlgcb_nodlg(&data->callid, &data->ftag, &data->ttag, DLGCB_TERMINATED | DLGCB_DESTROY | DLGCB_EXPIRED | DLGCB_RESPONSE_WITHIN | DLGCB_CONFIRMED, callback_dialog, (void*) (passed_rx_session_id), free_dialog_data);
+	    dlgb.register_dlgcb_nodlg(&data->callid, &data->ftag, &data->ttag, DLGCB_TERMINATED | DLGCB_DESTROY | DLGCB_EXPIRED | DLGCB_RESPONSE_WITHIN | DLGCB_CONFIRMED | DLGCB_FAILED, callback_dialog, (void*) (passed_rx_session_id), free_dialog_data);
 	} 
         result = CSCF_RETURN_TRUE;
     } else {

+ 1 - 1
utils/kamctl/db_berkeley/kamailio/version

@@ -105,7 +105,7 @@ rtpproxy|1
 sca_subscriptions|
 sca_subscriptions|1
 silo|
-silo|7
+silo|8
 sip_trace|
 sip_trace|4
 speed_dial|

+ 1 - 1
utils/kamctl/db_sqlite/msilo-create.sql

@@ -1,4 +1,4 @@
-INSERT INTO version (table_name, table_version) values ('silo','7');
+INSERT INTO version (table_name, table_version) values ('silo','8');
 CREATE TABLE silo (
     id INTEGER PRIMARY KEY NOT NULL,
     src_addr VARCHAR(128) DEFAULT '' NOT NULL,

+ 1 - 1
utils/kamctl/dbtext/kamailio/version

@@ -47,7 +47,7 @@ rls_presentity:1
 rls_watchers:3
 rtpproxy:1
 sca_subscriptions:1
-silo:7
+silo:8
 sip_trace:4
 speed_dial:2
 subscriber:6

+ 1 - 1
utils/kamctl/mysql/msilo-create.sql

@@ -1,4 +1,4 @@
-INSERT INTO version (table_name, table_version) values ('silo','7');
+INSERT INTO version (table_name, table_version) values ('silo','8');
 CREATE TABLE silo (
     id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
     src_addr VARCHAR(128) DEFAULT '' NOT NULL,

+ 1 - 1
utils/kamctl/oracle/msilo-create.sql

@@ -1,4 +1,4 @@
-INSERT INTO version (table_name, table_version) values ('silo','7');
+INSERT INTO version (table_name, table_version) values ('silo','8');
 CREATE TABLE silo (
     id NUMBER(10) PRIMARY KEY,
     src_addr VARCHAR2(128) DEFAULT '',

+ 1 - 1
utils/kamctl/postgres/msilo-create.sql

@@ -1,4 +1,4 @@
-INSERT INTO version (table_name, table_version) values ('silo','7');
+INSERT INTO version (table_name, table_version) values ('silo','8');
 CREATE TABLE silo (
     id SERIAL PRIMARY KEY NOT NULL,
     src_addr VARCHAR(128) DEFAULT '' NOT NULL,