فهرست منبع

cdp: removed svn ids and fixed some clang compile warnings

Daniel-Constantin Mierla 9 سال پیش
والد
کامیت
fe2db1bf6f
62فایلهای تغییر یافته به همراه2824 افزوده شده و 2931 حذف شده
  1. 20 22
      modules/cdp/acceptor.c
  2. 9 11
      modules/cdp/acceptor.h
  3. 48 48
      modules/cdp/acctstatemachine.c
  4. 39 39
      modules/cdp/api_process.c
  5. 12 14
      modules/cdp/api_process.h
  6. 521 523
      modules/cdp/authstatemachine.c
  7. 11 13
      modules/cdp/authstatemachine.h
  8. 11 13
      modules/cdp/cdp_load.c
  9. 18 20
      modules/cdp/cdp_load.h
  10. 66 66
      modules/cdp/cdp_rpc.c
  11. 30 30
      modules/cdp/cdp_stats.c
  12. 5 5
      modules/cdp/cdp_stats.h
  13. 25 25
      modules/cdp/common.c
  14. 9 11
      modules/cdp/config.c
  15. 23 25
      modules/cdp/config.h
  16. 9 11
      modules/cdp/configdtd.h
  17. 189 191
      modules/cdp/configparser.c
  18. 13 15
      modules/cdp/diameter.h
  19. 14 16
      modules/cdp/diameter_api.h
  20. 94 96
      modules/cdp/diameter_avp.c
  21. 67 69
      modules/cdp/diameter_code_avp.h
  22. 16 18
      modules/cdp/diameter_code_result.h
  23. 35 37
      modules/cdp/diameter_comm.c
  24. 9 11
      modules/cdp/diameter_epc.h
  25. 9 11
      modules/cdp/diameter_epc_code_app.h
  26. 184 186
      modules/cdp/diameter_epc_code_avp.h
  27. 9 11
      modules/cdp/diameter_epc_code_cmd.h
  28. 10 12
      modules/cdp/diameter_epc_code_result.h
  29. 9 11
      modules/cdp/diameter_ims.h
  30. 11 13
      modules/cdp/diameter_ims_code_app.h
  31. 95 97
      modules/cdp/diameter_ims_code_avp.h
  32. 9 11
      modules/cdp/diameter_ims_code_cmd.h
  33. 9 11
      modules/cdp/diameter_ims_code_result.h
  34. 63 65
      modules/cdp/diameter_msg.c
  35. 9 11
      modules/cdp/diameter_peer.c
  36. 12 14
      modules/cdp/diameter_peer.h
  37. 9 11
      modules/cdp/globals.c
  38. 9 11
      modules/cdp/globals.h
  39. 50 52
      modules/cdp/mod.c
  40. 9 11
      modules/cdp/mod.h
  41. 17 19
      modules/cdp/peer.c
  42. 7 9
      modules/cdp/peer.h
  43. 16 18
      modules/cdp/peermanager.c
  44. 9 11
      modules/cdp/peermanager.h
  45. 165 166
      modules/cdp/peerstatemachine.c
  46. 9 11
      modules/cdp/peerstatemachine.h
  47. 72 75
      modules/cdp/receiver.c
  48. 15 17
      modules/cdp/receiver.h
  49. 176 176
      modules/cdp/routing.c
  50. 9 11
      modules/cdp/routing.h
  51. 30 32
      modules/cdp/sem.h
  52. 76 78
      modules/cdp/session.c
  53. 17 19
      modules/cdp/session.h
  54. 39 41
      modules/cdp/tcp_accept.c
  55. 9 11
      modules/cdp/tcp_accept.h
  56. 47 49
      modules/cdp/timer.c
  57. 11 13
      modules/cdp/timer.h
  58. 25 26
      modules/cdp/transaction.c
  59. 16 18
      modules/cdp/transaction.h
  60. 10 12
      modules/cdp/utils.h
  61. 238 238
      modules/cdp/worker.c
  62. 12 14
      modules/cdp/worker.h

+ 20 - 22
modules/cdp/acceptor.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include <unistd.h>
@@ -78,27 +76,27 @@ void acceptor_process(dp_config *cfg)
 {
 	int i,k;
 	unsigned int sock;
-	
+
 	LM_INFO("Acceptor process starting up...\n");
 	listening_socks = pkg_malloc((cfg->acceptors_cnt+1)*sizeof(int));
 	if (!listening_socks){
 		LOG_NO_MEM("pkg",(cfg->acceptors_cnt+1)*sizeof(int));
 		goto done;
 	}
-	memset(listening_socks,0,(cfg->acceptors_cnt+1)*sizeof(int));	
+	memset(listening_socks,0,(cfg->acceptors_cnt+1)*sizeof(int));
 	k=0;
 	for(i=0;i<cfg->acceptors_cnt;i++)
 		if (create_socket(cfg->acceptors[i].port,cfg->acceptors[i].bind,&sock)){
-			listening_socks[k++]=sock;			
-		}	
+			listening_socks[k++]=sock;
+		}
+
 
-	
-	LM_INFO("Acceptor opened sockets. Entering accept loop ...\n");		
+	LM_INFO("Acceptor opened sockets. Entering accept loop ...\n");
 	accept_loop();
 
 	for(i=0;listening_socks[i];i++)
 		close(listening_socks[i]);
-	
+
 	if (listening_socks) pkg_free(listening_socks);
 #ifdef CDP_FOR_SER
 #else
@@ -108,12 +106,12 @@ void acceptor_process(dp_config *cfg)
 		//pkg_status();
 		#ifdef pkg_sums
 			pkg_sums();
-		#endif 
+		#endif
 	#endif
 #endif
-		dp_del_pid(getpid());		
-#endif		
-done:		
+		dp_del_pid(getpid());
+#endif
+done:
 	LM_INFO("Acceptor process finished\n");
 	exit(0);
 }

+ 9 - 11
modules/cdp/acceptor.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __ACCEPTOR_H

+ 48 - 48
modules/cdp/acctstatemachine.c

@@ -31,10 +31,10 @@ inline void update_gsu_response_timers(cdp_cc_acc_session_t* session, AAAMessage
 	AAA_AVP *z;
 
 	avp = AAAFindMatchingAVP(msg, 0, AVP_Multiple_Services_Credit_Control, 0, 0);
-        if (!avp) {
-            LM_WARN("Trying to update GSU timers but there is no MSCC AVP in the CCA response\n");
-            return;
-        }
+	if (!avp) {
+		LM_WARN("Trying to update GSU timers but there is no MSCC AVP in the CCA response\n");
+		return;
+	}
 	mscc_avp_list = AAAUngroupAVPS(avp->data);
 	AAA_AVP *mscc_avp = mscc_avp_list.head;
 
@@ -46,11 +46,11 @@ inline void update_gsu_response_timers(cdp_cc_acc_session_t* session, AAAMessage
 				z = y.head;
 				while (z) {
 					switch (z->code) {
-					case AVP_CC_Time:
-						session->reserved_units = get_4bytes(z->data.s);
-						break;
-					default:
-						LM_DBG("ignoring AVP in GSU group with code:[%d]\n", z->code);
+						case AVP_CC_Time:
+							session->reserved_units = get_4bytes(z->data.s);
+							break;
+						default:
+							LM_DBG("ignoring AVP in GSU group with code:[%d]\n", z->code);
 					}
 					z = z->next;
 				}
@@ -197,54 +197,54 @@ inline int cc_acc_client_stateful_sm_process(cdp_session_t* s, int event, AAAMes
 			switch (event) {
 				case ACC_CC_EV_RECV_ANS_SUCCESS:
 					x->state = ACC_CC_ST_DISCON;
-//					update_gsu_response_timers(x, msg);
+					//					update_gsu_response_timers(x, msg);
 				case ACC_CC_EV_RECV_ANS_UNSUCCESS:
 					x->state = ACC_CC_ST_DISCON;
 				default:
 					LM_DBG("Received event [%d] in state [%d] - cleaning up session regardless\n", event, x->state);
 					//have to leave session alone because our client app still has to be given this msg
 					x->discon_time = time(0);
-//					if (msg) AAAFreeMessage(&msg);
-//					cdp_session_cleanup(s, NULL);
-//					s = 0;
+					//					if (msg) AAAFreeMessage(&msg);
+					//					cdp_session_cleanup(s, NULL);
+					//					s = 0;
 			}
 			break;
 		case ACC_CC_ST_PENDING_U:
-			
-                        /**Richard added Aug 5 - there is a potential race condition where you may send a CCR-U immediately followed by CCR-T
-                         * and then receive a CCA-T while in state ACC_CC_ST_PENDING_U (e.g. if update timer and dialog termination at same time)  
-                         * In this event you would incorrectly ignore the CCR-T
-                         * Solution is to change state to change state to ACC_CC_ST_PENDING_T if CCR-T is sent while in this state  */
-                        if (event == ACC_CC_EV_SEND_REQ && msg && get_accounting_record_type(msg) == 4 /*TERMINATE RECORD*/) {
-                                LM_ERR("Received CCR-T while in state ACC_CC_ST_PENDING_U, just going to change to ACC_CC_ST_PENDING_T\n");
-                                s->u.cc_acc.state = ACC_CC_ST_PENDING_T;
-                                //update our reservation and its timers...
-                                update_gsu_request_timers(x, msg);
-                        } else {
-                            if (event == ACC_CC_EV_RECV_ANS && msg && !is_req(msg)) {
-                                    rc = get_result_code(msg);
-                                    if (rc >= 2000 && rc < 3000) {
-                                            event = ACC_CC_EV_RECV_ANS_SUCCESS;
-                                    } else {
-                                            event = ACC_CC_EV_RECV_ANS_UNSUCCESS;
-                                    }
-                            }
-                            switch (event) {
-                                    case ACC_CC_EV_RECV_ANS_SUCCESS:
-                                            x->state = ACC_CC_ST_OPEN;
-                                            LM_DBG("success CCA for UPDATE\n");
-                                            update_gsu_response_timers(x, msg);
-                                            break;
-                                    case ACC_CC_EV_RECV_ANS_UNSUCCESS:
-                                            //TODO: check whether we grant or terminate service to callback clients
-                                            x->state = ACC_CC_ST_DISCON;
-                                            LM_ERR("update failed... going back to IDLE/DISCON\n");
-                                            break;
-                                    default:
-                                            LM_ERR("Received unknown event [%d] in state [%d]\n", event, x->state);
-                                    break;
-                            }
-                        }
+
+			/**Richard added Aug 5 - there is a potential race condition where you may send a CCR-U immediately followed by CCR-T
+			 * and then receive a CCA-T while in state ACC_CC_ST_PENDING_U (e.g. if update timer and dialog termination at same time)
+			 * In this event you would incorrectly ignore the CCR-T
+			 * Solution is to change state to change state to ACC_CC_ST_PENDING_T if CCR-T is sent while in this state  */
+			if (event == ACC_CC_EV_SEND_REQ && msg && get_accounting_record_type(msg) == 4 /*TERMINATE RECORD*/) {
+				LM_ERR("Received CCR-T while in state ACC_CC_ST_PENDING_U, just going to change to ACC_CC_ST_PENDING_T\n");
+				s->u.cc_acc.state = ACC_CC_ST_PENDING_T;
+				//update our reservation and its timers...
+				update_gsu_request_timers(x, msg);
+			} else {
+				if (event == ACC_CC_EV_RECV_ANS && msg && !is_req(msg)) {
+					rc = get_result_code(msg);
+					if (rc >= 2000 && rc < 3000) {
+						event = ACC_CC_EV_RECV_ANS_SUCCESS;
+					} else {
+						event = ACC_CC_EV_RECV_ANS_UNSUCCESS;
+					}
+				}
+				switch (event) {
+					case ACC_CC_EV_RECV_ANS_SUCCESS:
+						x->state = ACC_CC_ST_OPEN;
+						LM_DBG("success CCA for UPDATE\n");
+						update_gsu_response_timers(x, msg);
+						break;
+					case ACC_CC_EV_RECV_ANS_UNSUCCESS:
+						//TODO: check whether we grant or terminate service to callback clients
+						x->state = ACC_CC_ST_DISCON;
+						LM_ERR("update failed... going back to IDLE/DISCON\n");
+						break;
+					default:
+						LM_ERR("Received unknown event [%d] in state [%d]\n", event, x->state);
+						break;
+				}
+			}
 			break;
 		case ACC_CC_ST_DISCON:
 			switch (event) {

+ 39 - 39
modules/cdp/api_process.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include "api_process.h"
@@ -77,25 +75,25 @@ int api_callback(peer *p,AAAMessage *msg,void* ptr)
 	else type=RESPONSE_HANDLER;
 
 	lock_get(handlers_lock);
-		for(h=handlers->head;h;h=h->next){
-			if (h->type==type){
-				x.handler = h->handler;
-				if (h->type == REQUEST_HANDLER) {
-					lock_release(handlers_lock);
-					rsp = (x.handler.requestHandler)(msg,h->param);
-					if (rsp) {
-						//peer_send_msg(p,rsp);
-						sm_process(p,Send_Message,rsp,0,0);
-					}
-					lock_get(handlers_lock);
-				}
-				else {
-					lock_release(handlers_lock);
-					(x.handler.responseHandler)(msg,h->param);
-					lock_get(handlers_lock);
+	for(h=handlers->head;h;h=h->next){
+		if (h->type==type){
+			x.handler = h->handler;
+			if (h->type == REQUEST_HANDLER) {
+				lock_release(handlers_lock);
+				rsp = (x.handler.requestHandler)(msg,h->param);
+				if (rsp) {
+					//peer_send_msg(p,rsp);
+					sm_process(p,Send_Message,rsp,0,0);
 				}
+				lock_get(handlers_lock);
+			}
+			else {
+				lock_release(handlers_lock);
+				(x.handler.responseHandler)(msg,h->param);
+				lock_get(handlers_lock);
 			}
 		}
+	}
 	lock_release(handlers_lock);
 
 	if (!is_req(msg)){
@@ -103,18 +101,20 @@ int api_callback(peer *p,AAAMessage *msg,void* ptr)
 		t = cdp_take_trans(msg);
 		if (t){
 			t->ans = msg;
-            struct timeval stop;
-            gettimeofday(&stop, NULL);
-            long elapsed_usecs =  (stop.tv_sec - t->started.tv_sec)*1000000 + (stop.tv_usec - t->started.tv_usec);
-            long elapsed_msecs = elapsed_usecs/1000;
-            if (elapsed_msecs > *latency_threshold_p) {
-                if (msg->sessionId && msg->sessionId->data.len)
-                    LM_ERR("Received diameter response outside of threshold (%d) - %ld (session-id: [%.*s])\n", *latency_threshold_p, elapsed_msecs, msg->sessionId->data.len, msg->sessionId->data.s);
-                else 
-                    LM_ERR("Received diameter response outside of threshold (%d) - %ld (no session-id)\n", *latency_threshold_p, elapsed_msecs);
-            }
-	    counter_inc(cdp_cnts_h.replies_received);
-	    counter_add(cdp_cnts_h.replies_response_time, elapsed_msecs);
+			struct timeval stop;
+			gettimeofday(&stop, NULL);
+			long elapsed_usecs =  (stop.tv_sec - t->started.tv_sec)*1000000 + (stop.tv_usec - t->started.tv_usec);
+			long elapsed_msecs = elapsed_usecs/1000;
+			if (elapsed_msecs > *latency_threshold_p) {
+				if (msg->sessionId && msg->sessionId->data.len)
+					LM_ERR("Received diameter response outside of threshold (%d) - %ld (session-id: [%.*s])\n",
+							*latency_threshold_p, elapsed_msecs, msg->sessionId->data.len, msg->sessionId->data.s);
+				else
+					LM_ERR("Received diameter response outside of threshold (%d) - %ld (no session-id)\n",
+							*latency_threshold_p, elapsed_msecs);
+			}
+			counter_inc(cdp_cnts_h.replies_received);
+			counter_add(cdp_cnts_h.replies_response_time, elapsed_msecs);
 			auto_drop = t->auto_drop;
 			if (t->cb){
 				(t->cb)(0,*(t->ptr),msg, elapsed_msecs);

+ 12 - 14
modules/cdp/api_process.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __CDP_API_PROCESS_H_
@@ -59,7 +57,7 @@ enum handler_types {
 
 /**
  * Diameter message received handler list element.
- */ 
+ */
 typedef struct handler_t{
 	enum handler_types type;					/**< type of the handler */
 	union {
@@ -70,12 +68,12 @@ typedef struct handler_t{
 	struct handler_t *next;				/**< next handler in the list */
 	struct handler_t *prev;				/**< prev handler in the list */
 } handler;
-		
+
 typedef struct handler_list_t{
 	handler *head;				/**< first handler in the list */
 	handler *tail;				/**< last handler in the list */
 } handler_list;
-		
+
 int api_callback(peer *p,AAAMessage *msg,void* ptr);
 
 #endif /*API_PROCESS_H_*/

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 521 - 523
modules/cdp/authstatemachine.c


+ 11 - 13
modules/cdp/authstatemachine.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __AUTHSTATEMACHINE_H
@@ -52,8 +50,8 @@
 
 void update_auth_session_timers(cdp_auth_session_t *x,AAAMessage *msg);
 
-inline int auth_client_statefull_sm_process(cdp_session_t* auth, int event, AAAMessage* msg);
-inline void auth_server_statefull_sm_process(cdp_session_t* auth, int event, AAAMessage* msg);
+int auth_client_statefull_sm_process(cdp_session_t* auth, int event, AAAMessage* msg);
+void auth_server_statefull_sm_process(cdp_session_t* auth, int event, AAAMessage* msg);
 
 void auth_client_stateless_sm_process(cdp_session_t* s, int event, AAAMessage *msg);
 void auth_server_stateless_sm_process(cdp_session_t* auth, int event, AAAMessage* msg);

+ 11 - 13
modules/cdp/cdp_load.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include "cdp_load.h"
@@ -62,7 +60,7 @@
  * Load the CDiameterPeer bindings
  * @param *cdpb - target structure to load the bindings into
  * @returns 1 on success, -1 on failure
- */  
+ */
 int load_cdp( struct cdp_binds *cdpb)
 {
 	FIND_EXP(AAACreateRequest);
@@ -103,7 +101,7 @@ int load_cdp( struct cdp_binds *cdpb)
 	FIND_EXP(AAAGetAuthSession);
 	FIND_EXP(AAADropAuthSession);
 	FIND_EXP(AAATerminateAuthSession);
-	
+
 	/* Credit Control Application API - RFC 4006 */
 	FIND_EXP(AAACreateCCAccSession);
 	FIND_EXP(AAAStartChargingCCAccSession);

+ 18 - 20
modules/cdp/cdp_load.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef _CDP_BIND_H
@@ -58,10 +56,10 @@
 
 struct cdp_binds {
 	AAACreateRequest_f			AAACreateRequest;
-	AAACreateResponse_f			AAACreateResponse;	
+	AAACreateResponse_f			AAACreateResponse;
 	AAAFreeMessage_f			AAAFreeMessage;
-	
-	
+
+
 	AAACreateAVP_f				AAACreateAVP;
 	AAAAddAVPToMessage_f		AAAAddAVPToMessage;
 	AAAAddAVPToList_f			AAAAddAVPToList;
@@ -77,16 +75,16 @@ struct cdp_binds {
 	AAASendMessageToPeer_f		AAASendMessageToPeer;
 	AAASendRecvMessage_f		AAASendRecvMessage;
 	AAASendRecvMessageToPeer_f	AAASendRecvMessageToPeer;
-	
-	
+
+
 	AAAAddRequestHandler_f		AAAAddRequestHandler;
 	AAAAddResponseHandler_f		AAAAddResponseHandler;
 
 
 	AAACreateTransaction_f		AAACreateTransaction;
 	AAADropTransaction_f		AAADropTransaction;
-	
-	
+
+
 	AAACreateSession_f			AAACreateSession;
 	AAAMakeSession_f			AAAMakeSession;
 	AAAGetSession_f				AAAGetSession;
@@ -120,12 +118,12 @@ static inline int load_cdp_api(struct cdp_binds* cdpb)
 
 	/* import the TM auto-loading function */
 	load_cdp = (load_cdp_f)find_export("load_cdp", NO_SCRIPT, 0);
-	
+
 	if (load_cdp == NULL) {
 		LM_WARN("Cannot import load_cdp function from CDP module\n");
 		return -1;
 	}
-	
+
 	/* let the auto-loading function load all TM stuff */
 	if (load_cdp(cdpb) == -1) {
 		return -1;

+ 66 - 66
modules/cdp/cdp_rpc.c

@@ -63,73 +63,73 @@ static void cdp_rpc_disable_peer(rpc_t* rpc, void* ctx)
 
 static void cdp_rpc_list_peers(rpc_t* rpc, void* ctx)
 {
-    void *peers_header;
-    void *peers_container;
-    void *peerdetail_container;
-    void *peerapplication_container;
-    peer *i, *j;
-    int c;
-    char buf[100];
-
-    if (rpc->add(ctx, "{", &peers_header) < 0) {
-            rpc->fault(ctx, 500, "Internal error creating top rpc");
-            return;
-    }
-
-    if (rpc->struct_add(peers_header, "SSddddddd{",
-                            "Realm", &config->realm,
-                            "Identity", &config->identity,
-                            "Accept unknown peers", config->accept_unknown_peers,
-                            "Connect timeout", config->connect_timeout,
-                            "Transaction timeout", config->transaction_timeout,
-                            "Default auth session timeout", config->default_auth_session_timeout,
-                            "Queue length", config->queue_length,
-                            "Workers", config->workers,
-                            "Peer count", config->peers_cnt,
-                            "Peers", &peers_container) < 0) {
-            rpc->fault(ctx, 500, "Internal error creating peers header struct");
-            return;
-    }
-
-    lock_get(peer_list_lock);
-    i = peer_list->head;
-    while (i) {
-    		lock_get(i->lock);
-    		if (rpc->struct_add(peers_container, "S{",
-                            "FQDN", &i->fqdn,
-                            "Details", &peerdetail_container) < 0) {
-                    rpc->fault(ctx, 500, "Internal error creating peers container struct");
-                    lock_release(i->lock);
-                    return;
-            }
-            if (rpc->struct_add(peerdetail_container, "ssd",
-                    "State", dp_states[(int)i->state],
-                    "Disabled", i->disabled?"True":"False",
-            		"Last used", i->last_selected) < 0) {
-                    rpc->fault(ctx, 500, "Internal error creating peer detail container struct");
-                    lock_release(i->lock);
-                    return;
-            }
-            if (rpc->struct_add(peerdetail_container, "{", "Applications", &peerapplication_container) < 0) {
-            	rpc->fault(ctx, 500, "Internal error creating peer application container struct");
-            	lock_release(i->lock);
-            	return;
-            }
-
-            for (c = 0; c < i->applications_cnt; c++) {
-            	snprintf(buf, 100, "%d:%d", i->applications[c].id, i->applications[c].vendor);
-            	if (rpc->struct_add(peerapplication_container, "s",
+	void *peers_header;
+	void *peers_container;
+	void *peerdetail_container;
+	void *peerapplication_container;
+	peer *i, *j;
+	int c;
+	char buf[100];
+
+	if (rpc->add(ctx, "{", &peers_header) < 0) {
+		rpc->fault(ctx, 500, "Internal error creating top rpc");
+		return;
+	}
+
+	if (rpc->struct_add(peers_header, "SSddddddd{",
+				"Realm", &config->realm,
+				"Identity", &config->identity,
+				"Accept unknown peers", config->accept_unknown_peers,
+				"Connect timeout", config->connect_timeout,
+				"Transaction timeout", config->transaction_timeout,
+				"Default auth session timeout", config->default_auth_session_timeout,
+				"Queue length", config->queue_length,
+				"Workers", config->workers,
+				"Peer count", config->peers_cnt,
+				"Peers", &peers_container) < 0) {
+		rpc->fault(ctx, 500, "Internal error creating peers header struct");
+		return;
+	}
+
+	lock_get(peer_list_lock);
+	i = peer_list->head;
+	while (i) {
+		lock_get(i->lock);
+		if (rpc->struct_add(peers_container, "S{",
+					"FQDN", &i->fqdn,
+					"Details", &peerdetail_container) < 0) {
+			rpc->fault(ctx, 500, "Internal error creating peers container struct");
+			lock_release(i->lock);
+			return;
+		}
+		if (rpc->struct_add(peerdetail_container, "ssd",
+					"State", dp_states[(int)i->state],
+					"Disabled", i->disabled?"True":"False",
+					"Last used", i->last_selected) < 0) {
+			rpc->fault(ctx, 500, "Internal error creating peer detail container struct");
+			lock_release(i->lock);
+			return;
+		}
+		if (rpc->struct_add(peerdetail_container, "{", "Applications", &peerapplication_container) < 0) {
+			rpc->fault(ctx, 500, "Internal error creating peer application container struct");
+			lock_release(i->lock);
+			return;
+		}
+
+		for (c = 0; c < i->applications_cnt; c++) {
+			snprintf(buf, 100, "%d:%d", i->applications[c].id, i->applications[c].vendor);
+			if (rpc->struct_add(peerapplication_container, "s",
 						"appid:vendorid", buf) < 0) {
-					rpc->fault(ctx, 500, "Internal error creating appid/vendorid information");
-					lock_release(i->lock);
-					return;
-				}
-            }
-            j=i;
-            i = i->next;
-            lock_release(j->lock);
-    }
-    lock_release(peer_list_lock);
+				rpc->fault(ctx, 500, "Internal error creating appid/vendorid information");
+				lock_release(i->lock);
+				return;
+			}
+		}
+		j=i;
+		i = i->next;
+		lock_release(j->lock);
+	}
+	lock_release(peer_list_lock);
 }
 
 rpc_export_t cdp_rpc[] = {

+ 30 - 30
modules/cdp/cdp_stats.c

@@ -6,44 +6,44 @@ enum sctp_info_req { CDP_AVG_RSP };
 static counter_val_t cdp_internal_stats(counter_handle_t h, void* what);
 
 counter_def_t cdp_cnt_defs[] = {
-    {&cdp_cnts_h.timeout, "timeout", 0, 0, 0,
-	"number of timeouts on CDP requests"},
-    {&cdp_cnts_h.replies_received, "replies_received", 0, 0, 0,
-	"total number of replies received"},
-    {&cdp_cnts_h.replies_response_time, "replies_response_time", 0, 0, 0,
-	"total time waiting for replies"},
-    {&cdp_cnts_h.queuelength, "queuelength", 0, 0, 0,
-	"current length of worker queue tasks"},
-    {0, "average_response_time", 0,
-	cdp_internal_stats, (void*) (long) CDP_AVG_RSP,
-	"average response time for CDP replies"},
-    {0, 0, 0, 0, 0, 0}
+	{&cdp_cnts_h.timeout, "timeout", 0, 0, 0,
+		"number of timeouts on CDP requests"},
+	{&cdp_cnts_h.replies_received, "replies_received", 0, 0, 0,
+		"total number of replies received"},
+	{&cdp_cnts_h.replies_response_time, "replies_response_time", 0, 0, 0,
+		"total time waiting for replies"},
+	{&cdp_cnts_h.queuelength, "queuelength", 0, 0, 0,
+		"current length of worker queue tasks"},
+	{0, "average_response_time", 0,
+		cdp_internal_stats, (void*) (long) CDP_AVG_RSP,
+		"average response time for CDP replies"},
+	{0, 0, 0, 0, 0, 0}
 };
 
 int cdp_init_counters() {
-    if (counter_register_array("cdp", cdp_cnt_defs) < 0)
-	goto error;
-    return 0;
+	if (counter_register_array("cdp", cdp_cnt_defs) < 0)
+		goto error;
+	return 0;
 error:
-    return -1;
+	return -1;
 }
 
 void cdp_destroy_counters() {
-    
+
 }
 
 /** helper function for some stats (which are kept internally).
- */
+*/
 static counter_val_t cdp_internal_stats(counter_handle_t h, void* what) {
-    enum sctp_info_req w;
-
-    w = (int) (long) what;
-    switch (w) {
-	case CDP_AVG_RSP:
-	    if (counter_get_val(cdp_cnts_h.replies_received) == 0) 
-		return 0;
-	    else
-		return counter_get_val(cdp_cnts_h.replies_response_time)/counter_get_val(cdp_cnts_h.replies_received);
-    };
-    return 0;
-}
+	enum sctp_info_req w;
+
+	w = (int) (long) what;
+	switch (w) {
+		case CDP_AVG_RSP:
+			if (counter_get_val(cdp_cnts_h.replies_received) == 0)
+				return 0;
+			else
+				return counter_get_val(cdp_cnts_h.replies_response_time)/counter_get_val(cdp_cnts_h.replies_received);
+	};
+	return 0;
+}

+ 5 - 5
modules/cdp/cdp_stats.h

@@ -4,11 +4,11 @@
 #include "../../counters.h"
 
 struct cdp_counters_h {
-    counter_handle_t timeout;
-    counter_handle_t replies_received;
-    counter_handle_t replies_response_time;
-    counter_handle_t avg_response_time;
-    counter_handle_t queuelength;
+	counter_handle_t timeout;
+	counter_handle_t replies_received;
+	counter_handle_t replies_response_time;
+	counter_handle_t avg_response_time;
+	counter_handle_t queuelength;
 };
 
 int cdp_init_counters();

+ 25 - 25
modules/cdp/common.c

@@ -18,35 +18,35 @@ int get_accounting_record_type(AAAMessage* msg) {
 }
 
 int get_result_code(AAAMessage* msg) {
-    AAA_AVP *avp;
-    AAA_AVP_LIST list;
-    list.head = 0;
-    list.tail = 0;
-    int rc = -1;
+	AAA_AVP *avp;
+	AAA_AVP_LIST list;
+	list.head = 0;
+	list.tail = 0;
+	int rc = -1;
 
-    if (!msg) goto error;
+	if (!msg) goto error;
 
-    for (avp = msg->avpList.tail; avp; avp = avp->prev) {
+	for (avp = msg->avpList.tail; avp; avp = avp->prev) {
 
-        if (avp->code == AVP_Result_Code) {
-            rc = get_4bytes(avp->data.s);
-            goto finish;
-        } else if (avp->code == AVP_Experimental_Result) {
-            list = AAAUngroupAVPS(avp->data);
-            for (avp = list.head; avp; avp = avp->next) {
-                if (avp->code == AVP_IMS_Experimental_Result_Code) {
-                    rc = get_4bytes(avp->data.s);
-                    AAAFreeAVPList(&list);
-                    goto finish;
-                }
-            }
-            AAAFreeAVPList(&list);
-        }
-    }
+		if (avp->code == AVP_Result_Code) {
+			rc = get_4bytes(avp->data.s);
+			goto finish;
+		} else if (avp->code == AVP_Experimental_Result) {
+			list = AAAUngroupAVPS(avp->data);
+			for (avp = list.head; avp; avp = avp->next) {
+				if (avp->code == AVP_IMS_Experimental_Result_Code) {
+					rc = get_4bytes(avp->data.s);
+					AAAFreeAVPList(&list);
+					goto finish;
+				}
+			}
+			AAAFreeAVPList(&list);
+		}
+	}
 finish:
-    return rc;
+	return rc;
 error:
-    LM_ERR("get_result_code(): no AAAMessage or Result Code not found\n");
-    return -1;
+	LM_ERR("get_result_code(): no AAAMessage or Result Code not found\n");
+	return -1;
 }
 

+ 9 - 11
modules/cdp/config.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include "config.h"

+ 23 - 25
modules/cdp/config.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __CONFIG_H_
@@ -54,13 +52,13 @@ typedef struct{
 	str fqdn;	/**< FQDN of the peer */
 	str realm;	/**< Realm of the peer */
 	int port;	/**< TCP port of the peer; the Diameter uri is then aaa://fqdn:port. */
-    str src_addr; /**< IP address used to connect to the peer */
+	str src_addr; /**< IP address used to connect to the peer */
 } peer_config;
 
 
 /** Acceptor socket configuration. */
 typedef struct{
-	int port;	/**< TCP port number to listen on */ 
+	int port;	/**< TCP port number to listen on */
 	str bind;	/**< IP address to bind to (if null, then :: (0.0.0.0) - all) */
 } acceptor_config;
 
@@ -105,32 +103,32 @@ typedef struct {
 	str product_name;			/**< own product name */
 	int accept_unknown_peers;	/**< if to accept connections from peers that are not configured initially */
 	int drop_unknown_peers;		/**< if to drop the peers that are not initially configured on disconnected;
-									 usually, you want to do this, unless you want your list of peers to
-									 grow and you want to try and connect back to everybody that connected 
-									 to you before */
+								 * usually, you want to do this, unless you want your list of peers to
+								 * grow and you want to try and connect back to everybody that connected
+								 * to you before */
 	int tc;						/**< Tc timer duration (30 seconds should be) */
 	int workers;				/**< Number of worker-processes to fork */
 	int queue_length;			/**< Length of the message queue; when it is filled, the server part will
-									 block until workers will finish work on at least one item in the queue */
+								 * block until workers will finish work on at least one item in the queue */
 	int connect_timeout;		/**< Connect timeout for outbound connections */
 	int transaction_timeout;	/**< Transaction timeout duration */
-	
-	int sessions_hash_size;		/**< Size of the sessions hash table */									 
-	int default_auth_session_timeout; /** The default Authorization Session Timeout to use if none other indicated */ 
-	int max_auth_session_timeout;	  /** The max Authorization Session Timeout limit */ 
-	
+
+	int sessions_hash_size;		/**< Size of the sessions hash table */
+	int default_auth_session_timeout; /** The default Authorization Session Timeout to use if none other indicated */
+	int max_auth_session_timeout;	  /** The max Authorization Session Timeout limit */
+
 	peer_config *peers;			/**< list of peers */
 	int peers_cnt;				/**< size of the list of peers */
-	
+
 	acceptor_config *acceptors;	/**< list of acceptors */
 	int acceptors_cnt;			/**< size of the list of acceptors */
-	
+
 	app_config *applications;	/**< list of supported applications */
 	int applications_cnt;		/**< size of list of supported applications*/
 
 	int *supported_vendors;		/**< list of supported vendor ids */
 	int supported_vendors_cnt;	/**< size of list of supported vendor ids */
-	
+
 	routing_table *r_table;		/**< realm routing table */
 } dp_config;
 

+ 9 - 11
modules/cdp/configdtd.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #define DP_CONFIG_DTD "\

+ 189 - 191
modules/cdp/configparser.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include "config.h"
@@ -51,7 +49,7 @@
 #include <string.h>
 
 extern int errno;
-	
+
 static xmlValidCtxt	cvp;	/**< XML Validation context */
 
 /**
@@ -67,7 +65,7 @@ static inline int parser_init()
 }
 
 /**
- * Destroys the parser 
+ * Destroys the parser
  */
 static inline void parser_destroy()
 {
@@ -121,17 +119,17 @@ xmlDocPtr parse_dp_config_file(char* filename)
 		goto error;
 	}
 	fclose(f);
-	
+
 	doc = xmlParseFile(filename);
 	if (!doc){
 		LM_ERR("parse_dp_config_file():  This is not a valid XML file <%s>\n",
-			filename);
+				filename);
 		goto error;
 	}
-	
+
 	return doc;
 error:
-	return 0;		
+	return 0;
 }
 
 /**
@@ -142,7 +140,7 @@ error:
 xmlDocPtr parse_dp_config_str(str config_str)
 {
 	xmlDocPtr doc;
-	
+
 	char c = config_str.s[config_str.len];
 	if (!config_str.len){
 		LM_ERR("ERROR:parse_dp_config_str(): empty string\n");
@@ -156,19 +154,19 @@ xmlDocPtr parse_dp_config_str(str config_str)
 
 	if (!doc){
 		LM_ERR("parse_dp_config_file():  This is not a valid XML string <%.*s>\n",
-			config_str.len,config_str.s);
+				config_str.len,config_str.s);
 		goto error;
 	}
-	
+
 	return  doc;
 error:
-	return 0;		
+	return 0;
 }
 
 /**
  * Parses a DiameterPeer configuration file.
  * @param filename - path to the file
- * @returns the dp_config* structure containing the parsed configuration  
+ * @returns the dp_config* structure containing the parsed configuration
  */
 dp_config* parse_dp_config(xmlDocPtr doc)
 {
@@ -178,10 +176,10 @@ dp_config* parse_dp_config(xmlDocPtr doc)
 	int k;
 	routing_entry *re,*rei;
 	routing_realm *rr,*rri;
-	
+
 	if (!doc)
 		goto error;
-		
+
 	x = new_dp_config();
 
 	root = xmlDocGetRootElement(doc);
@@ -203,13 +201,13 @@ dp_config* parse_dp_config(xmlDocPtr doc)
 		quote_trim_dup(&(x->identity),(char*)xc);
 		xmlFree(xc);
 	}
-	
+
 	xc = xmlGetProp(root,(xmlChar*)"Realm");
 	if (xc){
 		quote_trim_dup(&(x->realm),(char*)xc);
 		xmlFree(xc);
 	}
-	
+
 	xc = xmlGetProp(root,(xmlChar*)"Vendor_Id");
 	if (xc) x->vendor_id = atoi((char*)xc);
 	else x->vendor_id = 0;
@@ -219,15 +217,15 @@ dp_config* parse_dp_config(xmlDocPtr doc)
 		quote_trim_dup(&(x->product_name),(char*)xc);
 		xmlFree(xc);
 	}
-	
+
 	xc = xmlGetProp(root,(xmlChar*)"AcceptUnknownPeers");
 	if (xc) {x->accept_unknown_peers = atoi((char*)xc);xmlFree(xc);}
 	else x->accept_unknown_peers = 1;
-	
+
 	xc = xmlGetProp(root,(xmlChar*)"DropUnknownOnDisconnect");
 	if (xc) {x->drop_unknown_peers = atoi((char*)xc);xmlFree(xc);}
 	else x->drop_unknown_peers = 1;
-	
+
 	xc = xmlGetProp(root,(xmlChar*)"Tc");
 	if (xc) {x->tc = atoi((char*)xc);xmlFree(xc);}
 	else x->tc = 30;
@@ -247,7 +245,7 @@ dp_config* parse_dp_config(xmlDocPtr doc)
 	xc = xmlGetProp(root,(xmlChar*)"TransactionTimeout");
 	if (xc) {x->transaction_timeout = atoi((char*)xc);xmlFree(xc);}
 	else x->transaction_timeout = 5;
-	
+
 	xc = xmlGetProp(root,(xmlChar*)"SessionsHashSize");
 	if (xc) {x->sessions_hash_size = atoi((char*)xc);xmlFree(xc);}
 	else x->sessions_hash_size = 128;
@@ -259,28 +257,28 @@ dp_config* parse_dp_config(xmlDocPtr doc)
 	xc = xmlGetProp(root,(xmlChar*)"MaxAuthSessionTimeout");
 	if (xc) {x->max_auth_session_timeout = atoi((char*)xc);xmlFree(xc);}
 	else x->max_auth_session_timeout = 300;
-	
+
 	for(child = root->children; child; child = child->next)
 		if (child->type == XML_ELEMENT_NODE)
-	{
-		if (xmlStrlen(child->name)==4 && strncasecmp((char*)child->name,"Peer",4)==0){
-			//PEER
-			x->peers_cnt++;		
-		}
-		else if (xmlStrlen(child->name)==8 && strncasecmp((char*)child->name,"Acceptor",8)==0){
-			//Acceptor
-			x->acceptors_cnt++;		
+		{
+			if (xmlStrlen(child->name)==4 && strncasecmp((char*)child->name,"Peer",4)==0){
+				//PEER
+				x->peers_cnt++;
+			}
+			else if (xmlStrlen(child->name)==8 && strncasecmp((char*)child->name,"Acceptor",8)==0){
+				//Acceptor
+				x->acceptors_cnt++;
+			}
+			else if (xmlStrlen(child->name)==4 && (strncasecmp((char*)child->name,"Auth",4)==0||
+						strncasecmp((char*)child->name,"Acct",4)==0)){
+				//Application
+				x->applications_cnt++;
+			}
+			else if (xmlStrlen(child->name)==15 && (strncasecmp((char*)child->name,"SupportedVendor",15)==0)){
+				//SupportedVendor
+				x->supported_vendors_cnt++;
+			}
 		}
-		else if (xmlStrlen(child->name)==4 && (strncasecmp((char*)child->name,"Auth",4)==0||
-			strncasecmp((char*)child->name,"Acct",4)==0)){
-			//Application
-			x->applications_cnt++;		
-		}	
-		else if (xmlStrlen(child->name)==15 && (strncasecmp((char*)child->name,"SupportedVendor",15)==0)){
-			//SupportedVendor
-			x->supported_vendors_cnt++;		
-		}	
-	}
 	x->peers = shm_malloc(x->peers_cnt*sizeof(peer_config));
 	if (!x->peers){
 		LOG_NO_MEM("shm",x->peers_cnt*sizeof(peer_config));
@@ -313,173 +311,173 @@ dp_config* parse_dp_config(xmlDocPtr doc)
 
 	for(child = root->children; child; child = child->next)
 		if (child->type == XML_ELEMENT_NODE)
-	{
-		if (xmlStrlen(child->name)==4 && strncasecmp((char*)child->name,"Peer",4)==0){
-			//PEER
-			xc = xmlGetProp(child,(xmlChar*)"FQDN");
-			if (xc){
-				quote_trim_dup(&(x->peers[x->peers_cnt].fqdn),(char*)xc);
-				xmlFree(xc);
-			}
-			xc = xmlGetProp(child,(xmlChar*)"Realm");
-			if (xc){
-				quote_trim_dup(&(x->peers[x->peers_cnt].realm),(char*)xc);			
-				xmlFree(xc);
-			}
-			xc = xmlGetProp(child,(xmlChar*)"port");
-			if (xc){
-				x->peers[x->peers_cnt].port = atoi((char*)xc);
-				xmlFree(xc);
-			}
-			xc = xmlGetProp(child,(xmlChar*)"src_addr");
-			if (xc){
-				quote_trim_dup(&(x->peers[x->peers_cnt].src_addr),(char*)xc);
-				xmlFree(xc);
-			}
-			x->peers_cnt++;
-		}
-		else if (xmlStrlen(child->name)==8 && strncasecmp((char*)child->name,"Acceptor",8)==0){
-			//Acceptor
-			xc = xmlGetProp(child,(xmlChar*)"bind");			
-			if (xc){
-				quote_trim_dup(&(x->acceptors[x->acceptors_cnt].bind),(char*)xc);			
-				xmlFree(xc);
-			}
-			xc = xmlGetProp(child,(xmlChar*)"port");
-			if (xc){
-				x->acceptors[x->acceptors_cnt].port = atoi((char*)xc);						
-				xmlFree(xc);
-			}
-			x->acceptors_cnt++;		
-		}
-		else if (xmlStrlen(child->name)==4 && (strncasecmp((char*)child->name,"Auth",4)==0||
-			strncasecmp((char*)child->name,"Acct",4)==0)){
-			//Application
-			xc = xmlGetProp(child,(xmlChar*)"id");	
-			if (xc){
-				x->applications[x->applications_cnt].id = atoi((char*)xc);						
-				xmlFree(xc);
-			}
-			xc = xmlGetProp(child,(xmlChar*)"vendor");
-			if (xc){
-				x->applications[x->applications_cnt].vendor = atoi((char*)xc);						
-				xmlFree(xc);
-			}
-			if (child->name[1]=='u'||child->name[1]=='U')
-				x->applications[x->applications_cnt].type = DP_AUTHORIZATION;						
-			else
-				x->applications[x->applications_cnt].type = DP_ACCOUNTING;										
-			x->applications_cnt++;		
-		}	
-		else if (xmlStrlen(child->name)==15 && (strncasecmp((char*)child->name,"SupportedVendor",15)==0)){
-			//SupportedVendor
-			xc = xmlGetProp(child,(xmlChar*)"vendor");
-			if (xc){
-				x->supported_vendors[x->supported_vendors_cnt] = atoi((char*)xc);						
-				xmlFree(xc);
+		{
+			if (xmlStrlen(child->name)==4 && strncasecmp((char*)child->name,"Peer",4)==0){
+				//PEER
+				xc = xmlGetProp(child,(xmlChar*)"FQDN");
+				if (xc){
+					quote_trim_dup(&(x->peers[x->peers_cnt].fqdn),(char*)xc);
+					xmlFree(xc);
+				}
+				xc = xmlGetProp(child,(xmlChar*)"Realm");
+				if (xc){
+					quote_trim_dup(&(x->peers[x->peers_cnt].realm),(char*)xc);
+					xmlFree(xc);
+				}
+				xc = xmlGetProp(child,(xmlChar*)"port");
+				if (xc){
+					x->peers[x->peers_cnt].port = atoi((char*)xc);
+					xmlFree(xc);
+				}
+				xc = xmlGetProp(child,(xmlChar*)"src_addr");
+				if (xc){
+					quote_trim_dup(&(x->peers[x->peers_cnt].src_addr),(char*)xc);
+					xmlFree(xc);
+				}
+				x->peers_cnt++;
 			}
-			x->supported_vendors_cnt++;		
-		}	
-		else if (xmlStrlen(child->name)==12 && (strncasecmp((char*)child->name,"DefaultRoute",12)==0)){
-			if (!x->r_table) {
-				x->r_table = shm_malloc(sizeof(routing_table));
-				memset(x->r_table,0,sizeof(routing_table));
+			else if (xmlStrlen(child->name)==8 && strncasecmp((char*)child->name,"Acceptor",8)==0){
+				//Acceptor
+				xc = xmlGetProp(child,(xmlChar*)"bind");
+				if (xc){
+					quote_trim_dup(&(x->acceptors[x->acceptors_cnt].bind),(char*)xc);
+					xmlFree(xc);
+				}
+				xc = xmlGetProp(child,(xmlChar*)"port");
+				if (xc){
+					x->acceptors[x->acceptors_cnt].port = atoi((char*)xc);
+					xmlFree(xc);
+				}
+				x->acceptors_cnt++;
 			}
-			re = new_routing_entry();
-			if (re){			
-				xc = xmlGetProp(child,(xmlChar*)"FQDN");
+			else if (xmlStrlen(child->name)==4 && (strncasecmp((char*)child->name,"Auth",4)==0||
+						strncasecmp((char*)child->name,"Acct",4)==0)){
+				//Application
+				xc = xmlGetProp(child,(xmlChar*)"id");
 				if (xc){
-					quote_trim_dup(&(re->fqdn),(char*)xc);			
+					x->applications[x->applications_cnt].id = atoi((char*)xc);
 					xmlFree(xc);
 				}
-				xc = xmlGetProp(child,(xmlChar*)"metric");			
+				xc = xmlGetProp(child,(xmlChar*)"vendor");
+				if (xc){
+					x->applications[x->applications_cnt].vendor = atoi((char*)xc);
+					xmlFree(xc);
+				}
+				if (child->name[1]=='u'||child->name[1]=='U')
+					x->applications[x->applications_cnt].type = DP_AUTHORIZATION;
+				else
+					x->applications[x->applications_cnt].type = DP_ACCOUNTING;
+				x->applications_cnt++;
+			}
+			else if (xmlStrlen(child->name)==15 && (strncasecmp((char*)child->name,"SupportedVendor",15)==0)){
+				//SupportedVendor
+				xc = xmlGetProp(child,(xmlChar*)"vendor");
 				if (xc){
-					re->metric = atoi((char*)xc);			
+					x->supported_vendors[x->supported_vendors_cnt] = atoi((char*)xc);
 					xmlFree(xc);
 				}
-				
-				/* add it the list in ascending order */
-				if (! x->r_table->routes || re->metric <= x->r_table->routes->metric){
-					re->next = x->r_table->routes;
-					x->r_table->routes = re;
-				}else{
-					for(rei=x->r_table->routes;rei;rei=rei->next)
-						if (!rei->next){
-							rei->next = re;
-							break;						
-						}else{
-							if (re->metric <= rei->next->metric){
-								re->next = rei->next;
+				x->supported_vendors_cnt++;
+			}
+			else if (xmlStrlen(child->name)==12 && (strncasecmp((char*)child->name,"DefaultRoute",12)==0)){
+				if (!x->r_table) {
+					x->r_table = shm_malloc(sizeof(routing_table));
+					memset(x->r_table,0,sizeof(routing_table));
+				}
+				re = new_routing_entry();
+				if (re){
+					xc = xmlGetProp(child,(xmlChar*)"FQDN");
+					if (xc){
+						quote_trim_dup(&(re->fqdn),(char*)xc);
+						xmlFree(xc);
+					}
+					xc = xmlGetProp(child,(xmlChar*)"metric");
+					if (xc){
+						re->metric = atoi((char*)xc);
+						xmlFree(xc);
+					}
+
+					/* add it the list in ascending order */
+					if (! x->r_table->routes || re->metric <= x->r_table->routes->metric){
+						re->next = x->r_table->routes;
+						x->r_table->routes = re;
+					}else{
+						for(rei=x->r_table->routes;rei;rei=rei->next)
+							if (!rei->next){
 								rei->next = re;
 								break;
+							}else{
+								if (re->metric <= rei->next->metric){
+									re->next = rei->next;
+									rei->next = re;
+									break;
+								}
 							}
-						}				
+					}
 				}
-			}					
-		}
-		else if (xmlStrlen(child->name)==5 && (strncasecmp((char*)child->name,"Realm",5)==0)){
-			if (!x->r_table) {
-				x->r_table = shm_malloc(sizeof(routing_table));
-				memset(x->r_table,0,sizeof(routing_table));
 			}
-			rr = new_routing_realm();
-			if (rr){			
-				xc = xmlGetProp(child,(xmlChar*)"name");
-				quote_trim_dup(&(rr->realm),(char*)xc);			
-				
-				if (!x->r_table->realms) {				
-					x->r_table->realms = rr;
-				}else{				
-					for(rri=x->r_table->realms;rri->next;rri=rri->next);
-					rri->next = rr;				
-				}			
-				for(nephew = child->children; nephew; nephew = nephew->next)
-					if (nephew->type == XML_ELEMENT_NODE){
-						if (xmlStrlen(nephew->name)==5 && (strncasecmp((char*)nephew->name,"Route",5)==0))
-						{
-							re = new_routing_entry();
-							if (re) {
-								xc = xmlGetProp(nephew,(xmlChar*)"FQDN");
-								if (xc){
-									quote_trim_dup(&(re->fqdn),(char*)xc);	
-									xmlFree(xc);
-								}
-								xc = xmlGetProp(nephew,(xmlChar*)"metric");
-								if (xc){
-									re->metric = atoi((char*)xc);			
-									xmlFree(xc);
-								}
-								/* add it the list in ascending order */
-								if (! rr->routes || re->metric <= rr->routes->metric){
-									re->next = rr->routes;
-									rr->routes = re;
-								}else{
-									for(rei=rr->routes;rei;rei=rei->next)
-										if (!rei->next){
-											rei->next = re;
-											break;						
-										}else{
-											if (re->metric <= rei->next->metric){
-												re->next = rei->next;
+			else if (xmlStrlen(child->name)==5 && (strncasecmp((char*)child->name,"Realm",5)==0)){
+				if (!x->r_table) {
+					x->r_table = shm_malloc(sizeof(routing_table));
+					memset(x->r_table,0,sizeof(routing_table));
+				}
+				rr = new_routing_realm();
+				if (rr){
+					xc = xmlGetProp(child,(xmlChar*)"name");
+					quote_trim_dup(&(rr->realm),(char*)xc);
+
+					if (!x->r_table->realms) {
+						x->r_table->realms = rr;
+					}else{
+						for(rri=x->r_table->realms;rri->next;rri=rri->next);
+						rri->next = rr;
+					}
+					for(nephew = child->children; nephew; nephew = nephew->next)
+						if (nephew->type == XML_ELEMENT_NODE){
+							if (xmlStrlen(nephew->name)==5 && (strncasecmp((char*)nephew->name,"Route",5)==0))
+							{
+								re = new_routing_entry();
+								if (re) {
+									xc = xmlGetProp(nephew,(xmlChar*)"FQDN");
+									if (xc){
+										quote_trim_dup(&(re->fqdn),(char*)xc);
+										xmlFree(xc);
+									}
+									xc = xmlGetProp(nephew,(xmlChar*)"metric");
+									if (xc){
+										re->metric = atoi((char*)xc);
+										xmlFree(xc);
+									}
+									/* add it the list in ascending order */
+									if (! rr->routes || re->metric <= rr->routes->metric){
+										re->next = rr->routes;
+										rr->routes = re;
+									}else{
+										for(rei=rr->routes;rei;rei=rei->next)
+											if (!rei->next){
 												rei->next = re;
 												break;
+											}else{
+												if (re->metric <= rei->next->metric){
+													re->next = rei->next;
+													rei->next = re;
+													break;
+												}
 											}
-										}					
+									}
 								}
 							}
 						}
-					}
-			}		
+				}
+			}
 		}
-	}
-	
-	if (doc) xmlFreeDoc(doc);	
+
+	if (doc) xmlFreeDoc(doc);
 	parser_destroy();
 	return x;
 error:
 	if (doc) xmlFreeDoc(doc);
 	parser_destroy();
 	if (x) free_dp_config(x);
-	return 0;	
+	return 0;
 }
 

+ 13 - 15
modules/cdp/diameter.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef DIAMETER_H_
@@ -55,7 +53,7 @@
 
 #define get_2bytes(_b) \
 	((((unsigned char)(_b)[0])<<8)|\
-	 (((unsigned char)(_b)[1])))
+		(((unsigned char)(_b)[1])))
 
 #define get_3bytes(_b) \
 	((((unsigned char)(_b)[0])<<16)|(((unsigned char)(_b)[1])<<8)|\
@@ -79,8 +77,8 @@
 
 #define to_32x_len( _len_ ) \
 	( (_len_)+(((_len_)&3)?4-((_len_)&3):0) )
-	
-	
+
+
 /* AAA TYPES */
 
 #define AAA_NO_VENDOR_ID           0
@@ -145,7 +143,7 @@ typedef unsigned char   AAAMsgFlag;			/**< Message flag					*/
 #define Code_CE 	257
 #define Code_DW 	280
 #define Code_DP 	282
-	
+
 
 /** Status codes returned by functions in the AAA API */
 typedef enum {

+ 14 - 16
modules/cdp/diameter_api.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __DIAMETER_API_H_
@@ -53,7 +51,7 @@
 
 
 /* MESSAGE CREATION */
-				
+
 AAAMessage *AAACreateRequest(AAAApplicationId app_id,
 							AAACommandCode command_code,
 							AAAMsgFlag flags,
@@ -89,7 +87,7 @@ AAAMessage* AAATranslateMessage(unsigned char* source,unsigned int sourceLen,int
 
 /* AVPS */
 
-/** 
+/**
  * Create and add an AVP to the message, by duplicating the storage space
  */
 #define AAACreateAndAddAVPToMessage(_msg_,_code_,_flags_,_vdr_,_data_,_len_) \
@@ -129,7 +127,7 @@ AAA_AVP *AAAFindMatchingAVP(
 			AAA_AVP *startAvp,
 			AAA_AVPCode avpCode,
 			AAAVendorId vendorId,
-			AAASearchType searchType);				
+			AAASearchType searchType);
 typedef AAA_AVP* (*AAAFindMatchingAVP_f)(
 			AAAMessage *msg,
 			AAA_AVP *startAvp,
@@ -155,7 +153,7 @@ AAA_AVP* AAAGetPrevAVP(AAA_AVP *avp);
 
 char *AAAConvertAVPToString(AAA_AVP *avp,char *dest,unsigned int destLen);
 
- 
+
 
 str AAAGroupAVPS(AAA_AVP_LIST avps);
 typedef str (*AAAGroupAVPS_f)(AAA_AVP_LIST avps);
@@ -179,7 +177,7 @@ typedef AAA_AVP  *(*AAAFindMatchingAVPList_f)(
 
 
 void AAAAddAVPToList(AAA_AVP_LIST *list,AAA_AVP *avp);
-typedef void (*AAAAddAVPToList_f)(AAA_AVP_LIST *list,AAA_AVP *avp);	
+typedef void (*AAAAddAVPToList_f)(AAA_AVP_LIST *list,AAA_AVP *avp);
 
 
 /* CALLBACKS */

+ 94 - 96
modules/cdp/diameter_avp.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include <stdio.h>
@@ -111,7 +109,7 @@ inline void set_avp_fields( AAA_AVPCode code, AAA_AVP *avp)
 
 
 
-/** 
+/**
  * This function creates an AVP and returns a pointer to it.
  * @param code - the code of the new AVP
  * @param flags - the flags to set
@@ -123,19 +121,19 @@ inline void set_avp_fields( AAA_AVPCode code, AAA_AVP *avp)
  * \note This function is taken from DISC http://developer.berlios.de/projects/disc/
  */
 AAA_AVP*  AAACreateAVP(
-	AAA_AVPCode code,
-	AAA_AVPFlag flags,
-	AAAVendorId vendorId,
-	char   *data,
-	size_t length,
-	AVPDataStatus data_status)
+		AAA_AVPCode code,
+		AAA_AVPFlag flags,
+		AAAVendorId vendorId,
+		char   *data,
+		size_t length,
+		AVPDataStatus data_status)
 {
 	AAA_AVP *avp;
 
 	/* first check the params */
 	if( data==0 || length==0) {
 		LM_ERR("AAACreateAVP: NULL value received for"
-			" param data/length (AVP Code %d, VendorId %d)!!\n",code,vendorId);
+				" param data/length (AVP Code %d, VendorId %d)!!\n",code,vendorId);
 		return 0;
 	}
 
@@ -184,15 +182,15 @@ error:
  * \note This function is taken from DISC http://developer.berlios.de/projects/disc/
  */
 AAAReturnCode  AAAAddAVPToMessage(
-	AAAMessage *msg,
-	AAA_AVP *avp,
-	AAA_AVP *position)
+		AAAMessage *msg,
+		AAA_AVP *avp,
+		AAA_AVP *position)
 {
 	AAA_AVP *avp_t;
 
 	if ( !msg || !avp ) {
 		LM_ERR("AAAAddAVPToMessage: param msg or avp passed null"
-			" or *avpList=NULL and position!=NULL !!\n");
+				" or *avpList=NULL and position!=NULL !!\n");
 		return AAA_ERR_PARAMETER;
 	}
 
@@ -210,7 +208,7 @@ AAAReturnCode  AAAAddAVPToMessage(
 		for(avp_t=msg->avpList.head;avp_t&&avp_t!=position;avp_t=avp_t->next);
 		if (!avp_t) {
 			LM_ERR("AAAAddAVPToMessage: the \"position\" avp is not in"
-				"\"msg\" message!!\n");
+					"\"msg\" message!!\n");
 			return AAA_ERR_PARAMETER;
 		}
 		/* insert after position */
@@ -247,15 +245,15 @@ AAAReturnCode  AAAAddAVPToMessage(
  * @param avpCode - code of the AVP to match
  * @param vendorId - vendor id to match
  * @param searchType - whether to look forward or backward
- * @returns the AAA_AVP* if found, NULL if not 
+ * @returns the AAA_AVP* if found, NULL if not
  * \note This function is taken from DISC http://developer.berlios.de/projects/disc/
  */
 AAA_AVP  *AAAFindMatchingAVP(
-	AAAMessage *msg,
-	AAA_AVP *startAvp,
-	AAA_AVPCode avpCode,
-	AAAVendorId vendorId,
-	AAASearchType searchType)
+		AAAMessage *msg,
+		AAA_AVP *startAvp,
+		AAA_AVPCode avpCode,
+		AAAVendorId vendorId,
+		AAASearchType searchType)
 {
 	AAA_AVP *avp_t;
 
@@ -270,7 +268,7 @@ AAA_AVP  *AAAFindMatchingAVP(
 		for(avp_t=msg->avpList.head;avp_t&&avp_t!=startAvp;avp_t=avp_t->next);
 		if (!avp_t) {
 			LM_ERR("AAAFindMatchingAVP: the \"position\" avp is not "
-				"in \"avpList\" list!!\n");
+					"in \"avpList\" list!!\n");
 			goto error;
 		}
 		avp_t=startAvp;
@@ -295,21 +293,21 @@ error:
 
 /**
  *  This function removes an AVP from a message.
- * @param msg - the diameter message 
+ * @param msg - the diameter message
  * @param avp - the AVP to remove
  * @returns AAA_ERR_SUCCESS on success or AAA_ERR_PARAMETER if not found
  * \note This function is taken from DISC http://developer.berlios.de/projects/disc/
  */
 AAAReturnCode  AAARemoveAVPFromMessage(
-	AAAMessage *msg,
-	AAA_AVP *avp)
+		AAAMessage *msg,
+		AAA_AVP *avp)
 {
 	AAA_AVP *avp_t;
 
 	/* param check */
 	if ( !msg || !avp ) {
 		LM_ERR("AAARemoveAVPFromMessage: param AVP_LIST \"avpList\" or AVP "
-			"\"avp\" passed null !!\n");
+				"\"avp\" passed null !!\n");
 		return AAA_ERR_PARAMETER;
 	}
 
@@ -317,7 +315,7 @@ AAAReturnCode  AAARemoveAVPFromMessage(
 	for(avp_t=msg->avpList.head;avp_t&&avp_t!=avp;avp_t=avp_t->next);
 	if (!avp_t) {
 		LM_ERR("AAARemoveAVPFromMessage: the \"avp\" avp is not in "
-			"\"avpList\" avp list!!\n");
+				"\"avpList\" avp list!!\n");
 		return AAA_ERR_PARAMETER;
 	}
 
@@ -349,7 +347,7 @@ AAAReturnCode  AAARemoveAVPFromMessage(
 
 
 /**
- *  The function frees the memory allocated to an AVP 
+ *  The function frees the memory allocated to an AVP
  * \note This function is taken from DISC http://developer.berlios.de/projects/disc/
  */
 AAAReturnCode  AAAFreeAVP(AAA_AVP **avp)
@@ -374,7 +372,7 @@ AAAReturnCode  AAAFreeAVP(AAA_AVP **avp)
 
 /**
  *  This function returns the first AVP in the list.
- * @param avpList - the list 
+ * @param avpList - the list
  * \note This function is taken from DISC http://developer.berlios.de/projects/disc/
  */
 AAA_AVP*  AAAGetFirstAVP(AAA_AVP_LIST *avpList){
@@ -385,7 +383,7 @@ AAA_AVP*  AAAGetFirstAVP(AAA_AVP_LIST *avpList){
 
 /**
  *  This function returns the last AVP in the list.
- * @param avpList - the list  
+ * @param avpList - the list
  * \note This function is taken from DISC http://developer.berlios.de/projects/disc/
  */
 AAA_AVP*  AAAGetLastAVP(AAA_AVP_LIST *avpList)
@@ -426,9 +424,9 @@ AAA_AVP*  AAAGetPrevAVP(AAA_AVP *avp)
  *  This function converts the data in the AVP to a format suitable for
  * print, log or display.
  * @param avp - the AAA_AVP to print
- * @param dest - preallocated destination buffer. If too short, message will be truncated 
- * @param destLen - length of the destipation buffer 
- * @returns dest on success, NULL on failure 
+ * @param dest - preallocated destination buffer. If too short, message will be truncated
+ * @param destLen - length of the destipation buffer
+ * @returns dest on success, NULL on failure
  * \note This function is taken from DISC http://developer.berlios.de/projects/disc/
  */
 char*  AAAConvertAVPToString(AAA_AVP *avp, char *dest, unsigned int destLen)
@@ -438,59 +436,59 @@ char*  AAAConvertAVPToString(AAA_AVP *avp, char *dest, unsigned int destLen)
 
 	if (!avp || !dest || !destLen) {
 		LM_ERR("AAAConvertAVPToString: param AVP, DEST or DESTLEN "
-			"passed as null!!!\n");
+				"passed as null!!!\n");
 		return 0;
 	}
 	l = snprintf(dest,destLen,"AVP(%p < %p >%p);code=%u,"
-		"flags=%x;\nDataType=%u;VendorID=%u;DataLen=%u;\n",
-		avp->prev,avp,avp->next,avp->code,avp->flags,
-		avp->type,avp->vendorId,avp->data.len);
+			"flags=%x;\nDataType=%u;VendorID=%u;DataLen=%u;\n",
+			avp->prev,avp,avp->next,avp->code,avp->flags,
+			avp->type,avp->vendorId,avp->data.len);
 	switch(avp->type) {
 		case AAA_AVP_STRING_TYPE:
 			l+=snprintf(dest+l,destLen-l,"String: <%.*s>",avp->data.len,
-				avp->data.s);
+					avp->data.s);
 			break;
 		case AAA_AVP_INTEGER32_TYPE:
 			l+=snprintf(dest+l,destLen-l,"Int32: <%u>(%x)",
-				htonl(*((unsigned int*)avp->data.s)),
-				htonl(*((unsigned int*)avp->data.s)));
+					htonl(*((unsigned int*)avp->data.s)),
+					htonl(*((unsigned int*)avp->data.s)));
 			break;
 		case AAA_AVP_ADDRESS_TYPE:
 			i = 1;
 			switch (avp->data.len) {
 				case 4: i=i*0;
 				case 6: i=i*2;
-					l+=snprintf(dest+l,destLen-l,"Address IPv4: <%d.%d.%d.%d>",
-						(unsigned char)avp->data.s[i+0],
-						(unsigned char)avp->data.s[i+1],
-						(unsigned char)avp->data.s[i+2],
-						(unsigned char)avp->data.s[i+3]);
-					break;
+						l+=snprintf(dest+l,destLen-l,"Address IPv4: <%d.%d.%d.%d>",
+								(unsigned char)avp->data.s[i+0],
+								(unsigned char)avp->data.s[i+1],
+								(unsigned char)avp->data.s[i+2],
+								(unsigned char)avp->data.s[i+3]);
+						break;
 				case 16: i=i*0;
 				case 18: i=i*2;
-					l+=snprintf(dest+l,destLen-l,
-						"Address IPv6: <%x.%x.%x.%x.%x.%x.%x.%x>",
-						((avp->data.s[i+0]<<8)+avp->data.s[i+1]),
-						((avp->data.s[i+2]<<8)+avp->data.s[i+3]),
-						((avp->data.s[i+4]<<8)+avp->data.s[i+5]),
-						((avp->data.s[i+6]<<8)+avp->data.s[i+7]),
-						((avp->data.s[i+8]<<8)+avp->data.s[i+9]),
-						((avp->data.s[i+10]<<8)+avp->data.s[i+11]),
-						((avp->data.s[i+12]<<8)+avp->data.s[i+13]),
-						((avp->data.s[i+14]<<8)+avp->data.s[i+15]));
-					break;
-			break;
+						l+=snprintf(dest+l,destLen-l,
+								"Address IPv6: <%x.%x.%x.%x.%x.%x.%x.%x>",
+								((avp->data.s[i+0]<<8)+avp->data.s[i+1]),
+								((avp->data.s[i+2]<<8)+avp->data.s[i+3]),
+								((avp->data.s[i+4]<<8)+avp->data.s[i+5]),
+								((avp->data.s[i+6]<<8)+avp->data.s[i+7]),
+								((avp->data.s[i+8]<<8)+avp->data.s[i+9]),
+								((avp->data.s[i+10]<<8)+avp->data.s[i+11]),
+								((avp->data.s[i+12]<<8)+avp->data.s[i+13]),
+								((avp->data.s[i+14]<<8)+avp->data.s[i+15]));
+						break;
+						break;
 			}
 			break;
-		//case AAA_AVP_INTEGER64_TYPE:
+			//case AAA_AVP_INTEGER64_TYPE:
 		case AAA_AVP_TIME_TYPE:
 		default:
 			LM_WARN("AAAConvertAVPToString: don't know how to print"
-				" this data type [%d] -> tryng hexa\n",avp->type);
+					" this data type [%d] -> tryng hexa\n",avp->type);
 		case AAA_AVP_DATA_TYPE:
 			for (i=0;i<avp->data.len&&l<destLen-1;i++)
-			l+=snprintf(dest+l,destLen-l-1,"%x",
-				((unsigned char*)avp->data.s)[i]);
+				l+=snprintf(dest+l,destLen-l-1,"%x",
+						((unsigned char*)avp->data.s)[i]);
 	}
 	return dest;
 }
@@ -548,13 +546,13 @@ error:
 /**
  * Adds an AVP to a list of AVPs, at the end.
  * @param list - the list to add to
- * @param avp - the avp to add 
- */ 
+ * @param avp - the avp to add
+ */
 void AAAAddAVPToList(AAA_AVP_LIST *list,AAA_AVP *avp)
 {
 	if (list->tail) {
 		avp->prev=list->tail;
-		avp->next=0;	
+		avp->next=0;
 		list->tail->next = avp;
 		list->tail=avp;
 	} else {
@@ -562,16 +560,16 @@ void AAAAddAVPToList(AAA_AVP_LIST *list,AAA_AVP *avp)
 		list->tail = avp;
 		avp->next=0;
 		avp->prev=0;
-	}	
+	}
 }
- 
-/** 
+
+/**
  * Groups a list of avps into a data buffer
- * @param avps 
+ * @param avps
  */
 str AAAGroupAVPS(AAA_AVP_LIST avps)
- {
- 	AAA_AVP *avp;
+{
+	AAA_AVP *avp;
 	unsigned char *p;
 	str buf={0,0};
 
@@ -620,10 +618,10 @@ str AAAGroupAVPS(AAA_AVP_LIST avps)
 	return buf;
 }
 
-/** 
+/**
  * Ungroup from a data buffer a list of avps
  * @param buf - payload to ungroup the list from
- * @returns the AAA_AVP_LIST or an empty one on error 
+ * @returns the AAA_AVP_LIST or an empty one on error
  */
 AAA_AVP_LIST AAAUngroupAVPS(str buf)
 {
@@ -644,7 +642,7 @@ AAA_AVP_LIST AAAUngroupAVPS(str buf)
 	while (ptr < buf.s+buf.len) {
 		if (ptr+AVP_HDR_SIZE(0x80)>buf.s+buf.len){
 			LM_ERR("hss3g_ungroup_avps: source buffer to short!! "
-				"Cannot read the whole AVP header!\n");
+					"Cannot read the whole AVP header!\n");
 			goto error;
 		}
 		/* avp code */
@@ -658,7 +656,7 @@ AAA_AVP_LIST AAAUngroupAVPS(str buf)
 		ptr += AVP_LENGTH_SIZE;
 		if (avp_len<1) {
 			LM_ERR("hss3g_ungroup_avps: invalid AVP len [%d]\n",
-				avp_len);
+					avp_len);
 			goto error;
 		}
 		/* avp vendor-ID */
@@ -666,26 +664,26 @@ AAA_AVP_LIST AAAUngroupAVPS(str buf)
 		if (avp_flags&AAA_AVP_FLAG_VENDOR_SPECIFIC) {
 			avp_vendorID = get_4bytes( ptr );
 			ptr += AVP_VENDOR_ID_SIZE;
-		} 
+		}
 		/* data length */
 		avp_data_len = avp_len - AVP_HDR_SIZE(avp_flags);
 		/*check the data length */
 		if ( buf.s+buf.len<ptr+avp_data_len) {
 			LM_ERR("hss3g_ungroup_avps: source buffer to short!! "
-				"Cannot read a whole data for AVP!\n");
+					"Cannot read a whole data for AVP!\n");
 			goto error;
 		}
 
 		/* create the AVP */
 		avp = AAACreateAVP( avp_code, avp_flags, avp_vendorID, ptr,
-			avp_data_len, AVP_DONT_FREE_DATA);
+				avp_data_len, AVP_DONT_FREE_DATA);
 		if (!avp) {
 			LM_ERR("hss3g_ungroup_avps: can't create avp for member of list\n");
 			goto error;
 		}
 
 		/* link the avp into aaa message to the end */
-  		avp->next = 0;
+		avp->next = 0;
 		avp->prev = lh.tail;
 		if (lh.tail) {
 			lh.tail->next=avp;
@@ -708,7 +706,7 @@ error:
 /**
  * Find an avp into a list of avps.
  * @param avpList - the list to look into
- * @param startAvp - where to start the search. Usefull when you want to find the next one. 
+ * @param startAvp - where to start the search. Usefull when you want to find the next one.
  * Even this one will be checked and can be returned if it fits.
  * @param avpCode - the AVP code to match
  * @param vendorId - the vendor id to match
@@ -716,11 +714,11 @@ error:
  * @returns the AAA_AVP* if found, NULL if not
  */
 AAA_AVP  *AAAFindMatchingAVPList(
-	AAA_AVP_LIST avpList,
-	AAA_AVP *startAvp,
-	AAA_AVPCode avpCode,
-	AAAVendorId vendorId,
-	AAASearchType searchType)
+		AAA_AVP_LIST avpList,
+		AAA_AVP *startAvp,
+		AAA_AVPCode avpCode,
+		AAAVendorId vendorId,
+		AAASearchType searchType)
 {
 	AAA_AVP *avp_t;
 	/* param checking */
@@ -731,7 +729,7 @@ AAA_AVP  *AAAFindMatchingAVPList(
 		for(avp_t=avpList.head;avp_t&&avp_t!=startAvp;avp_t=avp_t->next);
 		if (!avp_t) {
 			LM_ERR("ndMatchingAVP: the \"position\" avp is not "
-				"in \"avpList\" list!!\n");
+					"in \"avpList\" list!!\n");
 			goto error;
 		}
 		avp_t=startAvp;
@@ -751,4 +749,4 @@ AAA_AVP  *AAAFindMatchingAVPList(
 error:
 	return 0;
 }
- 
+

+ 67 - 69
modules/cdp/diameter_code_avp.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef DIAMETER_CODE_AVP_H_
@@ -48,9 +46,9 @@
 
 /** Standard AVP Codes */
 typedef enum {
-	
+
 	/* RFC 3588 */
-	
+
 	AVP_User_Name                     =    1,
 	AVP_User_Password				  =    2, //RFC4005
 	AVP_NAS_IP_Addresss				  =    4, //RFC4005
@@ -126,15 +124,15 @@ typedef enum {
 	AVP_Framed_Interface_Id           =   96, //RFC4005
 	AVP_Framed_IPv6_Prefix            =   97, //RFC4005
 	AVP_Framed_IPv6_Route			  =   98, //RFC4005
-#define AVP_Login_IPv6_Host				  98	
+#define AVP_Login_IPv6_Host				  98
 	AVP_Framed_IPv6_Pool			  =  100, //RFC4005
-	
+
 	AVP_MIP6_Feature_Vector			  =  124, //RFC5447
 	AVP_MIP6_Home_Link_Prefix		  =  125, //RFC5447
-	
+
 	AVP_Host_IP_Address               =  257,
 	AVP_Auth_Application_Id           =  258,
-	AVP_Acct_Application_Id           =  259,	
+	AVP_Acct_Application_Id           =  259,
 	AVP_Vendor_Specific_Application_Id=  260,
 	AVP_Redirect_Host_Usage			  =  261,
 	AVP_Redirect_Max_Cache_Time       =  262,
@@ -170,30 +168,30 @@ typedef enum {
 	AVP_Experimental_Result			  =  297,
 	AVP_Experimental_Result_Code      =  298,
 	AVP_Inband_Security_Id			  =  299,
-	
+
 	AVP_E2E_Sequence				  =  300,
 	AVP_Accounting_Input_Octets		  =  363, //RFC4005
 	AVP_Accounting_Output_Octets	  =  364, //RFC4005
 	AVP_Accounting_Input_Packets	  =  365, //RFC4005
 	AVP_Accounting_Output_Packets	  =  366, //RFC4005
-	
+
 	/* RFC 4004 */
-	AVP_MIP_Reg_Request               =  320, 
-	AVP_MIP_Reg_Reply                 =  321, 
-	AVP_MIP_MN_AAA_Auth               =  322, 
-	AVP_MIP_Mobile_Node_Address       =  333, 
-	AVP_MIP_Home_Agent_Address        =  334, 
-	AVP_MIP_Candidate_Home_Agent_Host =  336, 
-	AVP_MIP_Feature_Vector            =  337, 
-	AVP_MIP_Auth_Input_Data_Length    =  338, 
-	AVP_MIP_Authenticator_Length      =  339, 
-	AVP_MIP_Authenticator_Offset      =  340, 
-	AVP_MIP_MN_AAA_SPI                =  341, 
-	AVP_MIP_Filter_Rule               =  342, 
-	AVP_MIP_FA_Challenge              =  344, 
-	AVP_MIP_Originating_Foreign_AAA   =  347, 
-	AVP_MIP_Home_Agent_Host           =  348, 
-	
+	AVP_MIP_Reg_Request               =  320,
+	AVP_MIP_Reg_Reply                 =  321,
+	AVP_MIP_MN_AAA_Auth               =  322,
+	AVP_MIP_Mobile_Node_Address       =  333,
+	AVP_MIP_Home_Agent_Address        =  334,
+	AVP_MIP_Candidate_Home_Agent_Host =  336,
+	AVP_MIP_Feature_Vector            =  337,
+	AVP_MIP_Auth_Input_Data_Length    =  338,
+	AVP_MIP_Authenticator_Length      =  339,
+	AVP_MIP_Authenticator_Offset      =  340,
+	AVP_MIP_MN_AAA_SPI                =  341,
+	AVP_MIP_Filter_Rule               =  342,
+	AVP_MIP_FA_Challenge              =  344,
+	AVP_MIP_Originating_Foreign_AAA   =  347,
+	AVP_MIP_Home_Agent_Host           =  348,
+
 	/* RFC 4005 */
 	AVP_NAS_Filter_Rule				  =  400,
 	AVP_Tunneling					  =  401,
@@ -204,13 +202,13 @@ typedef enum {
 	AVP_Accounting_Auth_Method		  =  406,
 	AVP_QoS_Filter_Rule				  =  407,
 	AVP_Origin_AAA_Protocol			  =  408,
-	
+
 	/* RFC 4006 */
 	AVP_CC_Correlation_Id			  =  411,
 	AVP_CC_Input_Octets				  =  412,
 	AVP_CC_Money                      =  413,
 	AVP_CC_Output_Octets              =  414,
-	AVP_CC_Request_Number             =  415, 
+	AVP_CC_Request_Number             =  415,
 	AVP_CC_Request_Type               =  416,
 	AVP_CC_Service_Specific_Units     =  417,
 	AVP_CC_Session_Failover           =  418,
@@ -238,35 +236,35 @@ typedef enum {
 	AVP_Service_Parameter_Info        =  440,
 	AVP_Service_Parameter_Type        =  441,
 	AVP_Service_Parameter_Value       =  442,
-	AVP_Subscription_Id				  =  443, 
+	AVP_Subscription_Id				  =  443,
 	AVP_Subscription_Id_Data		  =  444,
 	AVP_Unit_Value                    =  445,
 	AVP_Used_Service_Unit             =  446,
 	AVP_Value_Digits                  =  447,
 	AVP_Validity_Time                 =  448,
-	AVP_Final_Unit_Action			  =  449, 
+	AVP_Final_Unit_Action			  =  449,
 	AVP_Subscription_Id_Type		  =  450,
-	AVP_Tariff_Time_Change            =  451, 
+	AVP_Tariff_Time_Change            =  451,
 	AVP_Tariff_Change_Usage           =  452,
 	AVP_G_S_U_Pool_Identifier         =  453,
 	AVP_CC_Unit_Type                  =  454,
 	AVP_Multiple_Services_Indicator   =  455,
 	AVP_Multiple_Services_Credit_Control=456,
 	AVP_G_S_U_Pool_Reference          =  457,
-	AVP_User_Equipment_Info	          =  458, 
-	AVP_User_Equipment_Info_Type      =  459, 
+	AVP_User_Equipment_Info	          =  458,
+	AVP_User_Equipment_Info_Type      =  459,
 	AVP_User_Equipment_Info_Value	  =  460,
 	AVP_Service_Context_Id            =  461,
-	
-	
+
+
 	AVP_Accounting_Record_Type        =  480,
 	AVP_Accounting_Realtime_Required  =  483,
 	AVP_Accounting_Record_Number      =  485,
 	AVP_MIP6_Agent_Info				  =  486, //RFC5447
-	
-	AVP_Service_Selection			  =  493, //RFC5778  
+
+	AVP_Service_Selection			  =  493, //RFC5778
 	AVP_Call_Id                       =  494,
-	
+
 }AAA_AVPCodeNr;
 
 enum {
@@ -294,7 +292,7 @@ enum  {
 enum  {
 	AVP_Credit_Control_Failure_Handling_Terminate			= 0,
 	AVP_Credit_Control_Failure_Handling_Continue			= 1,
-	AVP_Credit_Control_Failure_Handling_Retry_And_Terminate	= 2,	
+	AVP_Credit_Control_Failure_Handling_Retry_And_Terminate	= 2,
 };
 
 enum  {
@@ -362,32 +360,32 @@ enum {
 typedef enum
 {
 	AVP_NAS_Port_Type_Async					= 0,
-	AVP_NAS_Port_Type_Sync 					= 1, 
-	AVP_NAS_Port_Type_ISDN_Sync 			= 2, 
+	AVP_NAS_Port_Type_Sync 					= 1,
+	AVP_NAS_Port_Type_ISDN_Sync 			= 2,
 	AVP_NAS_Port_Type_ISDN_Async_V120 		= 3,
 	AVP_NAS_Port_Type_ISDN_Async_V110		= 4,
-	AVP_NAS_Port_Type_Virtual				= 5, 
-	AVP_NAS_Port_Type_PIAFS					= 6, 	
-	AVP_NAS_Port_Type_HDLC_Clear_Channel	= 7, 
-	AVP_NAS_Port_Type_X_25					= 8, 
-	AVP_NAS_Port_Type_X_75					= 9, 
+	AVP_NAS_Port_Type_Virtual				= 5,
+	AVP_NAS_Port_Type_PIAFS					= 6,
+	AVP_NAS_Port_Type_HDLC_Clear_Channel	= 7,
+	AVP_NAS_Port_Type_X_25					= 8,
+	AVP_NAS_Port_Type_X_75					= 9,
 	AVP_NAS_Port_Type_G_3_Fax				=10,
-	AVP_NAS_Port_Type_Symmetric_DSL			=11, 	
+	AVP_NAS_Port_Type_Symmetric_DSL			=11,
 	AVP_NAS_Port_Type_ADSL_CAP				=12,
-	AVP_NAS_Port_Type_ADSL_DMT				=13, 
-	AVP_NAS_Port_Type_IDSL					=14, 
-	AVP_NAS_Port_Type_Ethernet				=15, 
-	AVP_NAS_Port_Type_xDSL					=16, 
-	AVP_NAS_Port_Type_Cable					=17, 
+	AVP_NAS_Port_Type_ADSL_DMT				=13,
+	AVP_NAS_Port_Type_IDSL					=14,
+	AVP_NAS_Port_Type_Ethernet				=15,
+	AVP_NAS_Port_Type_xDSL					=16,
+	AVP_NAS_Port_Type_Cable					=17,
 	AVP_NAS_Port_Type_Wireless_Other		=18,
 	AVP_NAS_Port_Type_Wireless_IEEE_802_11	=19,
-	AVP_NAS_Port_Type_Token_Ring			=20, 
+	AVP_NAS_Port_Type_Token_Ring			=20,
 	AVP_NAS_Port_Type_FDDI					=21,
 	AVP_NAS_Port_Type_Wireless_CDMA2000		=22,
 	AVP_NAS_Port_Type_Wireless_UMTS			=23,
 	AVP_NAS_Port_Type_Wireless_1X_EV		=24,
 	AVP_NAS_Port_Type_IAPP  				=25
-}	nas_port_type;						
+}	nas_port_type;
 
 enum {
 	AVP_Prompt_No_Echo	= 0,
@@ -448,7 +446,7 @@ enum {
 	AVP_Login_Service_Rlogin			= 1,
 	AVP_Login_Service_TCP_Clear			= 2,
 	AVP_Login_Service_PortMaster		= 3,
-	AVP_Login_Service_LAT				= 4,		
+	AVP_Login_Service_LAT				= 4,
 	AVP_Login_Service_X25_PAD			= 5,
 	AVP_Login_Service_X25_T3POS			= 6,
 	AVP_Login_Service_TCP_Clear_Quiet	= 7,
@@ -535,7 +533,7 @@ enum {
 	AVP_Accounting_Record_Type_Event_Record		= 1,
 	AVP_Accounting_Record_Type_Start_Record		= 2,
 	AVP_Accounting_Record_Type_Interim_Record	= 3,
-	AVP_Accounting_Record_Type_Stop_Record		= 4,			
+	AVP_Accounting_Record_Type_Stop_Record		= 4,
 };
 
 
@@ -543,10 +541,10 @@ enum {
 
 
 typedef enum {
-        Permanent_Termination   = 0,
-        New_Server_Assigned     = 1,
-        Server_Change           = 2,
-        Remove_S_CSCF           = 3,
+	Permanent_Termination   = 0,
+	New_Server_Assigned     = 1,
+	Server_Change           = 2,
+	Remove_S_CSCF           = 3,
 }AAA_AVPReasonCode;
 
 typedef enum {

+ 16 - 18
modules/cdp/diameter_code_result.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef DIAMETER_CODE_RESULT_H_
@@ -89,11 +87,11 @@ typedef enum {
 /**	Diameter Result Codes				*/
 enum {
 	/* RFC 3588 */
-	DIAMETER_MULTI_ROUND_AUTH							= 1001,	
-	
+	DIAMETER_MULTI_ROUND_AUTH							= 1001,
+
 	DIAMETER_SUCCESS									= 2001,//7D1
 	DIAMETER_LIMITED_SUCCESS							= 2002,
-	
+
 	DIAMETER_COMMAND_UNSUPPORTED						= 3001,
 	DIAMETER_UNABLE_TO_DELIVER							= 3002,
 	DIAMETER_REALM_NOT_SERVED							= 3003,//0xBBB
@@ -104,11 +102,11 @@ enum {
 	DIAMETER_INVALID_HDR_BITS							= 3008,
 	DIAMETER_INVALID_AVP_BITS							= 3009,
 	DIAMETER_UNKNOWN_PEER								= 3010,
-	
+
 	DIAMETER_AUTHENTICATION_REJECTED					= 4001,//FA1
 	DIAMETER_OUT_OF_SPACE								= 4002,
 	DIAMETER_ELECTION_LOST								= 4003,
-	
+
 	DIAMETER_AVP_UNSUPPORTED							= 5001,
 	DIAMETER_UNKNOWN_SESSION_ID							= 5002,
 	DIAMETER_AUTHORIZATION_REJECTED						= 5003,//138B
@@ -126,12 +124,12 @@ enum {
 	DIAMETER_INVALID_MESSAGE_LENGTH						= 5015,
 	DIAMETER_INVALID_AVP_BIT_COMBO						= 5016,
 	DIAMETER_NO_COMMON_SECURITY							= 5017,//0x1399
-	
+
 	/* RFC 4006 */
 	DIAMETER_END_USER_SERVICE_DENIED					= 4010,
 	DIAMETER_CREDIT_CONTROL_NOT_APPLICABLE				= 4011,
 	DIAMETER_CREDIT_LIMIT_REACHED						= 4012,
-	
+
 	DIAMETER_USER_UNKNOWN								= 5030,
 	DIAMETER_RATING_FAILED								= 5031
 };

+ 35 - 37
modules/cdp/diameter_comm.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include "diameter_api.h"
@@ -56,7 +54,7 @@
 extern dp_config *config;				/**< Configuration for this diameter peer 	*/
 extern unsigned int* latency_threshold_p;	/**<max delay for Diameter call */
 
-				/* CALLBACKS */
+/* CALLBACKS */
 extern handler_list *handlers; 		/**< list of handlers */
 extern gen_lock_t *handlers_lock;	/**< lock for list of handlers */
 
@@ -71,7 +69,7 @@ int AAAAddRequestHandler(AAARequestHandler_f *f,void *param)
 	handler *h = shm_malloc(sizeof(handler));
 	if (!h) {
 		LM_ERR("AAAAddRequestHandler: error allocating %ld bytes in shm\n",
-			(long int)sizeof(handler));
+				(long int)sizeof(handler));
 		return 0;
 	}
 	h->type = REQUEST_HANDLER;
@@ -98,7 +96,7 @@ int AAAAddResponseHandler(AAAResponseHandler_f *f,void *param)
 	handler *h = shm_malloc(sizeof(handler));
 	if (!h) {
 		LM_ERR("AAAAddResponseHandler: error allocating %ld bytes in shm\n",
-			(long int)sizeof(handler));
+				(long int)sizeof(handler));
 		return 0;
 	}
 	h->type = RESPONSE_HANDLER;
@@ -115,7 +113,7 @@ int AAAAddResponseHandler(AAAResponseHandler_f *f,void *param)
 }
 
 
-				/* MESSAGE SENDING */
+/* MESSAGE SENDING */
 
 /**
  * Send a AAAMessage asynchronously.
@@ -132,14 +130,14 @@ AAAReturnCode AAASendMessage(
 		AAATransactionCallback_f *callback_f,
 		void *callback_param)
 {
-        cdp_session_t* cdp_session;
+	cdp_session_t* cdp_session;
 	peer *p;
-        cdp_session = cdp_get_session(message->sessionId->data);
-        
+	cdp_session = cdp_get_session(message->sessionId->data);
+
 	p = get_routing_peer(cdp_session, message);
-        if (cdp_session) {
-            AAASessionsUnlock(cdp_session->hash);
-        }
+	if (cdp_session) {
+		AAASessionsUnlock(cdp_session->hash);
+	}
 	if (!p) {
 		LM_ERR("AAASendMessage(): Can't find a suitable connected peer in the routing table.\n");
 		goto error;
@@ -157,7 +155,7 @@ AAAReturnCode AAASendMessage(
 			LM_ERR("AAASendMessage(): can't add transaction callback for answer.\n");
 	}
 
-//	if (!peer_send_msg(p,message))
+	//	if (!peer_send_msg(p,message))
 	if (!sm_process(p,Send_Message,message,0,0))
 		goto error;
 
@@ -244,16 +242,16 @@ AAAMessage* AAASendRecvMessage(AAAMessage *message)
 	gen_sem_t *sem=0;
 	cdp_trans_t *t;
 	AAAMessage *ans;
-        struct timeval start, stop;
-        long elapsed_usecs=0, elapsed_millis=0;
-        cdp_session_t* cdp_session;
+	struct timeval start, stop;
+	long elapsed_usecs=0, elapsed_millis=0;
+	cdp_session_t* cdp_session;
 
-        gettimeofday(&start, NULL);
-        cdp_session = cdp_get_session(message->sessionId->data);
+	gettimeofday(&start, NULL);
+	cdp_session = cdp_get_session(message->sessionId->data);
 	p = get_routing_peer(cdp_session, message);
-        if (cdp_session) {
-            AAASessionsUnlock(cdp_session->hash);
-        }
+	if (cdp_session) {
+		AAASessionsUnlock(cdp_session->hash);
+	}
 	if (!p) {
 		LM_ERR("AAASendRecvMessage(): Can't find a suitable connected peer in the routing table.\n");
 		goto error;
@@ -280,8 +278,8 @@ AAAMessage* AAASendRecvMessage(AAAMessage *message)
 		}
 		sem_free(sem);
 		gettimeofday(&stop, NULL);
-        elapsed_usecs = (stop.tv_sec - start.tv_sec)*1000000 + (stop.tv_usec - start.tv_usec);
-        elapsed_millis = elapsed_usecs/1000;
+		elapsed_usecs = (stop.tv_sec - start.tv_sec)*1000000 + (stop.tv_usec - start.tv_usec);
+		elapsed_millis = elapsed_usecs/1000;
 		if (elapsed_millis > *latency_threshold_p) {
 			LM_ERR("CDP response to Send_Message took too long (>%dms) - [%ldms]\n", *latency_threshold_p, elapsed_millis);
 		}
@@ -316,9 +314,9 @@ AAAMessage* AAASendRecvMessageToPeer(AAAMessage *message, str *peer_id)
 	cdp_trans_t *t;
 	AAAMessage *ans;
 	struct timeval start, stop;
-    long elapsed_usecs=0, elapsed_millis=0;
+	long elapsed_usecs=0, elapsed_millis=0;
 
-    gettimeofday(&start, NULL);
+	gettimeofday(&start, NULL);
 
 	p = get_peer_by_fqdn(peer_id);
 	if (!p) {
@@ -334,7 +332,7 @@ AAAMessage* AAASendRecvMessageToPeer(AAAMessage *message, str *peer_id)
 		sem_new(sem,0);
 		t = cdp_add_trans(message,sendrecv_cb,(void*)sem,config->transaction_timeout,0);
 
-//		if (!peer_send_msg(p,message)) {
+		//		if (!peer_send_msg(p,message)) {
 		if (!sm_process(p,Send_Message,message,0,0)){
 			sem_free(sem);
 			goto error;
@@ -347,7 +345,7 @@ AAAMessage* AAASendRecvMessageToPeer(AAAMessage *message, str *peer_id)
 
 		gettimeofday(&stop, NULL);
 		elapsed_usecs = (stop.tv_sec - start.tv_sec) * 1000000
-				+ (stop.tv_usec - start.tv_usec);
+			+ (stop.tv_usec - start.tv_usec);
 		elapsed_millis = elapsed_usecs / 1000;
 		if (elapsed_millis > *latency_threshold_p) {
 			LM_ERR("CDP response to Send_Message took too long (>%dms) - [%ldms]\n", *latency_threshold_p, elapsed_millis);
@@ -367,7 +365,7 @@ error:
 out_of_memory:
 	AAAFreeMessage(&message);
 	return 0;
-}
+	}
 
 
 

+ 9 - 11
modules/cdp/diameter_epc.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef DIAMETER_EPC_H_

+ 9 - 11
modules/cdp/diameter_epc_code_app.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef DIAMETER_EPC_CODE_APP_H_

+ 184 - 186
modules/cdp/diameter_epc_code_avp.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef DIAMETER_EPC_CODE_AVP_H_
@@ -50,7 +48,7 @@
 
 /** 3GPP AVP Codes */
 enum {
-/**   1 to 255 reserved for backward compatibility with Radius TS29.061	*/
+	/**   1 to 255 reserved for backward compatibility with Radius TS29.061	*/
 
 	AVP_EPC_3GPP_IMSI									= 1,
 	AVP_EPC_3GPP_Charging_Id							= 2,
@@ -76,15 +74,15 @@ enum {
 	AVP_EPC_3GPP_MS_TimeZone							= 23,
 	AVP_EPC_3GPP_Allocate_IP_Type						= 27,
 	AVP_EPC_RAI											= 909, //TS29.061
-/** 256 to 299 reserved for future use										*/
+	/** 256 to 299 reserved for future use										*/
 
 
-/** 300 to 399 reserved for TS29.234											*/
+	/** 300 to 399 reserved for TS29.234											*/
 	AVP_EPC_3GPP_AAA_Server_Name	  					= 318, //TS29.234
-	
-/** 400 to 499 reserved for TS29.109 */
-		
-/** 500 to 599 reserved for TS29.209											*/
+
+	/** 400 to 499 reserved for TS29.109 */
+
+	/** 500 to 599 reserved for TS29.209											*/
 	AVP_EPC_Abort_Cause									= 500,
 	AVP_EPC_Access_Network_Charging_Address				= 501,
 	AVP_EPC_Access_Network_Charging_Identifier			= 502,
@@ -112,12 +110,12 @@ enum {
 	AVP_EPC_Service_URN									= 525,
 	AVP_EPC_Acceptable_Service_Info						= 526,
 	AVP_EPC_Service_Info_Status							= 527,
-/** 600 to 699 reserved for TS29.229											*/
-/** 700 to 799 reserved for TS29.329											*/
-	
-/** 800 to 899 reserved for TS29.299											*/
+	/** 600 to 699 reserved for TS29.229											*/
+	/** 700 to 799 reserved for TS29.329											*/
+
+	/** 800 to 899 reserved for TS29.299											*/
 
-/** 32.299 Partial																*/
+	/** 32.299 Partial																*/
 	AVP_EPC_Event_Type									= 823,
 	AVP_EPC_SIP_Method									= 824,
 	AVP_EPC_Event										= 825,
@@ -167,68 +165,68 @@ enum {
 	AVP_EPC_Address_Domain								= 898,
 	AVP_EPC_Address_Type								= 899,
 	AVP_EPC_CN_IP_Multicast_Distribution				= 921,
-	
-/** 1000   from TS29.212 */
+
+	/** 1000   from TS29.212 */
 	AVP_EPC_Bearer_Usage								= 1000,
- 	AVP_EPC_Charging_Rule_Install						= 1001,
- 	AVP_EPC_Charging_Rule_Remove						= 1002,
- 	AVP_EPC_Charging_Rule_Definition					= 1003,
- 	AVP_EPC_Charging_Rule_Base_Name						= 1004,
- 	AVP_EPC_Charging_Rule_Name							= 1005,
- 	AVP_EPC_Event_Trigger								= 1006,
- 	AVP_EPC_Metering_Method								= 1007,
- 	AVP_EPC_Offline										= 1008,
- 	AVP_EPC_Online										= 1009,
- 	AVP_EPC_Precedence									= 1010,
- 	AVP_EPC_Reporting_Level								= 1011,
- 	AVP_EPC_TFT_Filter									= 1012,
- 	AVP_EPC_TFT_Packet_Filter_Information				= 1013,
- 	AVP_EPC_ToS_Traffic_Class							= 1014,
- 	AVP_EPC_QoS_Bandwidth								= 1015,  //Not used in the EPC
- 	AVP_EPC_QoS_Information								= 1016,
- 	AVP_EPC_QoS_Jitter									= 1017,  //Not used in the EPC
- 	AVP_EPC_Charging_Rule_Report						= 1018,
- 	AVP_EPC_PCC_Rule_Status								= 1019,
- 	AVP_EPC_Bearer_Identifier							= 1020,
- 	AVP_EPC_Bearer_Operation							= 1021,
- 	AVP_EPC_Access_Network_Charging_Identifier_Gx		= 1022,
- 	AVP_EPC_Bearer_Control_Mode							= 1023,
- 	AVP_EPC_Network_Request_Support						= 1024,
- 	AVP_EPC_Guaranteed_Bitrate_DL						= 1025,
- 	AVP_EPC_Guaranteed_Bitrate_UL						= 1026,
- 	AVP_EPC_IP_CAN_Type									= 1027,
- 	AVP_EPC_QoS_Class_Identifier						= 1028,
- 	AVP_EPC_QoS_Negotiation								= 1029,
- 	AVP_EPC_QoS_Upgrade									= 1030,
- 	AVP_EPC_Rule_Failure_Code							= 1031,
- 	AVP_EPC_RAT_Type									= 1032,
- 	AVP_EPC_Event_Report_Indication						= 1033,
- 	AVP_EPC_Allocation_Retention_Priority				= 1034,
- 	AVP_EPC_CoA_IP_Address								= 1035,
- 	AVP_EPC_Tunnel_Header_Filter						= 1036,
- 	AVP_EPC_Tunnel_Header_Length						= 1037,
- 	AVP_EPC_Tunnel_Information							= 1038,
- 	AVP_EPC_CoA_Information								= 1039,
- 	AVP_EPC_APN_Aggregate_Max_Bitrate_DL				= 1040,
- 	AVP_EPC_APN_Aggregate_Max_Bitrate_UL				= 1041,
- 	AVP_EPC_Revalidation_Time							= 1042,
- 	AVP_EPC_Rule_Activation_Time						= 1043,
- 	AVP_EPC_Rule_DeActivation_Time						= 1044,
- 	AVP_EPC_Session_Release_Cause						= 1045,
- 	AVP_EPC_ARP_Value									= 1046, //Depends on the version
- 	AVP_EPC_Priority_Level								= 1046,
- 	AVP_EPC_Pre_emption_Capability						= 1047,
- 	AVP_EPC_Pre_emption_Vulnerability					= 1048,
- 	AVP_EPC_Default_EPS_Bearer_QoS						= 1049,
- 	AVP_EPC_AN_GW_Address								= 1050,
- 	AVP_EPC_QoS_Rule_Install							= 1051, //Gxx
- 	AVP_EPC_QoS_Rule_Remove								= 1052,
- 	AVP_EPC_QoS_Rule_Definition							= 1053,
- 	AVP_EPC_QoS_Rule_Name								= 1054,
- 	AVP_EPC_QoS_Rule_Report								= 1055,
- 	AVP_EPC_Security_Parameter_Index					= 1056,
- 	AVP_EPC_Flow_Label									= 1057,
- 	AVP_EPC_Flow_Information							= 1058,
+	AVP_EPC_Charging_Rule_Install						= 1001,
+	AVP_EPC_Charging_Rule_Remove						= 1002,
+	AVP_EPC_Charging_Rule_Definition					= 1003,
+	AVP_EPC_Charging_Rule_Base_Name						= 1004,
+	AVP_EPC_Charging_Rule_Name							= 1005,
+	AVP_EPC_Event_Trigger								= 1006,
+	AVP_EPC_Metering_Method								= 1007,
+	AVP_EPC_Offline										= 1008,
+	AVP_EPC_Online										= 1009,
+	AVP_EPC_Precedence									= 1010,
+	AVP_EPC_Reporting_Level								= 1011,
+	AVP_EPC_TFT_Filter									= 1012,
+	AVP_EPC_TFT_Packet_Filter_Information				= 1013,
+	AVP_EPC_ToS_Traffic_Class							= 1014,
+	AVP_EPC_QoS_Bandwidth								= 1015,  //Not used in the EPC
+	AVP_EPC_QoS_Information								= 1016,
+	AVP_EPC_QoS_Jitter									= 1017,  //Not used in the EPC
+	AVP_EPC_Charging_Rule_Report						= 1018,
+	AVP_EPC_PCC_Rule_Status								= 1019,
+	AVP_EPC_Bearer_Identifier							= 1020,
+	AVP_EPC_Bearer_Operation							= 1021,
+	AVP_EPC_Access_Network_Charging_Identifier_Gx		= 1022,
+	AVP_EPC_Bearer_Control_Mode							= 1023,
+	AVP_EPC_Network_Request_Support						= 1024,
+	AVP_EPC_Guaranteed_Bitrate_DL						= 1025,
+	AVP_EPC_Guaranteed_Bitrate_UL						= 1026,
+	AVP_EPC_IP_CAN_Type									= 1027,
+	AVP_EPC_QoS_Class_Identifier						= 1028,
+	AVP_EPC_QoS_Negotiation								= 1029,
+	AVP_EPC_QoS_Upgrade									= 1030,
+	AVP_EPC_Rule_Failure_Code							= 1031,
+	AVP_EPC_RAT_Type									= 1032,
+	AVP_EPC_Event_Report_Indication						= 1033,
+	AVP_EPC_Allocation_Retention_Priority				= 1034,
+	AVP_EPC_CoA_IP_Address								= 1035,
+	AVP_EPC_Tunnel_Header_Filter						= 1036,
+	AVP_EPC_Tunnel_Header_Length						= 1037,
+	AVP_EPC_Tunnel_Information							= 1038,
+	AVP_EPC_CoA_Information								= 1039,
+	AVP_EPC_APN_Aggregate_Max_Bitrate_DL				= 1040,
+	AVP_EPC_APN_Aggregate_Max_Bitrate_UL				= 1041,
+	AVP_EPC_Revalidation_Time							= 1042,
+	AVP_EPC_Rule_Activation_Time						= 1043,
+	AVP_EPC_Rule_DeActivation_Time						= 1044,
+	AVP_EPC_Session_Release_Cause						= 1045,
+	AVP_EPC_ARP_Value									= 1046, //Depends on the version
+	AVP_EPC_Priority_Level								= 1046,
+	AVP_EPC_Pre_emption_Capability						= 1047,
+	AVP_EPC_Pre_emption_Vulnerability					= 1048,
+	AVP_EPC_Default_EPS_Bearer_QoS						= 1049,
+	AVP_EPC_AN_GW_Address								= 1050,
+	AVP_EPC_QoS_Rule_Install							= 1051, //Gxx
+	AVP_EPC_QoS_Rule_Remove								= 1052,
+	AVP_EPC_QoS_Rule_Definition							= 1053,
+	AVP_EPC_QoS_Rule_Name								= 1054,
+	AVP_EPC_QoS_Rule_Report								= 1055,
+	AVP_EPC_Security_Parameter_Index					= 1056,
+	AVP_EPC_Flow_Label									= 1057,
+	AVP_EPC_Flow_Information							= 1058,
 	AVP_EPC_Packet_Filter_Content						= 1059,
 	AVP_EPC_Packet_Filter_Identifier					= 1060,
 	AVP_EPC_Packet_Filter_Information					= 1061,
@@ -236,9 +234,9 @@ enum {
 	AVP_EPC_Resource_Allocation_Notification			= 1063, //Gx
 	AVP_EPC_Session_Linking_Indicator					= 1064,
 	AVP_EPC_PDN_Connection_ID							= 1065,
- 	
-/** TS 32.299  */
-	
+
+	/** TS 32.299  */
+
 	AVP_EPC_Additional_Type_Information					= 1205,
 	AVP_EPC_Content_Size								= 1206,
 	AVP_EPC_Additional_Content_Information				= 1207,
@@ -263,9 +261,9 @@ enum {
 	AVP_EPC_AF_Correlation_Information					= 1276,
 	AVP_EPC_Alternate_Charged_Party_Address				= 1280,
 	AVP_EPC_Media_Initiator_Party						= 1288,
-	
-	
-/** TS 29.272  */
+
+
+	/** TS 29.272  */
 	AVP_EPC_Subscription_Data							= 1400,
 	AVP_EPC_Terminal_Information						= 1401,
 	AVP_EPC_IMEI										= 1402,
@@ -317,7 +315,7 @@ enum {
 	AVP_EPC_XRES										= 1448,
 	AVP_EPC_AUTN										= 1449,
 	AVP_EPC_KASME										= 1450,
-	
+
 	AVP_EPC_Trace_Collection_Entity						= 1452,
 	AVP_EPC_Kc											= 1453,
 	AVP_EPC_SRES										= 1454,
@@ -326,7 +324,7 @@ enum {
 	AVP_EPC_Roaming_Restricted_Due_To_Unsupported_Feature = 1457,
 	AVP_EPC_Trace_Data									= 1458,
 	AVP_EPC_Trace_Reference								= 1459,
-	
+
 	AVP_EPC_Trace_Depth									= 1462,
 	AVP_EPC_Trace_NE_Type_List							= 1463,
 	AVP_EPC_Trace_Interface_List						= 1464,
@@ -361,16 +359,16 @@ enum {
 	AVP_EPC_Homogenous_Support_of_IMS_Over_PS_Sessions	= 1493,
 	AVP_EPC_Last_UE_Activity_Time						= 1494,
 
-/** TS 29.273  */	
-	
+	/** TS 29.273  */
+
 	AVP_EPC_Non_3GPP_User_Data							= 1500,
 	AVP_EPC_Non_3GPP_IP_Access							= 1501,
 	AVP_EPC_Non_3GPP_IP_Access_APN						= 1502,
 	AVP_EPC_ANID										= 1504,
 	AVP_EPC_Trace_Info									= 1505,
-	
-/** TS 32.299  */
-	
+
+	/** TS 32.299  */
+
 	AVP_EPC_Client_Address								= 2018,
 	AVP_EPC_Carrier_Select_Routing_Information			= 2023,
 	AVP_EPC_Associated_Party_Address					= 2035,
@@ -393,7 +391,7 @@ enum {
 	AVP_EPC_Content_ID									= 2116,
 	AVP_EPC_Content_Provide_ID							= 2117,
 	AVP_EPC_SIP_Request_Timestamp_Fraction				= 2301,
-	AVP_EPC_SIP_Response_Timestamp_Fraction				= 2302,	
+	AVP_EPC_SIP_Response_Timestamp_Fraction				= 2302,
 	AVP_EPC_Account_Expiration							= 2309,
 	AVP_EPC_AoC_Cost_Format								= 2310,
 	AVP_EPC_AoC_Service									= 2311,
@@ -401,25 +399,25 @@ enum {
 	AVP_EPC_AoC_Service_Type							= 2313,
 	AVP_EPC_AoC_Subscription_Information				= 2314,
 	AVP_EPC_Outgoing_Session_Id							= 2320,
-	
-	
-	
-/** 2400 to 2407 reserved for TS29.173											*/
+
+
+
+	/** 2400 to 2407 reserved for TS29.173											*/
 
 	AVP_EPC_GMLC_Address								= 2405,
-	
-	
-	
-/** Not yet allocated */	
 
-	AVP_EPC_PDN_Gw_Address								= 42002, 
-	AVP_EPC_PDN_Gw_Name									= 42003, 
-	AVP_EPC_PDN_Gw_Identity								= 42004, 
-	AVP_EPC_QoS_Profile_Name							= 42005, 
-	AVP_EPC_GG_Enforce									= 42006, 
-	AVP_EPC_GG_IP										= 42007, 
-	AVP_EPC_UE_Locator									= 42008, 
-	AVP_EPC_UE_Locator_Id_Group							= 42009, 
+
+
+	/** Not yet allocated */
+
+	AVP_EPC_PDN_Gw_Address								= 42002,
+	AVP_EPC_PDN_Gw_Name									= 42003,
+	AVP_EPC_PDN_Gw_Identity								= 42004,
+	AVP_EPC_QoS_Profile_Name							= 42005,
+	AVP_EPC_GG_Enforce									= 42006,
+	AVP_EPC_GG_IP										= 42007,
+	AVP_EPC_UE_Locator									= 42008,
+	AVP_EPC_UE_Locator_Id_Group							= 42009,
 };
 
 /** Flow-Usage AVP */
@@ -477,7 +475,7 @@ enum {
 	AVP_EPC_Network_Request_Support_Supported				=1
 };
 
-/** IP-CAN Type TS 29.212 */ 
+/** IP-CAN Type TS 29.212 */
 enum {
 	AVP_EPC_IPCAN_Type_3GPP_GPRS 	= 0,
 	AVP_EPC_IPCAN_Type_DOCSIS 		= 1,
@@ -541,10 +539,10 @@ enum {
 };
 
 /** Event-Trigger TS 29.212*/
-enum {	
-	AVP_EPC_Event_Trigger_SGSN_CHANGE 							=0, 
+enum {
+	AVP_EPC_Event_Trigger_SGSN_CHANGE 							=0,
 	AVP_EPC_Event_Trigger_QOS_CHANGE 							=1,
-	AVP_EPC_Event_Trigger_RAT_CHANGE 							=2,	
+	AVP_EPC_Event_Trigger_RAT_CHANGE 							=2,
 	AVP_EPC_Event_Trigger_TFT_CHANGE 							=3,
 	AVP_EPC_Event_Trigger_PLMN_CHANGE 							=4,
 	AVP_EPC_Event_Trigger_LOSS_OF_BEARER 						=5,
@@ -554,10 +552,10 @@ enum {
 	AVP_EPC_Event_Trigger_RESOURCES_LIMITATION 					=9, //Release 7
 	AVP_EPC_Event_Trigger_MAX_NR_BEARERS_REACHED 				=10, //Release 7
 	AVP_EPC_Event_Trigger_QOS_CHANGE_EXCEEDING_AUTHORIZATION	=11,
-	AVP_EPC_Event_Trigger_RAI_CHANGE							=12, 
+	AVP_EPC_Event_Trigger_RAI_CHANGE							=12,
 	AVP_EPC_Event_Trigger_USER_LOCATION_CHANGE 					=13,
-	AVP_EPC_Event_Trigger_NO_EVENT_TRIGGER						=14,	 
-	AVP_EPC_Event_Trigger_OUT_OF_CREDIT							=15, 
+	AVP_EPC_Event_Trigger_NO_EVENT_TRIGGER						=14,
+	AVP_EPC_Event_Trigger_OUT_OF_CREDIT							=15,
 	AVP_EPC_Event_Trigger_RELLOCATION_OF_CREDIT					=16,
 	AVP_EPC_Event_Trigger_REVALIDATION_TIMEOUT					=17,
 	AVP_EPC_Event_Trigger_IP_ADDRESS_ALLOCATE					=18,
@@ -599,8 +597,8 @@ enum {
 	AVP_EPC_Subscription_Id_Type_End_User_E164					= 0,
 	AVP_EPC_Subscription_Id_Type_End_User_IMSI					= 1,
 	AVP_EPC_Subscription_Id_Type_End_User_SIP_URI				= 2,
-	AVP_EPC_Subscription_Id_Type_End_User_NAI					= 3,	
-	AVP_EPC_Subscription_Id_Type_End_User_Private				= 4,	
+	AVP_EPC_Subscription_Id_Type_End_User_NAI					= 3,
+	AVP_EPC_Subscription_Id_Type_End_User_Private				= 4,
 };
 
 enum {
@@ -648,46 +646,46 @@ enum {
 
 enum {
 	AVP_EPC_ULR_Flags_Single_Registration_Indication				= 1<<0,
-	AVP_EPC_ULR_Flags_S6a_Indicator									= 1<<1,	
-	AVP_EPC_ULR_Flags_Skip_Subscriber_Data							= 1<<2,			
-	AVP_EPC_ULR_Flags_GPRS_Subscription_Data_Indicator				= 1<<3,			
-	AVP_EPC_ULR_Flags_Node_Type_Indicator							= 1<<4,			
-	AVP_EPC_ULR_Flags_Initial_Attach_Indicator						= 1<<5,			
-	AVP_EPC_ULR_Flags_PS_LCS_Not_Supported_By_UE					= 1<<6,			
+	AVP_EPC_ULR_Flags_S6a_Indicator									= 1<<1,
+	AVP_EPC_ULR_Flags_Skip_Subscriber_Data							= 1<<2,
+	AVP_EPC_ULR_Flags_GPRS_Subscription_Data_Indicator				= 1<<3,
+	AVP_EPC_ULR_Flags_Node_Type_Indicator							= 1<<4,
+	AVP_EPC_ULR_Flags_Initial_Attach_Indicator						= 1<<5,
+	AVP_EPC_ULR_Flags_PS_LCS_Not_Supported_By_UE					= 1<<6,
 };
 
 enum {
-	AVP_EPC_ULA_Flags_Separation_Indication							= 1<<0,			
+	AVP_EPC_ULA_Flags_Separation_Indication							= 1<<0,
 };
 
 enum {
 	AVP_EPC_Feature_List_ODB_all_APN								= 1<<0,
-	AVP_EPC_Feature_List_ODB_HPLMN_APN								= 1<<1,	
-	AVP_EPC_Feature_List_ODB_VPLMN_APN								= 1<<2,			
-	AVP_EPC_Feature_List_ODB_all_OG									= 1<<3,			
-	AVP_EPC_Feature_List_ODB_all_InternationalOG					= 1<<4,			
-	AVP_EPC_Feature_List_ODB_all_InternationalOGNoToHPLMN_Country	= 1<<5,			
-	AVP_EPC_Feature_List_ODB_all_InterzonalIOG						= 1<<6,			
-	AVP_EPC_Feature_List_ODB_all_InterzonalIOGNotToHPLMN_Country	= 1<<7,			
-	AVP_EPC_Feature_List_ODB_all_InterzonalIOGAndInternationalOGNotToHPLMN_Country = 1<<8,			
-	AVP_EPC_Feature_List_RegSub										= 1<<9,			
-	AVP_EPC_Feature_List_Trace										= 1<<10,			
-	AVP_EPC_Feature_List_LCS_all_PrivExcep							= 1<<11,			
-	AVP_EPC_Feature_List_LCS_Universal								= 1<<12,			
-	AVP_EPC_Feature_List_LCS_CallSessionRelated						= 1<<13,			
-	AVP_EPC_Feature_List_LCS_CallSessionUnrelated					= 1<<14,			
-	AVP_EPC_Feature_List_LCS_PLMNOperator							= 1<<15,			
-	AVP_EPC_Feature_List_LCS_Service_Type							= 1<<16,			
-	AVP_EPC_Feature_List_LCS_all_MOLR_SS							= 1<<17,			
-	AVP_EPC_Feature_List_LCS_BasicShelfLocation						= 1<<18,			
-	AVP_EPC_Feature_List_LCS_AutonomousSelfLocation					= 1<<19,			
-	AVP_EPC_Feature_List_LCS_TransferToThirdParty					= 1<<20,			
+	AVP_EPC_Feature_List_ODB_HPLMN_APN								= 1<<1,
+	AVP_EPC_Feature_List_ODB_VPLMN_APN								= 1<<2,
+	AVP_EPC_Feature_List_ODB_all_OG									= 1<<3,
+	AVP_EPC_Feature_List_ODB_all_InternationalOG					= 1<<4,
+	AVP_EPC_Feature_List_ODB_all_InternationalOGNoToHPLMN_Country	= 1<<5,
+	AVP_EPC_Feature_List_ODB_all_InterzonalIOG						= 1<<6,
+	AVP_EPC_Feature_List_ODB_all_InterzonalIOGNotToHPLMN_Country	= 1<<7,
+	AVP_EPC_Feature_List_ODB_all_InterzonalIOGAndInternationalOGNotToHPLMN_Country = 1<<8,
+	AVP_EPC_Feature_List_RegSub										= 1<<9,
+	AVP_EPC_Feature_List_Trace										= 1<<10,
+	AVP_EPC_Feature_List_LCS_all_PrivExcep							= 1<<11,
+	AVP_EPC_Feature_List_LCS_Universal								= 1<<12,
+	AVP_EPC_Feature_List_LCS_CallSessionRelated						= 1<<13,
+	AVP_EPC_Feature_List_LCS_CallSessionUnrelated					= 1<<14,
+	AVP_EPC_Feature_List_LCS_PLMNOperator							= 1<<15,
+	AVP_EPC_Feature_List_LCS_Service_Type							= 1<<16,
+	AVP_EPC_Feature_List_LCS_all_MOLR_SS							= 1<<17,
+	AVP_EPC_Feature_List_LCS_BasicShelfLocation						= 1<<18,
+	AVP_EPC_Feature_List_LCS_AutonomousSelfLocation					= 1<<19,
+	AVP_EPC_Feature_List_LCS_TransferToThirdParty					= 1<<20,
 	AVP_EPC_Feature_List_SM_Mo_PP									= 1<<21,
-	AVP_EPC_Feature_List_Barring_OutgoingCalls						= 1<<22,			
-	AVP_EPC_Feature_List_BAOC										= 1<<23,			
-	AVP_EPC_Feature_List_BOIC										= 1<<24,			
-	AVP_EPC_Feature_List_BOICExHC									= 1<<25,			
-	AVP_EPC_Feature_List_T_ADSDataRetrieval							= 1<<26,			
+	AVP_EPC_Feature_List_Barring_OutgoingCalls						= 1<<22,
+	AVP_EPC_Feature_List_BAOC										= 1<<23,
+	AVP_EPC_Feature_List_BOIC										= 1<<24,
+	AVP_EPC_Feature_List_BOICExHC									= 1<<25,
+	AVP_EPC_Feature_List_T_ADSDataRetrieval							= 1<<26,
 };
 
 enum {
@@ -712,19 +710,19 @@ enum {
 
 enum {
 	AVP_EPC_DSR_Flags_Regional_Subscription_Withdrawal				= 1<<0,
-	AVP_EPC_DSR_Flags_Complete_APN_Configuration_Profile_Withdrawal	= 1<<1,	
-	AVP_EPC_DSR_Flags_Subscribed_Charging_Characteristics_Withdrawal= 1<<2,			
-	AVP_EPC_DSR_Flags_PDN_Subscription_Contexts_Withdrawal			= 1<<3,			
-	AVP_EPC_DSR_Flags_STN_SR										= 1<<4,			
-	AVP_EPC_DSR_Flags_Complete_PDP_Context_List_Withdrawal			= 1<<5,			
-	AVP_EPC_DSR_Flags_PDP_Contexts_Withdrawal						= 1<<6,			
-	AVP_EPC_DSR_Flags_Roaming_Restricted_Due_To_Unsupported_Feature	= 1<<7,			
-	AVP_EPC_DSR_Flags_Trace_Data_Withdrawal							= 1<<8,			
-	AVP_EPC_DSR_Flags_CSG_Deleted									= 1<<9,			
-	AVP_EPC_DSR_Flags_APN_OI_Replacement							= 1<<10,			
-	AVP_EPC_DSR_Flags_GMLC_List_Withdrawal							= 1<<11,			
-	AVP_EPC_DSR_Flags_LCS_Withdrawal								= 1<<12,			
-	AVP_EPC_DSR_Flags_SMS_Withdrawal								= 1<<13,			
+	AVP_EPC_DSR_Flags_Complete_APN_Configuration_Profile_Withdrawal	= 1<<1,
+	AVP_EPC_DSR_Flags_Subscribed_Charging_Characteristics_Withdrawal= 1<<2,
+	AVP_EPC_DSR_Flags_PDN_Subscription_Contexts_Withdrawal			= 1<<3,
+	AVP_EPC_DSR_Flags_STN_SR										= 1<<4,
+	AVP_EPC_DSR_Flags_Complete_PDP_Context_List_Withdrawal			= 1<<5,
+	AVP_EPC_DSR_Flags_PDP_Contexts_Withdrawal						= 1<<6,
+	AVP_EPC_DSR_Flags_Roaming_Restricted_Due_To_Unsupported_Feature	= 1<<7,
+	AVP_EPC_DSR_Flags_Trace_Data_Withdrawal							= 1<<8,
+	AVP_EPC_DSR_Flags_CSG_Deleted									= 1<<9,
+	AVP_EPC_DSR_Flags_APN_OI_Replacement							= 1<<10,
+	AVP_EPC_DSR_Flags_GMLC_List_Withdrawal							= 1<<11,
+	AVP_EPC_DSR_Flags_LCS_Withdrawal								= 1<<12,
+	AVP_EPC_DSR_Flags_SMS_Withdrawal								= 1<<13,
 };
 
 enum {
@@ -738,23 +736,23 @@ enum {
 
 enum {
 	AVP_EPC_Operator_Determined_Barring_All_Packet_Oriented_Services_Barred						= 1<<0,
-	AVP_EPC_Operator_Determined_Barring_Roamer_Access_HPLMN_AP_Barred							= 1<<1,	
-	AVP_EPC_Operator_Determined_Barring_Roamer_Access_To_VPLMN_AP_Barred						= 1<<2,			
-	AVP_EPC_Operator_Determined_Barring_Outgoing_Calls											= 1<<3,			
-	AVP_EPC_Operator_Determined_Barring_Outgoing_International_Calls							= 1<<4,			
-	AVP_EPC_Operator_Determined_Barring_Outgoing_International_Calls_Except_To_HPLMN_Country	= 1<<5,			
-	AVP_EPC_Operator_Determined_Barring_Outgoing_Inter_zonal_Calls								= 1<<6,			
-	AVP_EPC_Operator_Determined_Barring_Outgoing_Inter_zonal_Calls_Except_To_HPLMN_Country		= 1<<7,			
-	AVP_EPC_Operator_Determined_Barring_Outgoing_International_Calls_Except_To_HPLMN_Country_and_All_Inter_zonal_Calls = 1<<8,			
+	AVP_EPC_Operator_Determined_Barring_Roamer_Access_HPLMN_AP_Barred							= 1<<1,
+	AVP_EPC_Operator_Determined_Barring_Roamer_Access_To_VPLMN_AP_Barred						= 1<<2,
+	AVP_EPC_Operator_Determined_Barring_Outgoing_Calls											= 1<<3,
+	AVP_EPC_Operator_Determined_Barring_Outgoing_International_Calls							= 1<<4,
+	AVP_EPC_Operator_Determined_Barring_Outgoing_International_Calls_Except_To_HPLMN_Country	= 1<<5,
+	AVP_EPC_Operator_Determined_Barring_Outgoing_Inter_zonal_Calls								= 1<<6,
+	AVP_EPC_Operator_Determined_Barring_Outgoing_Inter_zonal_Calls_Except_To_HPLMN_Country		= 1<<7,
+	AVP_EPC_Operator_Determined_Barring_Outgoing_International_Calls_Except_To_HPLMN_Country_and_All_Inter_zonal_Calls = 1<<8,
 };
 
 enum {
 	AVP_EPC_Access_Restriction_Data_UTRAN_Not_Allowed					= 1<<0,
-	AVP_EPC_Access_Restriction_Data_GERAN_Not_Allowed					= 1<<1,	
-	AVP_EPC_Access_Restriction_Data_GAN_Not_Allowed 					= 1<<2,			
-	AVP_EPC_Access_Restriction_Data_I_HSPA_Evolution_Not_Allowed		= 1<<3,			
-	AVP_EPC_Access_Restriction_Data_E_UTRA_Not_Allowed					= 1<<4,			
-	AVP_EPC_Access_Restriction_Data_HO_To_Non_3GPP_Access_Not_Allowed 	= 1<<5,		
+	AVP_EPC_Access_Restriction_Data_GERAN_Not_Allowed					= 1<<1,
+	AVP_EPC_Access_Restriction_Data_GAN_Not_Allowed 					= 1<<2,
+	AVP_EPC_Access_Restriction_Data_I_HSPA_Evolution_Not_Allowed		= 1<<3,
+	AVP_EPC_Access_Restriction_Data_E_UTRA_Not_Allowed					= 1<<4,
+	AVP_EPC_Access_Restriction_Data_HO_To_Non_3GPP_Access_Not_Allowed 	= 1<<5,
 };
 
 enum {
@@ -800,7 +798,7 @@ enum {
 	AVP_EPC_PDN_Type_IPv6											= 1,
 	AVP_EPC_PDN_Type_IPv4v6											= 2,
 	AVP_EPC_PDN_Type_IPv4_or_IPv6									= 3,
-			
+
 };
 
 enum {
@@ -830,7 +828,7 @@ enum {
 	AVP_EPC_PLMN_Client_O_And_M_HPLMN								= 1,
 	AVP_EPC_PLMN_Client_O_And_M_VPLMN								= 2,
 	AVP_EPC_PLMN_Client_Anonymous_Location							= 3,
-	AVP_EPC_PLMN_Client_Target_UE_Subscribed_Services				= 4,		
+	AVP_EPC_PLMN_Client_Target_UE_Subscribed_Services				= 4,
 };
 
 enum {
@@ -866,7 +864,7 @@ enum {
 };
 
 enum {
-	AVP_EPC_Current_Location_Retrieved_Active_Location_Retrieval	= 0			
+	AVP_EPC_Current_Location_Retrieved_Active_Location_Retrieval	= 0
 };
 
 enum {
@@ -885,7 +883,7 @@ enum {
 	AVP_EPC_Node_Functionality_IBCF		= 7,
 	AVP_EPC_Node_Functionality_S_GW		= 8,
 	AVP_EPC_Node_Functionality_P_GW		= 9,
-	AVP_EPC_Node_Functionality_HSGW		= 10,	
+	AVP_EPC_Node_Functionality_HSGW		= 10,
 };
 
 enum {
@@ -906,7 +904,7 @@ enum {
 enum {
 	AVP_EPC_Media_Initiator_Flag_Called_Party		= 0,
 	AVP_EPC_Media_Initiator_Flag_Calling_Party		= 1,
-	AVP_EPC_Media_Initiator_Flag_Unknown			= 2,	
+	AVP_EPC_Media_Initiator_Flag_Unknown			= 2,
 };
 
 enum {

+ 9 - 11
modules/cdp/diameter_epc_code_cmd.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 #ifndef DIAMETER_EPC_CODE_CMD_H_
 #define DIAMETER_EPC_CODE_CMD_H_

+ 10 - 12
modules/cdp/diameter_epc_code_result.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef DIAMETER_EPC_CODE_RESULT_H_
@@ -60,7 +58,7 @@ enum{
 	RC_EPC_DIAMETER_ERROR_IDENTITY_NOT_REGISTERED		= 5003, //TS 29.273
 	RC_EPC_DIAMETER_AUTHORIZATION_REJECTED				= 5003, //TS 32.299
 	RC_EPC_DIAMETER_ERROR_ROAMING_NOT_ALLOWED			= 5004, //TS 29.273
-	RC_EPC_DIAMETER_ERROR_IDENTITY_ALREADY_REGISTERED	= 5005, //TS 29.273	
+	RC_EPC_DIAMETER_ERROR_IDENTITY_ALREADY_REGISTERED	= 5005, //TS 29.273
 	RC_EPC_DIAMETER_USER_UNKNOWN						= 5030, //TS 32.299
 	RC_EPC_DIAMETER_RATING_FAILED						= 5031, //TS 32.299
 	RC_EPC_DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION		= 5420,

+ 9 - 11
modules/cdp/diameter_ims.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __DIAMETER_IMS_H

+ 11 - 13
modules/cdp/diameter_ims_code_app.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __DIAMETER_IMS_CODE_APP_H
@@ -55,8 +53,8 @@
 #define IMS_Ph	16777217	/**< Sh interface between PresenceServer and HSS*/
 #define IMS_Rx  16777236	/**< Rx interface between P-CSCF and PCRF 		*/
 #define IMS_Gx	16777224	/**< Gx interface between PCRF and PCEF 		*/
-#define IMS_Rf  16777223    /**< Rf interface between P/I/S-CSCF and CDF, 
-								according to TS32.299 R7    */ 
+#define IMS_Rf  16777223    /**< Rf interface between P/I/S-CSCF and CDF,
+								according to TS32.299 R7    */
 
 #define IMS_Ro  4               /**< Ro interface between P/I/S-CSCF and OCS, according to TS32.299 R7    */
 

+ 95 - 97
modules/cdp/diameter_ims_code_avp.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,55 +35,55 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __DIAMETER_IMS_CODE_AVP_H
 #define __DIAMETER_IMS_CODE_AVP_H
 
 
-/** 3GPP AVP Codes */ 
+/** 3GPP AVP Codes */
 enum {
-/**   1 to 255 reserved for backward compatibility with IMS Radius TS29.061	*/
+	/**   1 to 255 reserved for backward compatibility with IMS Radius TS29.061	*/
 	AVP_IMS_Digest_Realm								= 104,
 	AVP_IMS_Digest_QoP									= 110,
 	AVP_IMS_Digest_Algorithm							= 111,
 	AVP_IMS_Digest_Auth_Param							= 117,
 	AVP_IMS_Digest_Domain								= 119,
 	AVP_IMS_Digest_HA1									= 121,
-/** 256 to 299 reserved for future use										*/
+	/** 256 to 299 reserved for future use										*/
 	AVP_IMS_Vendor_Id									= 266,
 	AVP_IMS_Experimental_Result_Code					= 298,
 	AVP_IMS_Experimental_Result							= 297,
-/** 300 to 399 reserved for TS29.234											*/
+	/** 300 to 399 reserved for TS29.234											*/
 
-/** 400 to 499 reserved for TS29.109											*/
+	/** 400 to 499 reserved for TS29.109											*/
 	AVP_IMS_CCR_Number									= 415,
 	AVP_IMS_CCR_Type									= 416,
- 	AVP_IMS_Service_Identifier							= 439,
- /**  or   RFC 4006 															*/
- 	AVP_IMS_Subscription_Id								= 443,
- 	AVP_IMS_Subscription_Id_Data						= 444,
- 	AVP_IMS_Subscription_Id_Type						= 450,
- /* This require ETSI vendor id and are from ETSI TS 183 017*/
- 	AVP_ETSI_Binding_Information						= 450,
- 	AVP_ETSI_Binding_Input_List							= 451,
- 	AVP_ETSI_Binding_Output_List						= 452,
- 	AVP_ETSI_V6_transport_address						= 453,
- 	AVP_ETSI_V4_transport_address						= 454,
- 	AVP_ETSI_Port_Number								= 455,
- 	AVP_ETSI_Reservation_Class							= 456,
- 	AVP_ETSI_Latching_Indication						= 457,
- 	AVP_ETSI_Reservation_Priority						= 458,
+	AVP_IMS_Service_Identifier							= 439,
+	/**  or   RFC 4006 															*/
+	AVP_IMS_Subscription_Id								= 443,
+	AVP_IMS_Subscription_Id_Data						= 444,
+	AVP_IMS_Subscription_Id_Type						= 450,
+	/* This require ETSI vendor id and are from ETSI TS 183 017*/
+	AVP_ETSI_Binding_Information						= 450,
+	AVP_ETSI_Binding_Input_List							= 451,
+	AVP_ETSI_Binding_Output_List						= 452,
+	AVP_ETSI_V6_transport_address						= 453,
+	AVP_ETSI_V4_transport_address						= 454,
+	AVP_ETSI_Port_Number								= 455,
+	AVP_ETSI_Reservation_Class							= 456,
+	AVP_ETSI_Latching_Indication						= 457,
+	AVP_ETSI_Reservation_Priority						= 458,
 	AVP_ETSI_Service_Class								= 459,
 	AVP_ETSI_Overbooking_Indication						= 460,
 	AVP_ETSI_Authorization_Package_Id  					= 461,
 	AVP_ETSI_Media_Authorization_Context_Id 			= 462,
 
-/** 500 to 599 reserved for TS29.209											*/
+	/** 500 to 599 reserved for TS29.209											*/
 	AVP_IMS_Abort_Cause									= 500,
 	AVP_IMS_Access_Network_Charging_Address				= 501,
 	AVP_IMS_Access_Network_Charging_Identifier			= 502,
@@ -109,12 +107,12 @@ enum {
 	AVP_IMS_RR_Bandwidth								= 521,
 	AVP_IMS_RS_Bandwidth								= 522,
 	AVP_IMS_SIP_Forking_Indication						= 523,
-/** Codec-Data is from TS 29.214*/
+	/** Codec-Data is from TS 29.214*/
 	AVP_IMS_Codec_Data									= 524,
 	AVP_IMS_Service_URN									= 525,
 	AVP_IMS_Acceptable_Service_Info						= 526,
 	AVP_IMS_Service_Info_Status							= 527,
-/** 600 to 699 reserved for TS29.229											*/
+	/** 600 to 699 reserved for TS29.229											*/
 	AVP_IMS_Visited_Network_Identifier					= 600,
 	AVP_IMS_Public_Identity								= 601,
 	AVP_IMS_Server_Name									= 602,
@@ -165,8 +163,8 @@ enum {
 	AVP_IMS_Associated_Registered_Identities			= 647,
 	AVP_IMS_Multiple_Registration_Indication			= 648,
 	AVP_IMS_Restoration_Info							= 649,
-	
-/** 700 to 799 reserved for TS29.329											*/
+
+	/** 700 to 799 reserved for TS29.329											*/
 	AVP_IMS_User_Identity								= 700,
 	AVP_IMS_MSISDN										= 701,
 	AVP_IMS_User_Data_Sh								= 702,
@@ -179,8 +177,8 @@ enum {
 	AVP_IMS_Expiry_Time									= 709,
 	AVP_IMS_Send_Data_Indication						= 710,
 	AVP_IMS_DSAI_Tag									= 711,
-	
-/** 800 to 899 reserved for TS29.299											*/
+
+	/** 800 to 899 reserved for TS29.299											*/
 	AVP_IMS_Event_Type 									= 823,
 	AVP_IMS_SIP_Method									= 824,
 	AVP_IMS_Event										= 825,
@@ -220,25 +218,25 @@ enum {
 	AVP_IMS_PoC_Group_Name								= 859,
 	AVP_IMS_Cause										= 860,
 	AVP_IMS_Cause_Code									= 861,
-	
+
 	/* TODO finish the list... */
 	AVP_IMS_Node_Functionality							= 862,
 	AVP_IMS_Service_Information							= 873,
 	AVP_IMS_IMS_Information								= 876,
 	AVP_IMS_Expires										= 888,
 	AVP_IMS_Message_Body								= 889,
-/** 1000   from TS29.212 */
- 	AVP_IMS_Charging_Rule_Install						= 1001,
- 	AVP_IMS_Charging_Rule_Remove						= 1002,
- 	AVP_IMS_Charging_Rule_Definition					= 1003,
- 	AVP_IMS_Charging_Rule_Base_Name						= 1004,
- 	AVP_IMS_Charging_Rule_Name							= 1005,
- 	AVP_IMS_Event_Trigger								= 1006,
- 	AVP_IMS_QoS_Information								= 1016,
- 	AVP_IMS_Charging_Rule_Report						= 1018,
- 	AVP_IMS_Pcc_Rule_Status								= 1019,
- 	AVP_IMS_Bearer_Identifier							= 1020,
- 	AVP_IMS_QoS_Class_Identifier						= 1028,
+	/** 1000   from TS29.212 */
+	AVP_IMS_Charging_Rule_Install						= 1001,
+	AVP_IMS_Charging_Rule_Remove						= 1002,
+	AVP_IMS_Charging_Rule_Definition					= 1003,
+	AVP_IMS_Charging_Rule_Base_Name						= 1004,
+	AVP_IMS_Charging_Rule_Name							= 1005,
+	AVP_IMS_Event_Trigger								= 1006,
+	AVP_IMS_QoS_Information								= 1016,
+	AVP_IMS_Charging_Rule_Report						= 1018,
+	AVP_IMS_Pcc_Rule_Status								= 1019,
+	AVP_IMS_Bearer_Identifier							= 1020,
+	AVP_IMS_QoS_Class_Identifier						= 1028,
 
 	AVP_IMS_Service_Specific_Info						= 1249,
 	AVP_IMS_Requested_Party_Address						= 1251,
@@ -246,54 +244,54 @@ enum {
 
 };
 
-/** ETSI AVP Codes */ 
+/** ETSI AVP Codes */
 enum {
-	
+
 	/*added from ETSI 283 034 */
 	AVP_ETSI_Globally_Unique_Address					=300,
 	AVP_ETSI_Address_Realm								=301,
 	AVP_ETSI_Logical_Access_Id							=302,
-	AVP_ETSI_Initial_Gate_Setting						=303, 
+	AVP_ETSI_Initial_Gate_Setting						=303,
 	AVP_ETSI_QoS_Profile								=304,
 	AVP_ETSI_IP_Connectivity_Status						=305,
 	AVP_ETSI_Access_Network_Type						=306,
 	AVP_ETSI_Aggregation_Network_Type					=307,
 	AVP_ETSI_Maximum_Allowed_Bandwidth_UL				=308,
-	AVP_ETSI_Maximum_Allowed_Bandwidth_DL				=309, 
+	AVP_ETSI_Maximum_Allowed_Bandwidth_DL				=309,
 	AVP_ETSI_Transport_Class							=311,
 	AVP_ETSI_Application_Class_ID						=312,
 	AVP_ETSI_Physical_Access_ID							=313,
 	AVP_ETSI_Location_Information						=350,
-	AVP_ETSI_RACS_Contact_Point							=351, 
-	AVP_ETSI_Terminal_Type								=352, 
+	AVP_ETSI_RACS_Contact_Point							=351,
+	AVP_ETSI_Terminal_Type								=352,
 	AVP_ETSI_Requested_Information						=353,
 	AVP_ETSI_Event_Type									=354,
-	
+
 	AVP_ETSI_Line_Identifier							= 500,
-	AVP_ETSI_SIP_Authenticate 							= 501, 
-	AVP_ETSI_SIP_Authorization 							= 502, 
-	AVP_ETSI_SIP_Authentication_Info 					= 503, 
-	AVP_ETSI_Digest_Realm 								= 504,  
-	AVP_ETSI_Digest_Nonce 								= 505,  
-	AVP_ETSI_Digest_Domain								= 506,  
-	AVP_ETSI_Digest_Opaque 								= 507,  
-	AVP_ETSI_Digest_Stale 								= 508,  
-	AVP_ETSI_Digest_Algorithm 							= 509,  
-	AVP_ETSI_Digest_QoP 								= 510,  
-	AVP_ETSI_Digest_HA1 								= 511,  
-	AVP_ETSI_Digest_Auth_Param 							= 512,  
-	AVP_ETSI_Digest_Username 							= 513,  
-	AVP_ETSI_Digest_URI 								= 514,  
-	AVP_ETSI_Digest_Response 							= 515,  
-	AVP_ETSI_Digest_CNonce 								= 516,  
-	AVP_ETSI_Digest_Nonce_Count 						= 517,  
-	AVP_ETSI_Digest_Method 								= 518,  
-	AVP_ETSI_Digest_Entity_Body_Hash 					= 519,  
-	AVP_ETSI_Digest_Nextnonce 							= 520,  
-	AVP_ETSI_Digest_Response_Auth						= 521	
+	AVP_ETSI_SIP_Authenticate 							= 501,
+	AVP_ETSI_SIP_Authorization 							= 502,
+	AVP_ETSI_SIP_Authentication_Info 					= 503,
+	AVP_ETSI_Digest_Realm 								= 504,
+	AVP_ETSI_Digest_Nonce 								= 505,
+	AVP_ETSI_Digest_Domain								= 506,
+	AVP_ETSI_Digest_Opaque 								= 507,
+	AVP_ETSI_Digest_Stale 								= 508,
+	AVP_ETSI_Digest_Algorithm 							= 509,
+	AVP_ETSI_Digest_QoP 								= 510,
+	AVP_ETSI_Digest_HA1 								= 511,
+	AVP_ETSI_Digest_Auth_Param 							= 512,
+	AVP_ETSI_Digest_Username 							= 513,
+	AVP_ETSI_Digest_URI 								= 514,
+	AVP_ETSI_Digest_Response 							= 515,
+	AVP_ETSI_Digest_CNonce 								= 516,
+	AVP_ETSI_Digest_Nonce_Count 						= 517,
+	AVP_ETSI_Digest_Method 								= 518,
+	AVP_ETSI_Digest_Entity_Body_Hash 					= 519,
+	AVP_ETSI_Digest_Nextnonce 							= 520,
+	AVP_ETSI_Digest_Response_Auth						= 521
 };
 
-/** CableLabs AVP Codes */ 
+/** CableLabs AVP Codes */
 enum {
 	AVP_CableLabs_SIP_Digest_Authenticate 				= 228,
 	AVP_CableLabs_Digest_Realm 							= 209,
@@ -338,7 +336,7 @@ enum {
 
 /** Originating-Request Enumerated AVP */
 enum {
-	AVP_IMS_LIR_ORIGINATING_REQUEST						= 0	
+	AVP_IMS_LIR_ORIGINATING_REQUEST						= 0
 };
 
 /** Data-Reference AVP */
@@ -351,12 +349,12 @@ enum {
 	AVP_IMS_Data_Reference_Location_Information			= 14,
 	AVP_IMS_Data_Reference_User_State					= 15,
 	AVP_IMS_Data_Reference_Charging_Information			= 16,
-	AVP_IMS_Data_Reference_MSISDN						= 17,	
-	AVP_IMS_Data_Reference_PSI_Activation				= 18,	
-	AVP_IMS_Data_Reference_DSAI							= 19,	
+	AVP_IMS_Data_Reference_MSISDN						= 17,
+	AVP_IMS_Data_Reference_PSI_Activation				= 18,
+	AVP_IMS_Data_Reference_DSAI							= 19,
 	AVP_IMS_Data_Reference_Aliases_Repository_Data		= 20,
 	AVP_IMS_Data_Reference_Service_Level_Trace_Info		= 21,
-	AVP_IMS_Data_Reference_IP_Address_Secure_Binding_Information = 22,	
+	AVP_IMS_Data_Reference_IP_Address_Secure_Binding_Information = 22,
 };
 
 /** Subs-Req-Type AVP */
@@ -387,7 +385,7 @@ enum{
 enum{
 	AVP_IMS_Feature_List_ID_Shared_iFC_Sets				= 1<<0,
 	AVP_IMS_Feature_List_ID_Alias_Indication			= 1<<1,
-	AVP_IMS_Feature_List_ID_IMS_Restoration_Indication  = 1<<2, 
+	AVP_IMS_Feature_List_ID_IMS_Restoration_Indication  = 1<<2,
 };
 
 /** Feature-List-ID AVP for Sh */
@@ -411,15 +409,15 @@ enum {
 enum {
 	AVP_IMS_Identity_Set_All_Identities					= 0,
 	AVP_IMS_Identity_Set_Registered_Identities			= 1,
-	AVP_IMS_Identity_Set_Implicit_Identities			= 2,	
-	AVP_IMS_Identity_Set_Alias_Identities				= 3	
+	AVP_IMS_Identity_Set_Implicit_Identities			= 2,
+	AVP_IMS_Identity_Set_Alias_Identities				= 3
 };
 
 /** Deregistration-Reason AVP */
 enum {
 	AVP_IMS_Deregistration_Reason_Permanent_Termination	= 0,
 	AVP_IMS_Deregistration_Reason_New_Server_Assigned	= 1,
-	AVP_IMS_Deregistration_Reason_Server_Change			= 2,	
+	AVP_IMS_Deregistration_Reason_Server_Change			= 2,
 	AVP_IMS_Deregistration_Reason_Remove_S_CSCF			= 3
 };
 
@@ -475,19 +473,19 @@ enum {
 
 enum {
 	AVP_Re_Auth_Request_Type_Authorize_Only			=0,
-	AVP_Re_Auth_Request_Type_Authorize_Authenticate	=1,		
+	AVP_Re_Auth_Request_Type_Authorize_Authenticate	=1,
 };
 
 
 
 /*
-access-info for each access type  
-"ADSL" / "ADSL2" / "ADSL2+" / "RADSL" / "SDSL" / "HDSL" / "HDSL2" / "G.SHDSL" / "VDSL" / "IDSL"  -> dsl-location
-"3GPP-GERAN" -> cgi-3gpp
-"3GPP-UTRAN-FDD" / "3GPP-UTRAN-TDD" -> utran-cell-id-3gpp
-"3GPP2-1X" / "3GPP2-1X-HRPD" -> ci-3gpp2
-"IEEE-802.11" / "IEEE-802.11a" / "IEEE-802.11b" / "IEEE-802.11g" -> i-wlan-node-id = MAC
-"DOCSIS" -> NULL
+	access-info for each access type
+	"ADSL" / "ADSL2" / "ADSL2+" / "RADSL" / "SDSL" / "HDSL" / "HDSL2" / "G.SHDSL" / "VDSL" / "IDSL"  -> dsl-location
+	"3GPP-GERAN" -> cgi-3gpp
+	"3GPP-UTRAN-FDD" / "3GPP-UTRAN-TDD" -> utran-cell-id-3gpp
+	"3GPP2-1X" / "3GPP2-1X-HRPD" -> ci-3gpp2
+	"IEEE-802.11" / "IEEE-802.11a" / "IEEE-802.11b" / "IEEE-802.11g" -> i-wlan-node-id = MAC
+	"DOCSIS" -> NULL
 */
 
 #endif /* __DIAMETER_IMS_CODE_AVP_H */

+ 9 - 11
modules/cdp/diameter_ims_code_cmd.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __DIAMETER_IMS_CODE_CMD_H

+ 9 - 11
modules/cdp/diameter_ims_code_result.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __DIAMETER_IMS_CODE_RESULT_H

+ 63 - 65
modules/cdp/diameter_msg.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include "diameter.h"
@@ -154,16 +152,16 @@ error:
  * @param commandCode - the command code for this message
  * @param applicationId - application id to be set
  * @param sessionId - session id to be set
- * @param request - if you want to create a response, put the request here. If you want a 
+ * @param request - if you want to create a response, put the request here. If you want a
  * request, call with NULL
  * @returns the AAAMessage* or NULL on error
- * \note This function is taken from DISC http://developer.berlios.de/projects/disc/ 
+ * \note This function is taken from DISC http://developer.berlios.de/projects/disc/
  */
 AAAMessage *AAANewMessage(
-	AAACommandCode commandCode,
-	AAAApplicationId applicationId,
-	AAASession *session,
-	AAAMessage *request)
+		AAACommandCode commandCode,
+		AAAApplicationId applicationId,
+		AAASession *session,
+		AAAMessage *request)
 {
 	AAAMessage   *msg;
 	AAA_AVP      *avp;
@@ -179,7 +177,7 @@ AAAMessage *AAANewMessage(
 	if (!session||!session->id.s) {
 		if (request){
 			/* copy old session id from AVP */
-			if (request->sessionId) 
+			if (request->sessionId)
 				sessionId = &(request->sessionId->data);
 		}else{
 			if (commandCode!=Code_DW)
@@ -205,7 +203,7 @@ AAAMessage *AAANewMessage(
 	/*add session ID */
 	if (sessionId){
 		avp = AAACreateAVP( 263, 0, 0, sessionId->s, sessionId->len,
-			AVP_DUPLICATE_DATA);
+				AVP_DUPLICATE_DATA);
 		if ( !avp || AAAAddAVPToMessage(msg,avp,0)!=AAA_ERR_SUCCESS) {
 			LM_ERR("AAANewMessage: cannot create/add Session-Id avp\n");
 			if (avp) AAAFreeAVP( &avp );
@@ -215,13 +213,13 @@ AAAMessage *AAANewMessage(
 	}
 
 	/* add origin host AVP */
-	/* changed by cristian to comply with rfc3588: 
+	/* changed by cristian to comply with rfc3588:
 	 * 6.3.  Origin-Host AVP
 	 *
 	 *    The Origin-Host AVP (AVP Code 264) is of type
 	 *    DiameterIdentity... */
 	avp = AAACreateAVP( 264, 0, 0, config->fqdn.s, config->fqdn.len,
-		AVP_DUPLICATE_DATA);
+			AVP_DUPLICATE_DATA);
 	if (!avp||AAAAddAVPToMessage(msg,avp,msg->avpList.tail)!=AAA_ERR_SUCCESS) {
 		LM_ERR("AAANewMessage: cannot create/add Origin-Host avp\n");
 		if (avp) AAAFreeAVP( &avp );
@@ -230,7 +228,7 @@ AAAMessage *AAANewMessage(
 	msg->orig_host = avp;
 	/* add origin realm AVP */
 	avp = AAACreateAVP( 296, 0, 0, config->realm.s, config->realm.len,
-		AVP_DUPLICATE_DATA);
+			AVP_DUPLICATE_DATA);
 	if (!avp||AAAAddAVPToMessage(msg,avp,msg->avpList.tail)!=AAA_ERR_SUCCESS) {
 		LM_ERR("AAANewMessage: cannot create/add Origin-Realm avp\n");
 		if (avp) AAAFreeAVP( &avp );
@@ -250,13 +248,13 @@ AAAMessage *AAANewMessage(
 		msg->endtoendId = request->endtoendId;
 		msg->hopbyhopId = request->hopbyhopId;
 
-		
+
 		//TODO: aon:move this information in the AAASession structure, do not add these fields for
-		
-	    if (msg->commandCode==Code_CE||msg->commandCode==Code_DP||msg->commandCode==Code_DW ||
-			    msg->commandCode==Diameter_CCR || msg->commandCode==Diameter_RAR){
-	    	// Don't add Destination Host/Realm because some stacks are way to picky and will just refuse it
-	    }else{
+
+		if (msg->commandCode==Code_CE||msg->commandCode==Code_DP||msg->commandCode==Code_DW ||
+				msg->commandCode==Diameter_CCR || msg->commandCode==Diameter_RAR){
+			// Don't add Destination Host/Realm because some stacks are way to picky and will just refuse it
+		}else{
 
 			/* Mirror the old originhost/realm to destinationhost/realm*/
 			//avp = AAAFindMatchingAVP(request,0,AVP_Origin_Host,0,0);
@@ -265,19 +263,19 @@ AAAMessage *AAANewMessage(
 			//avp = AAACreateAVP(AVP_Destination_Host,AAA_AVP_FLAG_MANDATORY,0,
 			//	dest_host.s,dest_host.len,AVP_DUPLICATE_DATA);
 			//if (!avp) {
-		//		LM_ERR("ERR:AAANewMessage: Failed creating Destination Host avp\n");
-		//		goto error;
-		//	}
-		//	if (AAAAddAVPToMessage(msg,avp,msg->avpList.tail)!=AAA_ERR_SUCCESS) {
-		//		LM_ERR("ERR:AAANewMessage: Failed adding Destination Host avp to message\n");
-		//		AAAFreeAVP(&avp);
-		//		goto error;
-		//	}
-	
+			//		LM_ERR("ERR:AAANewMessage: Failed creating Destination Host avp\n");
+			//		goto error;
+			//	}
+			//	if (AAAAddAVPToMessage(msg,avp,msg->avpList.tail)!=AAA_ERR_SUCCESS) {
+			//		LM_ERR("ERR:AAANewMessage: Failed adding Destination Host avp to message\n");
+			//		AAAFreeAVP(&avp);
+			//		goto error;
+			//	}
+
 			avp = AAAFindMatchingAVP(request,0,AVP_Origin_Realm,0,0);
 			if (avp) dest_realm = avp->data;
 			avp = AAACreateAVP(AVP_Destination_Realm,AAA_AVP_FLAG_MANDATORY,0,
-				dest_realm.s,dest_realm.len,AVP_DUPLICATE_DATA);
+					dest_realm.s,dest_realm.len,AVP_DUPLICATE_DATA);
 			if (!avp) {
 				LM_ERR("ERR:AAANewMessage: Failed creating Destination Realm avp\n");
 				goto error;
@@ -287,15 +285,15 @@ AAAMessage *AAANewMessage(
 				AAAFreeAVP(&avp);
 				goto error;
 			}
-	    }
+		}
 
 		msg->res_code=0;
 		/* mirror all the proxy-info avp in the same order */
 		avp_t = request->avpList.head;
 		while ( (avp_t=AAAFindMatchingAVP
-		(request,avp_t,284,0,AAA_FORWARD_SEARCH))!=0 ) {
+					(request,avp_t,284,0,AAA_FORWARD_SEARCH))!=0 ) {
 			if ( (avp=AAACloneAVP(avp_t,1))==0 || AAAAddAVPToMessage( msg, avp,
-			msg->avpList.tail)!=AAA_ERR_SUCCESS )
+						msg->avpList.tail)!=AAA_ERR_SUCCESS )
 				goto error;
 		}
 	}
@@ -316,9 +314,9 @@ error:
  * @returns the AAAMessage* or NULL on error
  */
 AAAMessage *AAACreateRequest(AAAApplicationId app_id,
-							AAACommandCode command_code,
-							AAAMsgFlag flags,
-							AAASession *session)
+		AAACommandCode command_code,
+		AAAMsgFlag flags,
+		AAASession *session)
 {
 	AAAMessage *msg;
 	AAA_AVP      *avp;
@@ -327,13 +325,13 @@ AAAMessage *AAACreateRequest(AAAApplicationId app_id,
 	if (!msg) return 0;
 	msg->hopbyhopId = next_hopbyhop();
 	msg->endtoendId = next_endtoend();
-	msg->flags |= flags;	
+	msg->flags |= flags;
 
 	if(session){
 		/* add destination host and destination realm */
 		/*if(session->dest_host.s){//TODO: check spec about removing this across the board (jason)
 			avp = AAACreateAVP(AVP_Destination_Host,AAA_AVP_FLAG_MANDATORY,0,
-				session->dest_host.s,session->dest_host.len,AVP_DUPLICATE_DATA);
+			session->dest_host.s,session->dest_host.len,AVP_DUPLICATE_DATA);
 			if (!avp) {
 				LM_ERR("ERR:AAACreateRequest: Failed creating Destination Host avp\n");
 				goto error;
@@ -347,7 +345,7 @@ AAAMessage *AAACreateRequest(AAAApplicationId app_id,
 
 		if(session->dest_realm.s){
 			avp = AAACreateAVP(AVP_Destination_Realm,AAA_AVP_FLAG_MANDATORY,0,
-				session->dest_realm.s,session->dest_realm.len,AVP_DUPLICATE_DATA);
+					session->dest_realm.s,session->dest_realm.len,AVP_DUPLICATE_DATA);
 			if (!avp) {
 				LM_ERR("ERR:AAACreateRequest: Failed creating Destination Realm avp\n");
 				goto error;
@@ -356,7 +354,7 @@ AAAMessage *AAACreateRequest(AAAApplicationId app_id,
 				LM_ERR("ERR:AAACreateRequest: Failed adding Destination Realm avp to message\n");
 				AAAFreeAVP(&avp);
 				goto error;
-			}		
+			}
 		}
 	}
 
@@ -367,7 +365,7 @@ error:
 }
 
 /**
- * Create a Diameter Response to a given Request. 
+ * Create a Diameter Response to a given Request.
  * @param request - the request that this response is for
  * @returns the AAAMessage* or NULL on error
  */
@@ -375,7 +373,7 @@ AAAMessage *AAACreateResponse(AAAMessage *request)
 {
 	AAAMessage *msg;
 	msg = AAANewMessage(request->commandCode,request->applicationId,0,request);
-		
+
 	return msg;
 }
 
@@ -383,7 +381,7 @@ AAAMessage *AAACreateResponse(AAAMessage *request)
 /**
  *  Frees a AVP List and all the members
  * @param avpList - list to be freed
- * @returns AAA_ERR_SUCCESS 
+ * @returns AAA_ERR_SUCCESS
  */
 AAAReturnCode  AAAFreeAVPList(AAA_AVP_LIST *avpList)
 {
@@ -405,7 +403,7 @@ AAAReturnCode  AAAFreeAVPList(AAA_AVP_LIST *avpList)
 /**
  *  Frees completely a message allocated through AAANewMessage()
  * @param msg - pointer to the pointer containing the message.
- * @returns AAA_ERR_SUCCESS 
+ * @returns AAA_ERR_SUCCESS
  */
 AAAReturnCode  AAAFreeMessage(AAAMessage **msg)
 {
@@ -433,12 +431,12 @@ done:
  *  Sets the proper result_code into the Result-Code AVP; ths avp must already
  * exists into the reply messge.
  * @param message - the message to set the Result-Code to
- * @param resultCode - code to set as result 
- * \note This function is taken from DISC http://developer.berlios.de/projects/disc/ 
+ * @param resultCode - code to set as result
+ * \note This function is taken from DISC http://developer.berlios.de/projects/disc/
  */
 AAAResultCode  AAASetMessageResultCode(
-	AAAMessage *message,
-	AAAResultCode resultCode)
+		AAAMessage *message,
+		AAAResultCode resultCode)
 {
 	if ( !is_req(message) && message->res_code) {
 		*((unsigned int*)(message->res_code->data.s)) = htonl(resultCode);
@@ -455,10 +453,10 @@ AAAResultCode  AAASetMessageResultCode(
  * @param sourceLen - the length of the input buffer
  * @param attach_buf - whether to attach the input buffer to the message
  * @returns the AAAMessage* or NULL on error
- * \note This function is taken from DISC http://developer.berlios.de/projects/disc/ 
+ * \note This function is taken from DISC http://developer.berlios.de/projects/disc/
  */
 AAAMessage* AAATranslateMessage( unsigned char* source, unsigned int sourceLen,
-															int attach_buf)
+		int attach_buf)
 {
 	unsigned char *ptr;
 	AAAMessage    *msg;
@@ -495,7 +493,7 @@ AAAMessage* AAATranslateMessage( unsigned char* source, unsigned int sourceLen,
 	ptr += VER_SIZE;
 	if (version!=1) {
 		LM_ERR("AAATranslateMessage: invalid version [%d]in "
-			"AAA msg\n",version);
+				"AAA msg\n",version);
 		goto error;
 	}
 
@@ -504,7 +502,7 @@ AAAMessage* AAATranslateMessage( unsigned char* source, unsigned int sourceLen,
 	ptr += MESSAGE_LENGTH_SIZE;
 	if (msg_len>sourceLen) {
 		LM_ERR("AAATranslateMessage: AAA message len [%d] bigger then"
-			" buffer len [%d]\n",msg_len,sourceLen);
+				" buffer len [%d]\n",msg_len,sourceLen);
 		goto error;
 	}
 
@@ -532,7 +530,7 @@ AAAMessage* AAATranslateMessage( unsigned char* source, unsigned int sourceLen,
 	while (ptr < source+msg_len) {
 		if (ptr+AVP_HDR_SIZE(0x80)>source+msg_len){
 			LM_ERR("AAATranslateMessage: source buffer to short!! "
-				"Cannot read the whole AVP header!\n");
+					"Cannot read the whole AVP header!\n");
 			goto error;
 		}
 		/* avp code */
@@ -546,7 +544,7 @@ AAAMessage* AAATranslateMessage( unsigned char* source, unsigned int sourceLen,
 		ptr += AVP_LENGTH_SIZE;
 		if (avp_len<1) {
 			LM_ERR("AAATranslateMessage: invalid AVP len [%d]\n",
-				avp_len);
+					avp_len);
 			goto error;
 		}
 		/* avp vendor-ID */
@@ -560,13 +558,13 @@ AAAMessage* AAATranslateMessage( unsigned char* source, unsigned int sourceLen,
 		/*check the data length */
 		if ( source+msg_len<ptr+avp_data_len) {
 			LM_ERR("AAATranslateMessage: source buffer to short!! "
-				"Cannot read a whole data for AVP!\n");
+					"Cannot read a whole data for AVP!\n");
 			goto error;
 		}
 
 		/* create the AVP */
 		avp = AAACreateAVP( avp_code, avp_flags, avp_vendorID, (char*) ptr,
-			avp_data_len, AVP_DONT_FREE_DATA);
+				avp_data_len, AVP_DONT_FREE_DATA);
 		if (!avp)
 			goto error;
 
@@ -597,7 +595,7 @@ error:
 /**
  *  print as debug all info contained by an aaa message + AVPs
  * @param msg - the AAAMessage to print
- * \note This function is taken from DISC http://developer.berlios.de/projects/disc/ 
+ * \note This function is taken from DISC http://developer.berlios.de/projects/disc/
  */
 void AAAPrintMessage( AAAMessage *msg)
 {

+ 9 - 11
modules/cdp/diameter_peer.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include <stdlib.h>

+ 12 - 14
modules/cdp/diameter_peer.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,17 +35,17 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __DIAMETER_PEER_H
 #define __DIAMETER_PEER_H
 
-#include <sys/types.h> 
-#include <unistd.h> 
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "utils.h"
 #include "diameter.h"
@@ -58,7 +56,7 @@
 
 /** Element for the local pid list. */
 typedef struct _pid_list_t{
-	pid_t pid;	
+	pid_t pid;
 	struct _pid_list_t *next,*prev;
 } pid_list_t;
 

+ 9 - 11
modules/cdp/globals.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include "globals.h"

+ 9 - 11
modules/cdp/globals.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef _c_diameter_peer_globals_h

+ 50 - 52
modules/cdp/mod.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include "mod.h"
@@ -68,7 +66,7 @@ unsigned int workerq_length_threshold_percentage = 0;	/**< default threshold for
 extern dp_config *config; 				/**< DiameterPeer configuration structure */
 
 #define EXP_FUNC(NAME) \
-		{#NAME, (cmd_function)NAME, NO_SCRIPT, 0, 0},
+{#NAME, (cmd_function)NAME, NO_SCRIPT, 0, 0},
 /**
  * Exported functions. This is the API available for use from other SER modules.
  * If you require more, please add them here.
@@ -107,55 +105,55 @@ static cmd_export_t cdp_cmds[] = {
 	{"load_cdp",					(cmd_function)load_cdp, 				NO_SCRIPT, 0, 0},
 
 	EXP_FUNC(AAACreateRequest)
-	EXP_FUNC(AAACreateResponse)
-	EXP_FUNC(AAAFreeMessage)
+		EXP_FUNC(AAACreateResponse)
+		EXP_FUNC(AAAFreeMessage)
 
 
-	EXP_FUNC(AAACreateAVP)
-	EXP_FUNC(AAAAddAVPToMessage)
-	EXP_FUNC(AAAAddAVPToList)
-	EXP_FUNC(AAAFindMatchingAVP)
-	EXP_FUNC(AAAFindMatchingAVPList)
-	EXP_FUNC(AAAGetNextAVP)
-	EXP_FUNC(AAAFreeAVP)
-	EXP_FUNC(AAAFreeAVPList)
-	EXP_FUNC(AAAGroupAVPS)
-	EXP_FUNC(AAAUngroupAVPS)
+		EXP_FUNC(AAACreateAVP)
+		EXP_FUNC(AAAAddAVPToMessage)
+		EXP_FUNC(AAAAddAVPToList)
+		EXP_FUNC(AAAFindMatchingAVP)
+		EXP_FUNC(AAAFindMatchingAVPList)
+		EXP_FUNC(AAAGetNextAVP)
+		EXP_FUNC(AAAFreeAVP)
+		EXP_FUNC(AAAFreeAVPList)
+		EXP_FUNC(AAAGroupAVPS)
+		EXP_FUNC(AAAUngroupAVPS)
 
-	EXP_FUNC(AAASendMessage)
-	EXP_FUNC(AAASendMessageToPeer)
-	EXP_FUNC(AAASendRecvMessage)
-	EXP_FUNC(AAASendRecvMessageToPeer)
+		EXP_FUNC(AAASendMessage)
+		EXP_FUNC(AAASendMessageToPeer)
+		EXP_FUNC(AAASendRecvMessage)
+		EXP_FUNC(AAASendRecvMessageToPeer)
 
 
-	EXP_FUNC(AAAAddRequestHandler)
-	EXP_FUNC(AAAAddResponseHandler)
+		EXP_FUNC(AAAAddRequestHandler)
+		EXP_FUNC(AAAAddResponseHandler)
 
 
-	EXP_FUNC(AAACreateTransaction)
-	EXP_FUNC(AAADropTransaction)
+		EXP_FUNC(AAACreateTransaction)
+		EXP_FUNC(AAADropTransaction)
 
 
-	EXP_FUNC(AAACreateSession)
-	EXP_FUNC(AAAMakeSession)
-	EXP_FUNC(AAAGetSession)
-	EXP_FUNC(AAADropSession)
-	EXP_FUNC(AAASessionsLock)
-	EXP_FUNC(AAASessionsUnlock)
+		EXP_FUNC(AAACreateSession)
+		EXP_FUNC(AAAMakeSession)
+		EXP_FUNC(AAAGetSession)
+		EXP_FUNC(AAADropSession)
+		EXP_FUNC(AAASessionsLock)
+		EXP_FUNC(AAASessionsUnlock)
 
-	EXP_FUNC(AAACreateClientAuthSession)
-	EXP_FUNC(AAACreateServerAuthSession)
-	EXP_FUNC(AAAGetAuthSession)
-	EXP_FUNC(AAADropAuthSession)
-	EXP_FUNC(AAATerminateAuthSession)
+		EXP_FUNC(AAACreateClientAuthSession)
+		EXP_FUNC(AAACreateServerAuthSession)
+		EXP_FUNC(AAAGetAuthSession)
+		EXP_FUNC(AAADropAuthSession)
+		EXP_FUNC(AAATerminateAuthSession)
 
-	EXP_FUNC(AAACreateCCAccSession)
-	EXP_FUNC(AAAStartChargingCCAccSession)
-	EXP_FUNC(AAAGetCCAccSession)
-	EXP_FUNC(AAADropCCAccSession)
-	EXP_FUNC(AAATerminateCCAccSession)
+		EXP_FUNC(AAACreateCCAccSession)
+		EXP_FUNC(AAAStartChargingCCAccSession)
+		EXP_FUNC(AAAGetCCAccSession)
+		EXP_FUNC(AAADropCCAccSession)
+		EXP_FUNC(AAATerminateCCAccSession)
 
-	{ 0, 0, 0, 0, 0 }
+		{ 0, 0, 0, 0, 0 }
 };
 
 
@@ -201,10 +199,10 @@ static int cdp_init( void )
 		LM_ERR("failed to register RPC commands for CDP module\n");
 		return -1;
 	}
-	
+
 	if (cdp_init_counters() != 0) {
-	    LM_ERR("Failed to register counters for CDP modules\n");
-	    return -1;
+		LM_ERR("Failed to register counters for CDP modules\n");
+		return -1;
 	}
 
 	if (!diameter_peer_init(config_file)){

+ 9 - 11
modules/cdp/mod.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef _CDP__H

+ 17 - 19
modules/cdp/peer.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include <time.h>
@@ -66,25 +64,25 @@ peer* new_peer(str fqdn,str realm,int port,str src_addr)
 	}
 	memset(x,0,sizeof(peer));
 	shm_str_dup_macro(x->fqdn,fqdn);
-	if (!x->fqdn.s) goto error;	
+	if (!x->fqdn.s) goto error;
 	shm_str_dup_macro(x->realm,realm);
-	if (!x->realm.s) goto error;	
+	if (!x->realm.s) goto error;
 	shm_str_dup_macro(x->src_addr,src_addr);
 	if (!x->src_addr.s) goto error;
 	x->port = port;
 	x->lock = lock_alloc();
 	x->lock = lock_init(x->lock);
-		
+
 	x->state = Closed;
 
 	x->I_sock = -1;
 	x->R_sock = -1;
 
-	x->activity = time(0)-500;	
-	
+	x->activity = time(0)-500;
+
 	x->next = 0;
 	x->prev = 0;
-	
+
 	return x;
 error:
 	return 0;
@@ -100,7 +98,7 @@ void free_peer(peer *x,int locked)
 	if (!x) return;
 	if (!locked) lock_get(x->lock);
 	if (x->fqdn.s) shm_free(x->fqdn.s);
-	if (x->realm.s) shm_free(x->realm.s);	
+	if (x->realm.s) shm_free(x->realm.s);
 	if (x->src_addr.s) shm_free(x->src_addr.s);
 	lock_destroy(x->lock);
 	lock_dealloc((void*)x->lock);
@@ -111,7 +109,7 @@ void free_peer(peer *x,int locked)
  * "Touches" the peer by updating the last activity time to the current time.
  * @param p - which peer to touch
  */
-inline void touch_peer(peer *p)
+void touch_peer(peer *p)
 {
 	p->activity = time(0);
 }

+ 7 - 9
modules/cdp/peer.h

@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
  *
@@ -104,26 +102,26 @@ typedef struct _peer_t{
 
 	app_config *applications;/**< list of supported applications */
 	int applications_cnt;	/**< size of list of supporter applications*/
-	
+
 	gen_lock_t *lock;		/**< lock for operations with this peer */
-	
+
 	peer_state_t state;		/**< state of the peer */
 	int I_sock;				/**< socket used as initiator */
 	int R_sock;				/**< socket used as receiver */
-	
+
 	time_t activity;		/**< timestamp of last activity */
 	time_t last_selected;	/**< timestamp this peer was last selected for routing - used in least recently used load balancing across metric */
 	int is_dynamic;			/**< whether this peer was accepted although it was not initially configured */
 	int disabled;			/**< administratively enable/disable a peer - ie remove/re-add from service dynamically */
 	int waitingDWA;			/**< if a Diameter Watch-dog Request was sent out and waiting for an answer */
-	
+
 	str send_pipe_name;		/**< pipe to signal messages to be sent out*/
-	
+
 	int fd_exchange_pipe_local;	/**< pipe to communicate with the receiver process and exchange a file descriptor - local end, to read from */
 	int fd_exchange_pipe;	/**< pipe to communicate with the receiver process and exchange a file descriptor */
 
 	AAAMessage *r_cer;      /**< the cer received from R-connection */
-	
+
 	struct _peer_t *next;	/**< next peer in the peer list */
 	struct _peer_t *prev;	/**< previous peer in the peer list */
 } peer;
@@ -131,6 +129,6 @@ typedef struct _peer_t{
 peer* new_peer(str fqdn,str realm,int port,str src_addr);
 void free_peer(peer *x,int locked);
 
-inline void touch_peer(peer *p);
+void touch_peer(peer *p);
 
 #endif

+ 16 - 18
modules/cdp/peermanager.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include <stdlib.h>
@@ -119,7 +117,7 @@ void peer_manager_destroy()
 		foo = bar;
 	}
 
-/*	lock_get(msg_id_lock);	*/
+	/*	lock_get(msg_id_lock);	*/
 	shm_free(hopbyhop_id);
 	shm_free(endtoend_id);
 	lock_destroy(msg_id_lock);
@@ -141,7 +139,7 @@ void log_peer_list()
 	peer *p;
 	int i;
 
-    LM_DBG("--- Peer List: ---\n");
+	LM_DBG("--- Peer List: ---\n");
 	for(p = peer_list->head;p;p = p->next){
 		LM_DBG(ANSI_GREEN" S["ANSI_YELLOW"%s"ANSI_GREEN"] "ANSI_BLUE"%.*s:%d"ANSI_GREEN" D["ANSI_RED"%c"ANSI_GREEN"]\n",dp_states[p->state],p->fqdn.len,p->fqdn.s,p->port,p->is_dynamic?'X':' ');
 		for(i=0;i<p->applications_cnt;i++)
@@ -291,7 +289,7 @@ int peer_timer(time_t now,void *ptr)
 						sm_process(p,Start,0,1,0);
 					}
 					break;
-				/* timeouts */
+					/* timeouts */
 				case Wait_Conn_Ack:
 				case Wait_I_CEA:
 				case Closing:
@@ -300,7 +298,7 @@ int peer_timer(time_t now,void *ptr)
 					touch_peer(p);
 					sm_process(p,Timeout,0,1,0);
 					break;
-				/* inactivity detected */
+					/* inactivity detected */
 				case I_Open:
 				case R_Open:
 					if (p->waitingDWA){
@@ -315,11 +313,11 @@ int peer_timer(time_t now,void *ptr)
 						LM_DBG("Inactivity on peer [%.*s], sending DWR... - if we don't get a reply, the peer will be closed\n", p->fqdn.len, p->fqdn.s);
 					}
 					break;
-				/* ignored states */
-				/* unknown states */
+					/* ignored states */
+					/* unknown states */
 				default:
 					LM_ERR("peer_timer(): Peer %.*s inactive  in state %d\n",
-						p->fqdn.len,p->fqdn.s,p->state);
+							p->fqdn.len,p->fqdn.s,p->state);
 			}
 		}
 		lock_release(p->lock);

+ 9 - 11
modules/cdp/peermanager.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __MANAGER_H

+ 165 - 166
modules/cdp/peerstatemachine.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,13 +35,13 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
-#include <sys/socket.h> 
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <unistd.h>
 
@@ -86,10 +84,10 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 	int result_code;
 	peer_event_t next_event;
 	int msg_received=0;
-		
+
 	if (!peer_locked) lock_get(p->lock);
 	LM_DBG("sm_process(): Peer %.*s \tState %s \tEvent %s\n",
-		p->fqdn.len,p->fqdn.s,dp_states[p->state],dp_events[event-101]);
+			p->fqdn.len,p->fqdn.s,dp_states[p->state],dp_events[event-101]);
 
 	switch (p->state){
 		case Closed:
@@ -100,9 +98,10 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 					if (next_event==I_Rcv_Conn_NAck)
 						sm_process(p,next_event,0,1,p->I_sock);
 					else{
-						/* wait for fd to be transmitted to the respective receiver, in order to get a send pipe opened */						
+						/* wait for fd to be transmitted to the respective receiver,
+						 * in order to get a send pipe opened */
 					}
-					break;	
+					break;
 				case R_Conn_CER:
 					R_Accept(p,sock);
 					result_code = Process_CER(p,msg);
@@ -122,16 +121,16 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 					break;
 				default:
 					LM_ERR("sm_process(): In state %s invalid event %s\n",
-						dp_states[p->state],dp_events[event-101]);
+							dp_states[p->state],dp_events[event-101]);
 					goto error;
 			}
-			break;		
+			break;
 		case Wait_Conn_Ack:
 			switch(event){
 				case I_Rcv_Conn_Ack:
 					I_Snd_CER(p);
 					p->state = Wait_I_CEA;
-					break;	
+					break;
 				case I_Rcv_Conn_NAck:
 					Cleanup(p,p->I_sock);
 					p->state = Closed;
@@ -156,17 +155,17 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 					p->state = Closed;
 				default:
 					LM_ERR("sm_process(): In state %s invalid event %s\n",
-						dp_states[p->state],dp_events[event-101]);
+							dp_states[p->state],dp_events[event-101]);
 					goto error;
 			}
 			break;
-			
+
 		case Wait_I_CEA:
 			switch(event){
 				case I_Rcv_CEA:
 					result_code = Process_CEA(p,msg);
 					if (result_code>=2000 && result_code<3000)
-						p->state = I_Open; 												
+						p->state = I_Open;
 					else {
 						Cleanup(p,p->I_sock);
 						p->state = Closed;
@@ -196,7 +195,7 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 						I_Disc(p);
 						p->state=Closed;
 						break;
-					}					
+					}
 					break;
 				case I_Peer_Disc:
 					I_Disc(p);
@@ -212,11 +211,11 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 					break;
 				default:
 					LM_ERR("sm_process(): In state %s invalid event %s\n",
-						dp_states[p->state],dp_events[event-101]);
+							dp_states[p->state],dp_events[event-101]);
 					goto error;
 			}
-			break;	
-			
+			break;
+
 		case Wait_Conn_Ack_Elect:
 			switch(event){
 				case I_Rcv_Conn_Ack:
@@ -249,7 +248,7 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 						else {
 							R_Disc(p);
 							p->state = Closed;
-						//	p->state = R_Open; /* Or maybe I should disconnect it?*/
+							//	p->state = R_Open; /* Or maybe I should disconnect it?*/
 						}
 					}else{
 						LM_ERR("sm_process():Wait_Conn_Ack_Elect, I_Rcv_Conn_NAck No R-CER ! \n");
@@ -271,11 +270,11 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 					break;
 				default:
 					LM_ERR("sm_process(): In state %s invalid event %s\n",
-						dp_states[p->state],dp_events[event-101]);
+							dp_states[p->state],dp_events[event-101]);
 					goto error;
 			}
 			break;
-			
+
 		case Wait_Returns:
 			switch(event){
 				case Win_Election:
@@ -304,7 +303,7 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 							p->state = Closed;
 						}
 					}else {
-						LM_ERR("sm_process():Wait_Returns, I_Peer_Disc No R-CER ! \n");						
+						LM_ERR("sm_process():Wait_Returns, I_Peer_Disc No R-CER ! \n");
 					}
 					break;
 				case I_Rcv_CEA:
@@ -313,7 +312,7 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 					R_Disc(p);
 					result_code = Process_CEA(p,msg);
 					if (result_code>=2000 && result_code<3000)
-						p->state = I_Open; 
+						p->state = I_Open;
 					else {
 						Cleanup(p,p->I_sock);
 						p->state = Closed;
@@ -334,7 +333,7 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 					p->state = Closed;
 				default:
 					LM_ERR("sm_process(): In state %s invalid event %s\n",
-						dp_states[p->state],dp_events[event-101]);
+							dp_states[p->state],dp_events[event-101]);
 					goto error;
 			}
 			break;
@@ -401,10 +400,10 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 					break;
 				default:
 					LM_ERR("sm_process(): In state %s invalid event %s\n",
-						dp_states[p->state],dp_events[event-101]);
+							dp_states[p->state],dp_events[event-101]);
 					goto error;
 			}
-			break;			
+			break;
 		case I_Open:
 			switch (event){
 				case Send_Message:
@@ -419,7 +418,7 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 					break;
 				case I_Rcv_DWR:
 					result_code = Process_DWR(p,msg);
-					Snd_DWA(p,msg,result_code,p->I_sock);						
+					Snd_DWA(p,msg,result_code,p->I_sock);
 					p->state =I_Open;
 					break;
 				case I_Rcv_DWA:
@@ -467,10 +466,10 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 					break;
 				default:
 					LM_ERR("sm_process(): In state %s invalid event %s\n",
-						dp_states[p->state],dp_events[event-101]);
+							dp_states[p->state],dp_events[event-101]);
 					goto error;
 			}
-			break;				
+			break;
 		case Closing:
 			switch(event){
 				case I_Rcv_DPA:
@@ -496,20 +495,20 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
 					break;
 				default:
 					LM_ERR("sm_process(): In state %s invalid event %s\n",
-						dp_states[p->state],dp_events[event-101]);
+							dp_states[p->state],dp_events[event-101]);
 					goto error;
 			}
-			break;				
+			break;
 	}
 	if (!peer_locked) lock_release(p->lock);
-	
+
 	if (msg_received)
 		Rcv_Process(p,msg);
-	
-	return 1;	
+
+	return 1;
 error:
 	if (!peer_locked) lock_release(p->lock);
-	return 0;	
+	return 0;
 }
 
 /**
@@ -523,7 +522,7 @@ error:
 peer_state_t I_Snd_Conn_Req(peer *p)
 {
 	LM_INFO("I_Snd_Conn_Req(): Peer %.*s \n",
-		p->fqdn.len,p->fqdn.s);
+			p->fqdn.len,p->fqdn.s);
 
 	if (p->I_sock>0) close(p->I_sock);
 	p->I_sock = -1;
@@ -531,7 +530,7 @@ peer_state_t I_Snd_Conn_Req(peer *p)
 	if (p->I_sock<0){
 		return I_Rcv_Conn_NAck;
 	}
-	
+
 	return I_Rcv_Conn_Ack;
 }
 
@@ -575,37 +574,37 @@ static inline void Snd_CE_add_applications(AAAMessage *msg,peer *p)
 	AAA_AVP_LIST list;
 	str group;
 	list.head=0;list.tail=0;
-	
+
 	for(i=0;i<config->applications_cnt;i++){
 		app = config->applications+i;
 		if (app->vendor==0){
 			set_4bytes(x,app->id);
 			AAACreateAndAddAVPToMessage(msg,
-				(app->type==DP_AUTHORIZATION?AVP_Auth_Application_Id:AVP_Acct_Application_Id),
-				AAA_AVP_FLAG_MANDATORY,0,x,4);
+					(app->type==DP_AUTHORIZATION?AVP_Auth_Application_Id:AVP_Acct_Application_Id),
+					AAA_AVP_FLAG_MANDATORY,0,x,4);
 		}else{
 			set_4bytes(x,app->vendor);
-			avp1 = AAACreateAVP(AVP_Vendor_Id,AAA_AVP_FLAG_MANDATORY,0,x,4, AVP_DUPLICATE_DATA);			
+			avp1 = AAACreateAVP(AVP_Vendor_Id,AAA_AVP_FLAG_MANDATORY,0,x,4, AVP_DUPLICATE_DATA);
 			AAAAddAVPToList(&list,avp1);
-			
+
 			set_4bytes(x,app->id);
 			avp2 = AAACreateAVP((app->type==DP_AUTHORIZATION?AVP_Auth_Application_Id:AVP_Acct_Application_Id),
-				AAA_AVP_FLAG_MANDATORY,0,x,4,AVP_DUPLICATE_DATA);			
+					AAA_AVP_FLAG_MANDATORY,0,x,4,AVP_DUPLICATE_DATA);
 			AAAAddAVPToList(&list,avp2);
-		
-			group = AAAGroupAVPS(list);	
+
+			group = AAAGroupAVPS(list);
 			AAAFreeAVPList(&list);
-			
+
 			AAACreateAndAddAVPToMessage(msg,
-				AVP_Vendor_Specific_Application_Id,
-				AAA_AVP_FLAG_MANDATORY,0,group.s,group.len);
+					AVP_Vendor_Specific_Application_Id,
+					AAA_AVP_FLAG_MANDATORY,0,group.s,group.len);
 			shm_free(group.s);
 		}
 	}
 	for(i=0;i<config->supported_vendors_cnt;i++){
 		set_4bytes(x,config->supported_vendors[i]);
-		AAACreateAndAddAVPToMessage(msg,AVP_Supported_Vendor_Id,AAA_AVP_FLAG_MANDATORY,0,x,4);					
-	}		
+		AAACreateAndAddAVPToMessage(msg,AVP_Supported_Vendor_Id,AAA_AVP_FLAG_MANDATORY,0,x,4);
+	}
 }
 
 /**
@@ -616,7 +615,7 @@ static inline void Snd_CE_add_applications(AAAMessage *msg,peer *p)
 void I_Snd_CER(peer *p)
 {
 	AAAMessage *cer=0;
-//	AAA_AVP *avp;
+	//	AAA_AVP *avp;
 	unsigned long ip;
 	union {
 		struct sockaddr addr;
@@ -625,13 +624,13 @@ void I_Snd_CER(peer *p)
 	} addr_u ;
 	socklen_t addrlen;
 	char x[18];
-	
+
 	cer = AAANewMessage(Code_CE,0,0,0);
 	if (!cer) return;
 	cer->hopbyhopId = next_hopbyhop();
 	cer->endtoendId = next_endtoend();
 	addrlen = sizeof(addr_u);
-	if (getsockname(p->I_sock,&(addr_u.addr), &addrlen) == -1) { 
+	if (getsockname(p->I_sock,&(addr_u.addr), &addrlen) == -1) {
 		LM_ERR("I_Snd_CER(): Error on finding local host address > %s\n",strerror(errno));
 	}else{
 		switch(addr_u.addr.sa_family){
@@ -653,11 +652,11 @@ void I_Snd_CER(peer *p)
 
 	set_4bytes(x,config->vendor_id);
 	AAACreateAndAddAVPToMessage(cer,AVP_Vendor_Id,AAA_AVP_FLAG_MANDATORY,0,x,4);
-			
+
 	AAACreateAndAddAVPToMessage(cer,AVP_Product_Name,AAA_AVP_FLAG_MANDATORY,0,config->product_name.s,config->product_name.len);
 
 	Snd_CE_add_applications(cer,p);
-//	peer_send(p,p->I_sock,cer,1);
+	//	peer_send(p,p->I_sock,cer,1);
 	peer_send_msg(p,cer);
 }
 
@@ -668,20 +667,20 @@ void add_peer_application(peer *p, int id, int vendor, app_type type)
 	if (!p->applications) return;
 	for(i=0;i<p->applications_cnt;i++)
 		if (p->applications[i].id == id &&
-			p->applications[i].vendor == vendor &&
-			p->applications[i].type == type) return;
+				p->applications[i].vendor == vendor &&
+				p->applications[i].type == type) return;
 
 	p->applications[p->applications_cnt].id = id;
 	p->applications[p->applications_cnt].vendor = vendor;
 	p->applications[p->applications_cnt].type = type;
-	p->applications_cnt++;	 
+	p->applications_cnt++;
 }
 
 int count_Supported_Vendor_Id_AVPS(AAAMessage *msg)
 {
 	AAA_AVP* avp_vendor;
 	int avp_vendor_cnt;
-	
+
 	avp_vendor = AAAFindMatchingAVP(msg,0,AVP_Supported_Vendor_Id,0,0);
 	avp_vendor_cnt = 0;
 	while (avp_vendor) {
@@ -707,9 +706,9 @@ void save_peer_applications(peer *p,AAAMessage *msg)
 		p->applications = 0;
 		p->applications_cnt = 0;
 	}
-	
+
 	supported_vendor_id_avp_cnt = count_Supported_Vendor_Id_AVPS(msg);
-	
+
 	for(avp=msg->avpList.head;avp;avp = avp->next)
 
 		switch (avp->code){
@@ -719,38 +718,38 @@ void save_peer_applications(peer *p,AAAMessage *msg)
 			case AVP_Acct_Application_Id:
 				total_cnt += supported_vendor_id_avp_cnt;
 				break;
-			case AVP_Vendor_Specific_Application_Id:				
-				total_cnt+=2;/* wasteful, but let's skip decoding */	
-				break;				
+			case AVP_Vendor_Specific_Application_Id:
+				total_cnt+=2;/* wasteful, but let's skip decoding */
+				break;
 		}
 	p->applications_cnt = 0;
 	p->applications = shm_malloc(sizeof(app_config)*total_cnt);
-	if (!p->applications){	
+	if (!p->applications){
 		LM_ERR("save_peer_applications(): Error allocating %ld bytes! No applications saved...\n",
-			(long int)(sizeof(app_config)*total_cnt));
+				(long int)(sizeof(app_config)*total_cnt));
 		return;
 	}
 	for(avp=msg->avpList.head;avp;avp = avp->next)
 	{
-		
+
 		switch (avp->code){
 			case AVP_Auth_Application_Id:
 				id = get_4bytes(avp->data.s);
 				add_peer_application(p,id,0,DP_AUTHORIZATION);
 				avp_vendor = AAAFindMatchingAVP(msg,0,AVP_Supported_Vendor_Id,0,0);
 				while (avp_vendor) {
-					
+
 					vendor = get_4bytes(avp_vendor->data.s);
 					LM_DBG("Found Supported Vendor for Application %i: %i\n", DP_AUTHORIZATION, vendor);
 					add_peer_application(p,id,vendor,DP_AUTHORIZATION);
 					if (!avp_vendor->next)
 						break;
 					avp_vendor = AAAFindMatchingAVP(msg,avp_vendor->next,AVP_Supported_Vendor_Id,0,AAA_FORWARD_SEARCH);
-				} 
+				}
 				break;
 			case AVP_Acct_Application_Id:
-				id = get_4bytes(avp->data.s);	
-				add_peer_application(p,id,0,DP_ACCOUNTING);	
+				id = get_4bytes(avp->data.s);
+				add_peer_application(p,id,0,DP_ACCOUNTING);
 				avp_vendor = AAAFindMatchingAVP(msg,0,AVP_Supported_Vendor_Id,0,0);
 				while (avp_vendor) {
 					vendor = get_4bytes(avp_vendor->data.s);
@@ -759,28 +758,28 @@ void save_peer_applications(peer *p,AAAMessage *msg)
 					if (!avp_vendor->next)
 						break;
 					avp_vendor = AAAFindMatchingAVP(msg,avp_vendor->next,AVP_Supported_Vendor_Id,0,AAA_FORWARD_SEARCH);
-				} 
+				}
 				break;
 			case AVP_Vendor_Specific_Application_Id:
 				group = AAAUngroupAVPS(avp->data);
-				avp_vendor = AAAFindMatchingAVPList(group,group.head,AVP_Vendor_Id,0,0);				
-				avp2 = AAAFindMatchingAVPList(group,group.head,AVP_Auth_Application_Id,0,AAA_FORWARD_SEARCH);				
+				avp_vendor = AAAFindMatchingAVPList(group,group.head,AVP_Vendor_Id,0,0);
+				avp2 = AAAFindMatchingAVPList(group,group.head,AVP_Auth_Application_Id,0,AAA_FORWARD_SEARCH);
 				if (avp_vendor&&avp2){
 					vendor = get_4bytes(avp_vendor->data.s);
 					id = get_4bytes(avp2->data.s);
-					add_peer_application(p,id,vendor,DP_AUTHORIZATION);						
+					add_peer_application(p,id,vendor,DP_AUTHORIZATION);
 				}
-				avp2 = AAAFindMatchingAVPList(group,group.head,AVP_Acct_Application_Id,0,AAA_FORWARD_SEARCH);				
+				avp2 = AAAFindMatchingAVPList(group,group.head,AVP_Acct_Application_Id,0,AAA_FORWARD_SEARCH);
 				if (avp_vendor&&avp2){
 					vendor = get_4bytes(avp_vendor->data.s);
 					id = get_4bytes(avp2->data.s);
-					add_peer_application(p,id,vendor,DP_ACCOUNTING);					
+					add_peer_application(p,id,vendor,DP_ACCOUNTING);
 				}
 				AAAFreeAVPList(&group);
 				break;
-				
+
 		}
-	}	
+	}
 }
 
 /**
@@ -789,7 +788,7 @@ void save_peer_applications(peer *p,AAAMessage *msg)
  * @param p - the peer that the CEA was received from
  * @param cea - the CEA message
  * @returns the result-code from CEA or AAA_UNABLE_TO_COMPLY if no result-code found
- */	
+ */
 int Process_CEA(peer *p,AAAMessage *cea)
 {
 	AAA_AVP *avp;
@@ -798,7 +797,7 @@ int Process_CEA(peer *p,AAAMessage *cea)
 	AAAFreeMessage(&cea);
 	if (!avp) return AAA_UNABLE_TO_COMPLY;
 	else return get_4bytes(avp->data.s);
-}	
+}
 
 /**
  * Initiator - disconnect peer.
@@ -833,7 +832,7 @@ void R_Disc(peer *p)
  * @param p - the peer that the DWR was received from
  * @param dwr - the DWR message
  * @returns AAA_SUCCESS
- */	
+ */
 int Process_DWR(peer *p,AAAMessage *dwr)
 {
 	return AAA_SUCCESS;
@@ -845,7 +844,7 @@ int Process_DWR(peer *p,AAAMessage *dwr)
  * \note Must be called with a lock on the peer.
  * @param p - the peer that the DWR was received from
  * @param dwa - the DWA message
- */	
+ */
 void Process_DWA(peer *p,AAAMessage *dwa)
 {
 	p->waitingDWA = 0;
@@ -857,19 +856,19 @@ void Process_DWA(peer *p,AAAMessage *dwa)
  * The flag for waiting a DWA is set.
  * \note Must be called with a lock on the peer.
  * @param p - the peer that the DWR was received from
- */	
+ */
 void Snd_DWR(peer *p)
 {
 	AAAMessage *dwr=0;
-	
+
 	dwr = AAANewMessage(Code_DW,0,0,0);
-	if (!dwr) return;	
+	if (!dwr) return;
 	dwr->hopbyhopId = next_hopbyhop();
 	dwr->endtoendId = next_endtoend();
 	if (p->state==I_Open)
-		peer_send_msg(p,dwr);	
+		peer_send_msg(p,dwr);
 	else
-		peer_send_msg(p,dwr);	
+		peer_send_msg(p,dwr);
 }
 
 /**
@@ -879,20 +878,20 @@ void Snd_DWR(peer *p)
  * @param dwr - the DWR message
  * @param result_code - the Result-Code to attach to DWA
  * @param sock - socket to send on
- */	
+ */
 void Snd_DWA(peer *p,AAAMessage *dwr,int result_code,int sock)
 {
 	AAAMessage *dwa;
-	char x[4];	
+	char x[4];
 
 	dwa = AAANewMessage(Code_DW,0,0,dwr);
-	if (!dwa) goto done;	
+	if (!dwa) goto done;
 
 	set_4bytes(x,result_code);
 	AAACreateAndAddAVPToMessage(dwa,AVP_Result_Code,AAA_AVP_FLAG_MANDATORY,0,x,4);
-	
+
 	peer_send_msg(p,dwa);
-done:	
+done:
 	AAAFreeMessage(&dwr);
 }
 
@@ -905,8 +904,8 @@ void Snd_DPR(peer *p)
 {
 	AAAMessage *dpr=0;
 	char x[4];
-	
-	dpr = AAANewMessage(Code_DP,0,0,0);	
+
+	dpr = AAANewMessage(Code_DP,0,0,0);
 	if (!dpr) return;
 	dpr->hopbyhopId = next_hopbyhop();
 	dpr->endtoendId = next_endtoend();
@@ -915,9 +914,9 @@ void Snd_DPR(peer *p)
 	AAACreateAndAddAVPToMessage(dpr,AVP_Disconnect_Cause,AAA_AVP_FLAG_MANDATORY,0,x,4);
 
 	if (p->state==I_Open)
-		peer_send_msg(p,dpr);	
+		peer_send_msg(p,dpr);
 	else
-		peer_send_msg(p,dpr);	
+		peer_send_msg(p,dpr);
 }
 
 /**
@@ -932,7 +931,7 @@ void Snd_DPA(peer *p,AAAMessage *dpr,int result_code,int sock)
 {
 	AAAMessage *dpa;
 
-	dpa = AAANewMessage(Code_DP,0,0,dpr);	
+	dpa = AAANewMessage(Code_DP,0,0,dpr);
 	if (dpa) peer_send_msg(p,dpa);
 	AAAFreeMessage(&dpr);
 }
@@ -978,53 +977,53 @@ int Process_CER(peer *p,AAAMessage *cer)
 	{
 		switch (avp->code){
 			case AVP_Auth_Application_Id:
-				id = get_4bytes(avp->data.s);	
+				id = get_4bytes(avp->data.s);
 				for(i=0;i<config->applications_cnt;i++)
 					if (id == config->applications[i].id &&
-						config->applications[i].vendor==0 &&
-						config->applications[i].type==DP_AUTHORIZATION) common_app++;	
+							config->applications[i].vendor==0 &&
+							config->applications[i].type==DP_AUTHORIZATION) common_app++;
 				break;
 			case AVP_Acct_Application_Id:
-				id = get_4bytes(avp->data.s);	
+				id = get_4bytes(avp->data.s);
 				for(i=0;i<config->applications_cnt;i++)
 					if (id == config->applications[i].id &&
-						config->applications[i].vendor==0 &&
-						config->applications[i].type==DP_ACCOUNTING) common_app++;	
+							config->applications[i].vendor==0 &&
+							config->applications[i].type==DP_ACCOUNTING) common_app++;
 				break;
 			case AVP_Vendor_Specific_Application_Id:
 				group = AAAUngroupAVPS(avp->data);
-				avp_vendor = AAAFindMatchingAVPList(group,group.head,AVP_Vendor_Id,0,0);				
-				avp2 = AAAFindMatchingAVPList(group,group.head,AVP_Auth_Application_Id,0,0);				
+				avp_vendor = AAAFindMatchingAVPList(group,group.head,AVP_Vendor_Id,0,0);
+				avp2 = AAAFindMatchingAVPList(group,group.head,AVP_Auth_Application_Id,0,0);
 				if (avp_vendor&&avp2){
 					vendor = get_4bytes(avp_vendor->data.s);
 					id = get_4bytes(avp2->data.s);
 					for(i=0;i<config->applications_cnt;i++)
 						if (id == config->applications[i].id &&
-							config->applications[i].vendor==vendor &&
-							config->applications[i].type==DP_AUTHORIZATION) common_app++;	
-					
+								config->applications[i].vendor==vendor &&
+								config->applications[i].type==DP_AUTHORIZATION) common_app++;
+
 				}
-				avp2 = AAAFindMatchingAVPList(group,group.head,AVP_Acct_Application_Id,0,0);				
+				avp2 = AAAFindMatchingAVPList(group,group.head,AVP_Acct_Application_Id,0,0);
 				if (avp_vendor&&avp2){
 					vendor = get_4bytes(avp_vendor->data.s);
 					id = get_4bytes(avp2->data.s);
 					for(i=0;i<config->applications_cnt;i++)
 						if (id == config->applications[i].id &&
-							config->applications[i].vendor==vendor &&
-							config->applications[i].type==DP_ACCOUNTING) common_app++;	
-					
+								config->applications[i].vendor==vendor &&
+								config->applications[i].type==DP_ACCOUNTING) common_app++;
+
 				}
 				AAAFreeAVPList(&group);
 				break;
-				
+
 		}
 	}
-	
+
 	if (common_app!=0){
 		save_peer_applications(p,cer);
 		return AAA_SUCCESS;
-	}else 
-		return AAA_NO_COMMON_APPLICATION;	
+	}else
+		return AAA_NO_COMMON_APPLICATION;
 }
 
 /**
@@ -1047,12 +1046,12 @@ void Snd_CEA(peer *p,AAAMessage *cer,int result_code,int sock)
 	} addr_u ;
 	socklen_t addrlen;
 	char x[18];
-	
-	cea = AAANewMessage(Code_CE,0,0,cer);	
+
+	cea = AAANewMessage(Code_CE,0,0,cer);
 	if (!cea) goto done;
-	
+
 	addrlen = sizeof(addr_u);
-	if (getsockname(sock, &(addr_u.addr), &addrlen) == -1) { 
+	if (getsockname(sock, &(addr_u.addr), &addrlen) == -1) {
 		LM_ERR("Snd_CEA(): Error on finding local host address > %s\n",strerror(errno));
 	}else{
 		switch(addr_u.addr.sa_family){
@@ -1074,7 +1073,7 @@ void Snd_CEA(peer *p,AAAMessage *cer,int result_code,int sock)
 
 	set_4bytes(x,config->vendor_id);
 	AAACreateAndAddAVPToMessage(cea,AVP_Vendor_Id,AAA_AVP_FLAG_MANDATORY,0,x,4);
-			
+
 	AAACreateAndAddAVPToMessage(cea,AVP_Product_Name,AAA_AVP_FLAG_MANDATORY,0,config->product_name.s,config->product_name.len);
 
 	set_4bytes(x,result_code);
@@ -1083,7 +1082,7 @@ void Snd_CEA(peer *p,AAAMessage *cer,int result_code,int sock)
 	Snd_CE_add_applications(cea,p);
 
 	peer_send(p,sock,cea,1);
-done:	
+done:
 	AAAFreeMessage(&cer);
 }
 
@@ -1097,7 +1096,7 @@ done:
  * @param p - peer identification
  * @param cer - the CER message
  * @returns 1 if winning, 0 if loosing
- */  
+ */
 int Elect(peer *p,AAAMessage *cer)
 {
 	/* returns if we win the election */
@@ -1110,7 +1109,7 @@ int Elect(peer *p,AAAMessage *cer)
 		// return lose
 		return 0;
 	}
-	
+
 	local = config->fqdn;
 
 	avp = AAAFindMatchingAVP(cer,cer->avpList.head,AVP_Origin_Host,0,0);
@@ -1140,9 +1139,9 @@ void Snd_Message(peer *p, AAAMessage *msg)
 	int rcode;
 	int send_message_before_session_sm=0;
 	LM_DBG("Snd_Message called to peer [%.*s] for %s with code %d \n",
-		p->fqdn.len,p->fqdn.s,is_req(msg)?"request":"response",msg->commandCode);
+			p->fqdn.len,p->fqdn.s,is_req(msg)?"request":"response",msg->commandCode);
 	if (msg->sessionId) session = cdp_get_session(msg->sessionId->data);
-	
+
 	if (session){
 		LM_DBG("There is a session of type %d\n",session->type);
 		switch (session->type){
@@ -1182,7 +1181,7 @@ void Snd_Message(peer *p, AAAMessage *msg)
 								session = 0;
 							}
 						}
-						
+
 					}else {
 						auth_client_statefull_sm_process(session,AUTH_EV_SEND_ANS,msg);
 						session = 0;
@@ -1216,14 +1215,14 @@ void Snd_Message(peer *p, AAAMessage *msg)
 						session = 0;
 					}
 				}
-				break;				 
+				break;
 			default:
 				break;
 		}
 		if (session) AAASessionsUnlock(session->hash);
 	}
 	if (!send_message_before_session_sm) peer_send_msg(p,msg);
-	
+
 }
 
 /**
@@ -1233,7 +1232,7 @@ void Snd_Message(peer *p, AAAMessage *msg)
  * \note Must be called with a lock on the peer.
  * @param p - peer received from
  * @param msg - the message received
- */ 
+ */
 void Rcv_Process(peer *p, AAAMessage *msg)
 {
 	AAASession *session=0;
@@ -1256,7 +1255,7 @@ void Rcv_Process(peer *p, AAAMessage *msg)
 				if (is_req(msg)){
 					if (msg->commandCode==IMS_ASR)
 						auth_client_statefull_sm_process(session,AUTH_EV_RECV_ASR,msg);
-					else 
+					else
 						auth_client_statefull_sm_process(session,AUTH_EV_RECV_REQ,msg);
 					session = 0;
 				}else {
@@ -1267,44 +1266,44 @@ void Rcv_Process(peer *p, AAAMessage *msg)
 					session = 0;
 				}
 				break;
-			 case AUTH_SERVER_STATEFULL:
-			 	if (is_req(msg))
-			 	{
-			 		if (msg->commandCode==IMS_STR)
-			 		{
-			 			auth_server_statefull_sm_process(session,AUTH_EV_RECV_STR,msg);
-			 		} else {
-			 			auth_server_statefull_sm_process(session,AUTH_EV_RECV_REQ,msg);
-			 		}
-					session = 0;			 		
-			 	}else{
-			 		if (msg->commandCode==IMS_ASA)
-			 			auth_server_statefull_sm_process(session,AUTH_EV_RECV_ASA,msg);
-			 		else
-			 			auth_server_statefull_sm_process(session,AUTH_EV_RECV_ANS,msg);
-					session = 0;			 		
-			 	}
-			 	break;
+			case AUTH_SERVER_STATEFULL:
+				if (is_req(msg))
+				{
+					if (msg->commandCode==IMS_STR)
+					{
+						auth_server_statefull_sm_process(session,AUTH_EV_RECV_STR,msg);
+					} else {
+						auth_server_statefull_sm_process(session,AUTH_EV_RECV_REQ,msg);
+					}
+					session = 0;
+				}else{
+					if (msg->commandCode==IMS_ASA)
+						auth_server_statefull_sm_process(session,AUTH_EV_RECV_ASA,msg);
+					else
+						auth_server_statefull_sm_process(session,AUTH_EV_RECV_ANS,msg);
+					session = 0;
+				}
+				break;
 			default:
 				AAASessionsUnlock(session->hash);
 				session =0;
-				break;			 
+				break;
 		}
 	}else{
 		if (msg->sessionId){
-			if (msg->commandCode == IMS_ASR) 
+			if (msg->commandCode == IMS_ASR)
 				auth_client_statefull_sm_process(0,AUTH_EV_RECV_ASR,msg);
-		} 
-				 
+		}
+
 	}
 	if (!nput && !put_task(p,msg)){
 		LM_ERR("Rcv_Process(): Queue refused task\n");
-		if (msg) AAAFreeMessage(&msg); 
+		if (msg) AAAFreeMessage(&msg);
 	}
 	//if (msg) LM_ERR("Rcv_Process(): task added to queue command %d, flags %#1x endtoend %u hopbyhop %u\n",msg->commandCode,msg->flags,msg->endtoendId,msg->hopbyhopId);
-	
-//	AAAPrintMessage(msg);
-	
+
+	//	AAAPrintMessage(msg);
+
 }
 
 

+ 9 - 11
modules/cdp/peerstatemachine.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __STATEMACHINE_H

+ 72 - 75
modules/cdp/receiver.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include <unistd.h>
@@ -102,8 +100,7 @@ static void log_serviced_peers()
 	serviced_peer_t *sp;
 
 	LM_DBG("--- Receiver ["ANSI_BLUE"%s"ANSI_GREEN"] Serviced Peers: ---\n",
-			pt[process_no].desc
-			);
+			pt[process_no].desc);
 	for(sp=serviced_peers;sp;sp=sp->next){
 		LM_DBG(ANSI_GREEN" Peer: ["ANSI_YELLOW"%.*s"ANSI_GREEN"]  TCP Socket: ["ANSI_YELLOW"%d"ANSI_GREEN"] Recv.State: ["ANSI_YELLOW"%d"ANSI_GREEN"]\n",
 				sp->p?sp->p->fqdn.len:0,
@@ -219,10 +216,10 @@ static void disconnect_serviced_peer(serviced_peer_t *sp,int locked)
 			sp->p?sp->p->fqdn.s:0);
 	if (sp->p){
 		if (!locked) lock_get(sp->p->lock);
-			if (sp->p->I_sock == sp->tcp_socket) sm_process(sp->p,I_Peer_Disc,0,1,sp->tcp_socket);
-			if (sp->p->R_sock == sp->tcp_socket) sm_process(sp->p,R_Peer_Disc,0,1,sp->tcp_socket);
-			sp->p->send_pipe_name.s = 0;
-			sp->p->send_pipe_name.len = 0;
+		if (sp->p->I_sock == sp->tcp_socket) sm_process(sp->p,I_Peer_Disc,0,1,sp->tcp_socket);
+		if (sp->p->R_sock == sp->tcp_socket) sm_process(sp->p,R_Peer_Disc,0,1,sp->tcp_socket);
+		sp->p->send_pipe_name.s = 0;
+		sp->p->send_pipe_name.len = 0;
 		if (!locked) lock_release(sp->p->lock);
 	}
 	sp->tcp_socket = -1;
@@ -368,7 +365,7 @@ again:
 	}
 	if (ret!=sizeof(peer *)){
 		LM_WARN("receive_fd: different number of bytes received than expected (%d from %ld)"
-				    "trying to fix...\n", ret, (long int)sizeof(peer*));
+				"trying to fix...\n", ret, (long int)sizeof(peer*));
 		goto error;
 	}
 
@@ -389,7 +386,7 @@ again:
 			LM_ERR("receive_fd: no descriptor passed, empty control message");
 		else
 			LM_ERR("receive_fd: no descriptor passed, cmsg=%p,"
-				"len=%d\n", cmsg, (unsigned)cmsg->cmsg_len);
+					"len=%d\n", cmsg, (unsigned)cmsg->cmsg_len);
 		*fd=-1;
 		*p=0;
 		/* it's not really an error */
@@ -419,7 +416,7 @@ int receiver_init(peer *p)
 	int fd_exchange_pipe[2];/**< pipe to pass file descriptors towards this process */
 
 	if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd_exchange_pipe)<0){
-		 LM_ERR("receiver_init(): socketpair(fd_exchanged_pipe) failed > %s\n",strerror(errno));
+		LM_ERR("receiver_init(): socketpair(fd_exchanged_pipe) failed > %s\n",strerror(errno));
 		return 0;
 	}
 	if (p) {
@@ -453,7 +450,7 @@ void receiver_process(peer *p)
 
 	if (receive_loop(p)<0){
 		LM_INFO("receiver_process(): [%.*s] receive_loop() return -1 (error)!\n",
-						p?p->fqdn.len:0,p?p->fqdn.s:0);
+				p?p->fqdn.len:0,p?p->fqdn.s:0);
 
 	}
 
@@ -477,14 +474,14 @@ done:
 
 #else
 #ifdef PKG_MALLOC
-	#ifdef PKG_MALLOC
-		LM_DBG("Receiver[%.*s] Memory status (pkg):\n",
-				p?p->fqdn.len:0,p?p->fqdn.s:0);
-		//pkg_status();
-		#ifdef pkg_sums
-			pkg_sums();
-		#endif
-	#endif
+#ifdef PKG_MALLOC
+	LM_DBG("Receiver[%.*s] Memory status (pkg):\n",
+			p?p->fqdn.len:0,p?p->fqdn.s:0);
+	//pkg_status();
+#ifdef pkg_sums
+	pkg_sums();
+#endif
+#endif
 #endif
 #endif
 
@@ -540,10 +537,10 @@ static inline int do_receive(serviced_peer_t *sp)
 		case Receiver_Waiting:
 			version = (unsigned char)(sp->buf[0]);
 			if (version!=1) {
-		  		LM_ERR("do_receive(): [%.*s] Received Unknown version [%d]\n",
-		  				sp->p->fqdn.len,
-		  				sp->p->fqdn.s,
-		  				(unsigned char)sp->buf[0]);
+				LM_ERR("do_receive(): [%.*s] Received Unknown version [%d]\n",
+						sp->p->fqdn.len,
+						sp->p->fqdn.s,
+						(unsigned char)sp->buf[0]);
 				goto error_and_reset;
 			}else{
 				sp->state = Receiver_Header;
@@ -582,7 +579,7 @@ static inline int do_receive(serviced_peer_t *sp)
 		case Receiver_Rest_of_Message:
 			sp->msg_len+=cnt;
 			if (sp->msg_len==sp->length){
-		    	dmsg = AAATranslateMessage((unsigned char*)sp->msg,(unsigned int)sp->msg_len,1);
+				dmsg = AAATranslateMessage((unsigned char*)sp->msg,(unsigned int)sp->msg_len,1);
 				if (dmsg) {
 					sp->msg = 0;
 					receive_message(dmsg,sp);
@@ -638,7 +635,7 @@ int receive_loop(peer *original_peer)
 	if (original_peer) fd_exchange_pipe_local = original_peer->fd_exchange_pipe_local;
 	else fd_exchange_pipe_local = fd_exchange_pipe_unknown_local;
 
-//	if (shutdownx) return -1;
+	//	if (shutdownx) return -1;
 
 	while(shutdownx&&!*shutdownx){
 		n = 0;
@@ -788,7 +785,7 @@ int receive_loop(peer *original_peer)
 							AAAFreeMessage(&msg);
 							//don't return, maybe there is something to read
 						}
-	receive:
+receive:
 						/* receive */
 						if (sp->tcp_socket>=0 && FD_ISSET(sp->tcp_socket,&rfds)) {
 							errno=0;
@@ -804,11 +801,11 @@ int receive_loop(peer *original_peer)
 							}
 						}
 
-	//next_sp:
+						//next_sp:
 						/* go to next serviced peer */
 						sp=sp->next;
 						continue;
-	drop_peer:
+drop_peer:
 						/* drop this serviced peer on error */
 						sp2 = sp->next;
 						disconnect_serviced_peer(sp,0);
@@ -842,8 +839,8 @@ int peer_connect(peer *p)
 
 	memset (&hints, 0, sizeof(hints));
 	//hints.ai_protocol = IPPROTO_SCTP;
- 	//hints.ai_protocol = IPPROTO_TCP;
- 	hints.ai_flags = AI_ADDRCONFIG;
+	//hints.ai_protocol = IPPROTO_TCP;
+	hints.ai_flags = AI_ADDRCONFIG;
 	hints.ai_socktype = SOCK_STREAM;
 
 	sprintf(buf,"%d",p->port);
@@ -852,21 +849,21 @@ int peer_connect(peer *p)
 
 	if (error!=0){
 		LM_WARN("peer_connect(): Error opening connection to %.*s:%d >%s\n",
-			p->fqdn.len,p->fqdn.s,p->port,gai_strerror(error));
+				p->fqdn.len,p->fqdn.s,p->port,gai_strerror(error));
 		goto error;
 	}
 
 	for(ainfo = res;ainfo;ainfo = ainfo->ai_next)
 	{
 		if (getnameinfo(ainfo->ai_addr,ainfo->ai_addrlen,
-			host,256,serv,256,NI_NUMERICHOST|NI_NUMERICSERV)==0){
-				LM_WARN("peer_connect(): Trying to connect to %s port %s\n",
+					host,256,serv,256,NI_NUMERICHOST|NI_NUMERICSERV)==0){
+			LM_WARN("peer_connect(): Trying to connect to %s port %s\n",
 					host,serv);
 		}
 
 		if ((sock = socket(ainfo->ai_family, ainfo->ai_socktype, ainfo->ai_protocol)) == -1) {
 			LM_ERR("peer_connect(): error creating client socket to %s port %s >"
-				" %s\n",host,serv,strerror(errno));
+					" %s\n",host,serv,strerror(errno));
 			continue;
 		}
 
@@ -880,11 +877,11 @@ int peer_connect(peer *p)
 
 			if (error!=0){
 				LM_WARN("peer_connect(): error getting client socket on %.*s:%s\n",
-					p->src_addr.len,p->src_addr.s,gai_strerror(error));
+						p->src_addr.len,p->src_addr.s,gai_strerror(error));
 			} else {
 				if (bind(sock, sainfo->ai_addr, sainfo->ai_addrlen )) {
 					LM_WARN("peer_connect(): error opening client socket on %.*s:%s\n",
-						p->src_addr.len,p->src_addr.s,strerror(errno));
+							p->src_addr.len,p->src_addr.s,strerror(errno));
 				}
 			}
 		}
@@ -896,27 +893,27 @@ int peer_connect(peer *p)
 			int res = connect(sock,ainfo->ai_addr,ainfo->ai_addrlen);
 			if (res<0){
 				if (errno==EINPROGRESS){
-					  struct timeval tv={
-						  .tv_sec = config->connect_timeout,
-						  .tv_usec = 0,
-					  };
-					  fd_set myset;
-					  FD_ZERO(&myset);
-					  FD_SET(sock, &myset);
-					  if (select(sock+1, NULL, &myset, NULL, &tv) > 0) {
-						  socklen_t lon = sizeof(int);
-						  int  valopt;
-						  getsockopt(sock, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
-						  if (valopt) {
-					    	  LM_WARN("peer_connect(): Error opening connection to to %s port %s >%s\n",host,serv,strerror(valopt));
-					    	  close(sock);
-					    	  continue;
-					      }
-					  }else{
-				    	  LM_WARN("peer_connect(): Timeout or error opening connection to to %s port %s >%s\n",host,serv,strerror(errno));
-				    	  close(sock);
-				    	  continue;
-					  }
+					struct timeval tv={
+						.tv_sec = config->connect_timeout,
+						.tv_usec = 0,
+					};
+					fd_set myset;
+					FD_ZERO(&myset);
+					FD_SET(sock, &myset);
+					if (select(sock+1, NULL, &myset, NULL, &tv) > 0) {
+						socklen_t lon = sizeof(int);
+						int  valopt;
+						getsockopt(sock, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
+						if (valopt) {
+							LM_WARN("peer_connect(): Error opening connection to to %s port %s >%s\n",host,serv,strerror(valopt));
+							close(sock);
+							continue;
+						}
+					}else{
+						LM_WARN("peer_connect(): Timeout or error opening connection to to %s port %s >%s\n",host,serv,strerror(errno));
+						close(sock);
+						continue;
+					}
 				}
 			}else{
 				LM_WARN("peer_connect(): Error opening connection to to %s port %s >%s\n",host,serv,strerror(errno));
@@ -1032,7 +1029,7 @@ int peer_send(peer *p,int sock,AAAMessage *msg,int locked)
 		if (errno==EINTR)
 			continue;
 		LM_ERR("peer_send(): write returned error: %s\n",
-			strerror(errno));
+				strerror(errno));
 		if (p->I_sock==sock) sm_process(p,I_Peer_Disc,0,1,p->I_sock);
 		if (p->R_sock==sock) sm_process(p,R_Peer_Disc,0,1,p->R_sock);
 		if (!locked) lock_release(p->lock);
@@ -1093,7 +1090,7 @@ void receive_message(AAAMessage *msg,serviced_peer_t *sp)
 					}
 					if (!sp->p) {
 						LM_ERR("receive_msg(): Received CER from unknown peer (accept unknown=%d) -ignored\n",
-							config->accept_unknown_peers);
+								config->accept_unknown_peers);
 						AAAFreeMessage(&msg);
 					}else{
 						LM_DBG("receive_message(): [%.*s] This receiver has no peer associated\n",
@@ -1126,15 +1123,15 @@ void receive_message(AAAMessage *msg,serviced_peer_t *sp)
 				switch (msg->commandCode){
 					case Code_CE:
 						if (is_req(msg)) sm_process(sp->p,I_Rcv_CER,msg,0,sp->tcp_socket);
-									else sm_process(sp->p,I_Rcv_CEA,msg,0,sp->tcp_socket);
+						else sm_process(sp->p,I_Rcv_CEA,msg,0,sp->tcp_socket);
 						break;
 					case Code_DW:
 						if (is_req(msg)) sm_process(sp->p,I_Rcv_DWR,msg,0,sp->tcp_socket);
-									else sm_process(sp->p,I_Rcv_DWA,msg,0,sp->tcp_socket);
+						else sm_process(sp->p,I_Rcv_DWA,msg,0,sp->tcp_socket);
 						break;
 					case Code_DP:
 						if (is_req(msg)) sm_process(sp->p,I_Rcv_DPR,msg,0,sp->tcp_socket);
-									else sm_process(sp->p,I_Rcv_DPA,msg,0,sp->tcp_socket);
+						else sm_process(sp->p,I_Rcv_DPA,msg,0,sp->tcp_socket);
 						break;
 					default:
 						sm_process(sp->p,I_Rcv_Message,msg,0,sp->tcp_socket);
@@ -1144,15 +1141,15 @@ void receive_message(AAAMessage *msg,serviced_peer_t *sp)
 				switch (msg->commandCode){
 					case Code_CE:
 						if (is_req(msg)) sm_process(sp->p,R_Rcv_CER,msg,0,sp->tcp_socket);
-									else sm_process(sp->p,R_Rcv_CEA,msg,0,sp->tcp_socket);
+						else sm_process(sp->p,R_Rcv_CEA,msg,0,sp->tcp_socket);
 						break;
 					case Code_DW:
 						if (is_req(msg)) sm_process(sp->p,R_Rcv_DWR,msg,0,sp->tcp_socket);
-									else sm_process(sp->p,R_Rcv_DWA,msg,0,sp->tcp_socket);
+						else sm_process(sp->p,R_Rcv_DWA,msg,0,sp->tcp_socket);
 						break;
 					case Code_DP:
 						if (is_req(msg)) sm_process(sp->p,R_Rcv_DPR,msg,0,sp->tcp_socket);
-									else sm_process(sp->p,R_Rcv_DPA,msg,0,sp->tcp_socket);
+						else sm_process(sp->p,R_Rcv_DPA,msg,0,sp->tcp_socket);
 						break;
 					default:
 						sm_process(sp->p,R_Rcv_Message,msg,0,sp->tcp_socket);

+ 15 - 17
modules/cdp/receiver.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __RECEIVER_H
@@ -64,10 +62,10 @@ typedef enum {
 /** list of receiver attached peers */
 typedef struct _serviced_peer_t {
 	peer *p;									/**< the attached peer */
-	
+
 	int tcp_socket;								/**< socket used for the Diameter communication */
-	
-	str send_pipe_name;							/**< name of the pipe to signal messages to be sent out */ 
+
+	str send_pipe_name;							/**< name of the pipe to signal messages to be sent out */
 	int send_pipe_fd;							/**< reader from the pipe to signal messages to be sent out */
 	int send_pipe_fd_out;						/**< keep-alive writer for the pipe to signal messages to be sent out */
 
@@ -77,9 +75,9 @@ typedef struct _serviced_peer_t {
 	int length;									/**< length of the message as written in the header */
 	char *msg;									/**< dynamic buffer for receiving one message */
 	int msg_len;								/**< received bytes in the dynamic buffer */
-		
-	
-	struct _serviced_peer_t *next;	/**< first peer in the list */	
+
+
+	struct _serviced_peer_t *next;	/**< first peer in the list */
 	struct _serviced_peer_t *prev; /**< last peer in the list */
 } serviced_peer_t;
 

+ 176 - 176
modules/cdp/routing.c

@@ -55,12 +55,12 @@ int gcount = 0;
  * @returns 0 if not found, 1 if found
  */
 int peer_handles_application(peer *p, int app_id, int vendor_id) {
-    int i;
-    LM_DBG("Checking if peer %.*s handles application %d for vendord %d\n", p->fqdn.len, p->fqdn.s, app_id, vendor_id);
-    if (!p || !p->applications || !p->applications_cnt) return 0;
-    for (i = 0; i < p->applications_cnt; i++)
-        if (p->applications[i].id == app_id && p->applications[i].vendor == vendor_id) return 1;
-    return 0;
+	int i;
+	LM_DBG("Checking if peer %.*s handles application %d for vendord %d\n", p->fqdn.len, p->fqdn.s, app_id, vendor_id);
+	if (!p || !p->applications || !p->applications_cnt) return 0;
+	for (i = 0; i < p->applications_cnt; i++)
+		if (p->applications[i].id == app_id && p->applications[i].vendor == vendor_id) return 1;
+	return 0;
 }
 
 /**
@@ -69,93 +69,93 @@ int peer_handles_application(peer *p, int app_id, int vendor_id) {
  * @returns - the peer or null if none connected
  */
 peer* get_first_connected_route(cdp_session_t* cdp_session, routing_entry *r, int app_id, int vendor_id) {
-    peer * peers[LB_MAX_PEERS];
-    int peer_count = 0;
-    int prev_metric = 0;
-    routing_entry *i;
-    peer *p;
-    int j;
-    time_t least_recent_time;
-    struct timespec time_spec;
-
-    if (cdp_session) {
-        /*try and find an already used peer for this session - sticky*/
-        if ((cdp_session->sticky_peer_fqdn.len > 0) && cdp_session->sticky_peer_fqdn.s) {
-            //we have an old sticky peer. let's make sure it's up and connected before we use it.
-            AAASessionsUnlock(cdp_session->hash); /*V1.1 - Don't attempt to hold two locks at same time */
-            p = get_peer_by_fqdn(&cdp_session->sticky_peer_fqdn);
-            AAASessionsLock(cdp_session->hash); /*V1.1 - As we were...no call seems to pass cdp_session unlocked */  
-            if (p && !p->disabled && (p->state == I_Open || p->state == R_Open) && peer_handles_application(p, app_id, vendor_id)) {
-                p->last_selected = time(NULL);
-                LM_DBG("Found a sticky peer [%.*s] for this session - re-using\n", p->fqdn.len, p->fqdn.s);
-                return p;
-            }
-        }
-    }
-
-    for (i = r; i; i = i->next) {
-        if (peer_count >= LB_MAX_PEERS)
-            break;
-        p = get_peer_by_fqdn(&(i->fqdn));
-        if (!p)
-            LM_DBG("The peer %.*s does not seem to be connected or configured\n",
-                i->fqdn.len, i->fqdn.s);
-        else
-            LM_DBG("The peer %.*s state is %s\n", i->fqdn.len, i->fqdn.s,
-                (p->state == I_Open || p->state == R_Open) ? "opened" : "closed");
-        if (p && !p->disabled && (p->state == I_Open || p->state == R_Open) && peer_handles_application(p, app_id, vendor_id)) {
-            LM_DBG("The peer %.*s matches - will forward there\n", i->fqdn.len, i->fqdn.s);
-            if (peer_count != 0) {//check the metric
-                if (i->metric != prev_metric)
-                    break;
-                //metric must be the same
-                peers[peer_count++] = p;
-            } else {//we're first
-                prev_metric = i->metric;
-                peers[peer_count++] = p;
-            }
-        }
-    }
-
-    if (peer_count == 0) {
-        return 0;
-    }
-
-    least_recent_time = peers[0]->last_selected;
-    LM_DBG("peer [%.*s] was last used @ %ld\n", peers[0]->fqdn.len, peers[0]->fqdn.s, peers[0]->last_selected);
-    p = peers[0];
-    for (j = 1; j < peer_count; j++) {
-        LM_DBG("Peer [%.*s] was last used at [%ld]\n", peers[j]->fqdn.len, peers[j]->fqdn.s, peers[j]->last_selected);
-        if (peers[j]->last_selected < least_recent_time) {
-            least_recent_time = peers[j]->last_selected;
-            p = peers[j];
-        }
-    }
-
-    ser_clock_gettime(&time_spec);
-
-    p->last_selected = (time_spec.tv_sec*1000000) + round(time_spec.tv_nsec / 1.0e3); // Convert nanoseconds to microseconds
-    LM_DBG("chosen peer [%.*s]\n", p->fqdn.len, p->fqdn.s);
-
-    if (cdp_session) {
-        if (cdp_session->sticky_peer_fqdn_buflen <= p->fqdn.len) {
-            LM_DBG("not enough storage for sticky peer - allocating more\n");
-            if (cdp_session->sticky_peer_fqdn.s)
-                shm_free(cdp_session->sticky_peer_fqdn.s);
-
-            cdp_session->sticky_peer_fqdn.s = (char*) shm_malloc(p->fqdn.len + 1);
-            if (!cdp_session->sticky_peer_fqdn.s) {
-                LM_ERR("no more shm memory\n");
-                return 0;
-            }
-            cdp_session->sticky_peer_fqdn_buflen = p->fqdn.len + 1;
-            memset(cdp_session->sticky_peer_fqdn.s, 0, p->fqdn.len + 1);
-        }
-        cdp_session->sticky_peer_fqdn.len = p->fqdn.len;
-        memcpy(cdp_session->sticky_peer_fqdn.s, p->fqdn.s, p->fqdn.len);
-    }
-
-    return p;
+	peer * peers[LB_MAX_PEERS];
+	int peer_count = 0;
+	int prev_metric = 0;
+	routing_entry *i;
+	peer *p;
+	int j;
+	time_t least_recent_time;
+	struct timespec time_spec;
+
+	if (cdp_session) {
+		/*try and find an already used peer for this session - sticky*/
+		if ((cdp_session->sticky_peer_fqdn.len > 0) && cdp_session->sticky_peer_fqdn.s) {
+			//we have an old sticky peer. let's make sure it's up and connected before we use it.
+			AAASessionsUnlock(cdp_session->hash); /*V1.1 - Don't attempt to hold two locks at same time */
+			p = get_peer_by_fqdn(&cdp_session->sticky_peer_fqdn);
+			AAASessionsLock(cdp_session->hash); /*V1.1 - As we were...no call seems to pass cdp_session unlocked */
+			if (p && !p->disabled && (p->state == I_Open || p->state == R_Open) && peer_handles_application(p, app_id, vendor_id)) {
+				p->last_selected = time(NULL);
+				LM_DBG("Found a sticky peer [%.*s] for this session - re-using\n", p->fqdn.len, p->fqdn.s);
+				return p;
+			}
+		}
+	}
+
+	for (i = r; i; i = i->next) {
+		if (peer_count >= LB_MAX_PEERS)
+			break;
+		p = get_peer_by_fqdn(&(i->fqdn));
+		if (!p)
+			LM_DBG("The peer %.*s does not seem to be connected or configured\n",
+					i->fqdn.len, i->fqdn.s);
+		else
+			LM_DBG("The peer %.*s state is %s\n", i->fqdn.len, i->fqdn.s,
+					(p->state == I_Open || p->state == R_Open) ? "opened" : "closed");
+		if (p && !p->disabled && (p->state == I_Open || p->state == R_Open) && peer_handles_application(p, app_id, vendor_id)) {
+			LM_DBG("The peer %.*s matches - will forward there\n", i->fqdn.len, i->fqdn.s);
+			if (peer_count != 0) {//check the metric
+				if (i->metric != prev_metric)
+					break;
+				//metric must be the same
+				peers[peer_count++] = p;
+			} else {//we're first
+				prev_metric = i->metric;
+				peers[peer_count++] = p;
+			}
+		}
+	}
+
+	if (peer_count == 0) {
+		return 0;
+	}
+
+	least_recent_time = peers[0]->last_selected;
+	LM_DBG("peer [%.*s] was last used @ %ld\n", peers[0]->fqdn.len, peers[0]->fqdn.s, peers[0]->last_selected);
+	p = peers[0];
+	for (j = 1; j < peer_count; j++) {
+		LM_DBG("Peer [%.*s] was last used at [%ld]\n", peers[j]->fqdn.len, peers[j]->fqdn.s, peers[j]->last_selected);
+		if (peers[j]->last_selected < least_recent_time) {
+			least_recent_time = peers[j]->last_selected;
+			p = peers[j];
+		}
+	}
+
+	ser_clock_gettime(&time_spec);
+
+	p->last_selected = (time_spec.tv_sec*1000000) + round(time_spec.tv_nsec / 1.0e3); // Convert nanoseconds to microseconds
+	LM_DBG("chosen peer [%.*s]\n", p->fqdn.len, p->fqdn.s);
+
+	if (cdp_session) {
+		if (cdp_session->sticky_peer_fqdn_buflen <= p->fqdn.len) {
+			LM_DBG("not enough storage for sticky peer - allocating more\n");
+			if (cdp_session->sticky_peer_fqdn.s)
+				shm_free(cdp_session->sticky_peer_fqdn.s);
+
+			cdp_session->sticky_peer_fqdn.s = (char*) shm_malloc(p->fqdn.len + 1);
+			if (!cdp_session->sticky_peer_fqdn.s) {
+				LM_ERR("no more shm memory\n");
+				return 0;
+			}
+			cdp_session->sticky_peer_fqdn_buflen = p->fqdn.len + 1;
+			memset(cdp_session->sticky_peer_fqdn.s, 0, p->fqdn.len + 1);
+		}
+		cdp_session->sticky_peer_fqdn.len = p->fqdn.len;
+		memcpy(cdp_session->sticky_peer_fqdn.s, p->fqdn.s, p->fqdn.len);
+	}
+
+	return p;
 }
 
 /**
@@ -168,87 +168,87 @@ peer* get_first_connected_route(cdp_session_t* cdp_session, routing_entry *r, in
  * @returns - the connected peer or null if none connected found
  */
 peer* get_routing_peer(cdp_session_t* cdp_session, AAAMessage *m) {
-    str destination_realm = {0, 0}, destination_host = {0, 0};
-    AAA_AVP *avp, *avp_vendor, *avp2;
-    AAA_AVP_LIST group;
-    peer *p;
-    routing_realm *rr;
-    int app_id = 0, vendor_id = 0;
-
-    LM_DBG("getting diameter routing peer for realm: [%.*s]\n", m->dest_realm->data.len, m->dest_realm->data.s);
-
-    app_id = m->applicationId;
-    avp = AAAFindMatchingAVP(m, 0, AVP_Vendor_Specific_Application_Id, 0, AAA_FORWARD_SEARCH);
-    if (avp) {
-        group = AAAUngroupAVPS(avp->data);
-        avp_vendor = AAAFindMatchingAVPList(group, group.head, AVP_Vendor_Id, 0, 0);
-        avp2 = AAAFindMatchingAVPList(group, group.head, AVP_Auth_Application_Id, 0, 0);
-        if (avp_vendor && avp2) {
-            vendor_id = get_4bytes(avp_vendor->data.s);
-            app_id = get_4bytes(avp2->data.s);
-        }
-        avp2 = AAAFindMatchingAVPList(group, group.head, AVP_Acct_Application_Id, 0, 0);
-        if (avp_vendor && avp2) {
-            vendor_id = get_4bytes(avp_vendor->data.s);
-            app_id = get_4bytes(avp2->data.s);
-        }
-        AAAFreeAVPList(&group);
-    }
-
-    avp_vendor = AAAFindMatchingAVP(m, 0, AVP_Vendor_Id, 0, AAA_FORWARD_SEARCH);
-    avp = AAAFindMatchingAVP(m, 0, AVP_Auth_Application_Id, 0, AAA_FORWARD_SEARCH);
-    if (avp && avp_vendor) {
-	vendor_id = get_4bytes(avp_vendor->data.s);
-        app_id = get_4bytes(avp->data.s);
-    }
-
-    avp = AAAFindMatchingAVP(m, 0, AVP_Acct_Application_Id, 0, AAA_FORWARD_SEARCH);
-    if (avp && avp_vendor) {
-	vendor_id = get_4bytes(avp_vendor->data.s);
-        app_id = get_4bytes(avp->data.s);
-    }
-
-    avp = AAAFindMatchingAVP(m, 0, AVP_Destination_Host, 0, AAA_FORWARD_SEARCH);
-    if (avp) destination_host = avp->data;
-
-    if (destination_host.len) {
-        /* There is a destination host present in the message try and route directly there */
-        p = get_peer_by_fqdn(&destination_host);
-        if (p && (p->state == I_Open || p->state == R_Open) && peer_handles_application(p, app_id, vendor_id)) {
-            p->last_selected = time(NULL);
-            return p;
-        }
-        /* the destination host peer is not connected at the moment, try a normal route then */
-    }
-
-    avp = AAAFindMatchingAVP(m, 0, AVP_Destination_Realm, 0, AAA_FORWARD_SEARCH);
-    if (avp) destination_realm = avp->data;
-
-    if (!config->r_table) {
-        LM_ERR("get_routing_peer(): Empty routing table.\n");
-        return 0;
-    }
-
-    if (destination_realm.len) {
-        /* first search for the destination realm */
-        for (rr = config->r_table->realms; rr; rr = rr->next)
-            if (rr->realm.len == destination_realm.len &&
-                    strncasecmp(rr->realm.s, destination_realm.s, destination_realm.len) == 0)
-                break;
-        if (rr) {
-            p = get_first_connected_route(cdp_session, rr->routes, app_id, vendor_id);
-            if (p) return p;
-            else LM_ERR("get_routing_peer(): No connected Route peer found for Realm <%.*s>. Trying DefaultRoutes next...\n",
-                    destination_realm.len, destination_realm.s);
-        }
-    }
-    /* if not found in the realms or no destination_realm, 
-     * get the first connected host in default routes */
-    LM_DBG("no routing peer found, trying default route\n");
-    p = get_first_connected_route(cdp_session, config->r_table->routes, app_id, vendor_id);
-    if (!p) {
-        LM_ERR("get_routing_peer(): No connected DefaultRoute peer found for app_id %d and vendor id %d.\n",
-                app_id, vendor_id);
-    }
-    return p;
+	str destination_realm = {0, 0}, destination_host = {0, 0};
+	AAA_AVP *avp, *avp_vendor, *avp2;
+	AAA_AVP_LIST group;
+	peer *p;
+	routing_realm *rr;
+	int app_id = 0, vendor_id = 0;
+
+	LM_DBG("getting diameter routing peer for realm: [%.*s]\n", m->dest_realm->data.len, m->dest_realm->data.s);
+
+	app_id = m->applicationId;
+	avp = AAAFindMatchingAVP(m, 0, AVP_Vendor_Specific_Application_Id, 0, AAA_FORWARD_SEARCH);
+	if (avp) {
+		group = AAAUngroupAVPS(avp->data);
+		avp_vendor = AAAFindMatchingAVPList(group, group.head, AVP_Vendor_Id, 0, 0);
+		avp2 = AAAFindMatchingAVPList(group, group.head, AVP_Auth_Application_Id, 0, 0);
+		if (avp_vendor && avp2) {
+			vendor_id = get_4bytes(avp_vendor->data.s);
+			app_id = get_4bytes(avp2->data.s);
+		}
+		avp2 = AAAFindMatchingAVPList(group, group.head, AVP_Acct_Application_Id, 0, 0);
+		if (avp_vendor && avp2) {
+			vendor_id = get_4bytes(avp_vendor->data.s);
+			app_id = get_4bytes(avp2->data.s);
+		}
+		AAAFreeAVPList(&group);
+	}
+
+	avp_vendor = AAAFindMatchingAVP(m, 0, AVP_Vendor_Id, 0, AAA_FORWARD_SEARCH);
+	avp = AAAFindMatchingAVP(m, 0, AVP_Auth_Application_Id, 0, AAA_FORWARD_SEARCH);
+	if (avp && avp_vendor) {
+		vendor_id = get_4bytes(avp_vendor->data.s);
+		app_id = get_4bytes(avp->data.s);
+	}
+
+	avp = AAAFindMatchingAVP(m, 0, AVP_Acct_Application_Id, 0, AAA_FORWARD_SEARCH);
+	if (avp && avp_vendor) {
+		vendor_id = get_4bytes(avp_vendor->data.s);
+		app_id = get_4bytes(avp->data.s);
+	}
+
+	avp = AAAFindMatchingAVP(m, 0, AVP_Destination_Host, 0, AAA_FORWARD_SEARCH);
+	if (avp) destination_host = avp->data;
+
+	if (destination_host.len) {
+		/* There is a destination host present in the message try and route directly there */
+		p = get_peer_by_fqdn(&destination_host);
+		if (p && (p->state == I_Open || p->state == R_Open) && peer_handles_application(p, app_id, vendor_id)) {
+			p->last_selected = time(NULL);
+			return p;
+		}
+		/* the destination host peer is not connected at the moment, try a normal route then */
+	}
+
+	avp = AAAFindMatchingAVP(m, 0, AVP_Destination_Realm, 0, AAA_FORWARD_SEARCH);
+	if (avp) destination_realm = avp->data;
+
+	if (!config->r_table) {
+		LM_ERR("get_routing_peer(): Empty routing table.\n");
+		return 0;
+	}
+
+	if (destination_realm.len) {
+		/* first search for the destination realm */
+		for (rr = config->r_table->realms; rr; rr = rr->next)
+			if (rr->realm.len == destination_realm.len &&
+					strncasecmp(rr->realm.s, destination_realm.s, destination_realm.len) == 0)
+				break;
+		if (rr) {
+			p = get_first_connected_route(cdp_session, rr->routes, app_id, vendor_id);
+			if (p) return p;
+			else LM_ERR("get_routing_peer(): No connected Route peer found for Realm <%.*s>. Trying DefaultRoutes next...\n",
+					destination_realm.len, destination_realm.s);
+		}
+	}
+	/* if not found in the realms or no destination_realm,
+	 * get the first connected host in default routes */
+	LM_DBG("no routing peer found, trying default route\n");
+	p = get_first_connected_route(cdp_session, config->r_table->routes, app_id, vendor_id);
+	if (!p) {
+		LM_ERR("get_routing_peer(): No connected DefaultRoute peer found for app_id %d and vendor id %d.\n",
+				app_id, vendor_id);
+	}
+	return p;
 }

+ 9 - 11
modules/cdp/routing.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __ROUTING_H

+ 30 - 32
modules/cdp/sem.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __SEM_H
@@ -50,19 +48,19 @@
 
 //	#include "../../mem/mem.h"
 //	#include "../../mem/shm_mem.h"
-	
-	#include "utils.h"
-	
-	#include <semaphore.h>
 
-	typedef sem_t gen_sem_t;
+#include "utils.h"
+
+#include <semaphore.h>
+
+typedef sem_t gen_sem_t;
 
-	/**
-	 * Create a new unnamed semaphore and initialize it
-	 * @param value - 0 if it should be pre-locked, 1 if not, or how many locks until block
-	 * @return
-	 */
-    #define sem_new(sem_ptr,value)\
+/**
+ * Create a new unnamed semaphore and initialize it
+ * @param value - 0 if it should be pre-locked, 1 if not, or how many locks until block
+ * @return
+ */
+#define sem_new(sem_ptr,value)\
 	do {\
 		sem_ptr=shm_malloc(sizeof(gen_sem_t));\
 		if (!sem_ptr){\
@@ -74,8 +72,8 @@
 			goto out_of_memory;\
 		}\
 	} while(0)
-	
-    #define sem_free(sem)\
+
+#define sem_free(sem)\
 	do {\
 		if (sem) {\
 			sem_destroy(sem);\
@@ -83,16 +81,16 @@
 			sem=0;\
 		}\
 	} while(0)
-	
-	
-	#define sem_get(sem) sem_wait(sem)
-	#define sem_tryget(sem) sem_trywait(sem)
-	#define sem_timedget(sem,abs_timeout) sem_trywait(sem,abs_timeout)
-	
-	#define sem_release(sem) sem_post(sem)
+
+
+#define sem_get(sem) sem_wait(sem)
+#define sem_tryget(sem) sem_trywait(sem)
+#define sem_timedget(sem,abs_timeout) sem_trywait(sem,abs_timeout)
+
+#define sem_release(sem) sem_post(sem)
 
 #else
-	//#error "locking requires shared memory support"
+//#error "locking requires shared memory support"
 #endif
 
 #endif

+ 76 - 78
modules/cdp/session.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include <time.h>
@@ -111,7 +109,7 @@ void free_session(cdp_session_t *x)
 			case UNKNOWN_SESSION:
 				if (x->u.generic_data){
 					LM_ERR("free_session(): The session->u.generic_data should be freed and reset before dropping the session!"
-						"Possible memory leak!\n");
+							"Possible memory leak!\n");
 				}
 				break;
 			case AUTH_CLIENT_STATEFULL:
@@ -126,9 +124,9 @@ void free_session(cdp_session_t *x)
 
 		if(x->dest_host.s) shm_free(x->dest_host.s);
 		if(x->dest_realm.s) shm_free(x->dest_realm.s);
-                if (x->sticky_peer_fqdn_buflen && x->sticky_peer_fqdn.s) {
-                    shm_free(x->sticky_peer_fqdn.s);
-                }
+		if (x->sticky_peer_fqdn_buflen && x->sticky_peer_fqdn.s) {
+			shm_free(x->sticky_peer_fqdn.s);
+		}
 		shm_free(x);
 	}
 }
@@ -228,24 +226,24 @@ int cdp_sessions_destroy()
 inline unsigned int get_str_hash(str x,int hash_size)
 {
 #define h_inc h+=v^(v>>3)
-   char* p;
-   register unsigned v;
-   register unsigned h;
-
-   h=0;
-   for (p=x.s; p<=(x.s+x.len-4); p+=4){
-       v=(*p<<24)+(p[1]<<16)+(p[2]<<8)+p[3];
-       h_inc;
-   }
-   v=0;
-   for (;p<(x.s+x.len); p++) {
-       v<<=8;
-       v+=*p;
-   }
-   h_inc;
-
-   h=((h)+(h>>11))+((h>>13)+(h>>23));
-   return (h)%hash_size;
+	char* p;
+	register unsigned v;
+	register unsigned h;
+
+	h=0;
+	for (p=x.s; p<=(x.s+x.len-4); p+=4){
+		v=(*p<<24)+(p[1]<<16)+(p[2]<<8)+p[3];
+		h_inc;
+	}
+	v=0;
+	for (;p<(x.s+x.len); p++) {
+		v<<=8;
+		v+=*p;
+	}
+	h_inc;
+
+	h=((h)+(h>>11))+((h>>13)+(h>>23));
+	return (h)%hash_size;
 #undef h_inc
 }
 
@@ -280,10 +278,10 @@ error:
  */
 void cdp_add_session(cdp_session_t *x)
 {
-//	unsigned int hash;
+	//	unsigned int hash;
 	if (!x) return;
-//	hash = get_str_hash(x->id,sessions_hash_size);
-//	x->hash = hash;
+	//	hash = get_str_hash(x->id,sessions_hash_size);
+	//	x->hash = hash;
 	LM_DBG("adding a session with id %.*s\n",x->id.len,x->id.s);
 	AAASessionsLock(x->hash);
 	x->next = 0;
@@ -307,12 +305,12 @@ cdp_session_t* cdp_get_session(str id)
 	hash = get_str_hash(id,sessions_hash_size);
 	LM_DBG("called get session with id %.*s and hash %u\n",id.len,id.s,hash);
 	AAASessionsLock(hash);
-		for(x = sessions[hash].head;x;x=x->next){
-			LM_DBG("looking for |%.*s| in |%.*s|\n",id.len,id.s,x->id.len,x->id.s);
-			if (x->id.len == id.len &&
+	for(x = sessions[hash].head;x;x=x->next){
+		LM_DBG("looking for |%.*s| in |%.*s|\n",id.len,id.s,x->id.len,x->id.s);
+		if (x->id.len == id.len &&
 				strncasecmp(x->id.s,id.s,id.len)==0)
-					return x;
-		}
+			return x;
+	}
 	AAASessionsUnlock(hash);
 	LM_DBG("no session found\n");
 	return 0;
@@ -365,7 +363,7 @@ static int generate_session_id(str *id, unsigned int end_pad_len)
 	id->len = config->identity.len +
 		1/*;*/ + 10/*high 32 bits*/ +
 		1/*;*/ + 10/*low 32 bits*/ +
-//		1/*;*/ + 8/*optional value*/ +
+		//		1/*;*/ + 8/*optional value*/ +
 		1 /* terminating \0 */ +
 		end_pad_len;
 
@@ -411,8 +409,8 @@ void cdp_sessions_log()
 							(int)(x->u.auth.timeout-time(0)),
 							x->u.auth.lifetime?(int)(x->u.auth.lifetime-time(0)):-1,
 							(int)(x->u.auth.grace_period),
-							x->u.auth.generic_data, 
-                                                        x->u.auth.class);
+							x->u.auth.generic_data,
+							x->u.auth.class);
 					break;
 				case ACCT_CC_CLIENT:
 					LM_DBG(ANSI_GRAY"\tCCAcct State [%d] Charging Active [%c (%d)s] Reserved Units(valid=%ds) [%d] Generic [%p]\n",
@@ -456,16 +454,16 @@ int cdp_sessions_timer(time_t now, void* ptr)
 						int buffer_time = 15; //15 seconds - TODO: add as config parameter
 						//we should check for reservation expiries if the state is open
 						if(x->u.cc_acc.state==ACC_CC_ST_OPEN){
-						    if (last_res_timestamp) {
-							    //we have obv already started reservations
-							    if ((last_res_timestamp + res_valid_for) < (time(0) + last_reservation + buffer_time)) {
-								    LM_DBG("reservation about to expire, sending callback\n");
-								    cc_acc_client_stateful_sm_process(x, ACC_CC_EV_RSVN_WARNING, 0);
-							    }
-
-						    }
+							if (last_res_timestamp) {
+								//we have obv already started reservations
+								if ((last_res_timestamp + res_valid_for) < (time(0) + last_reservation + buffer_time)) {
+									LM_DBG("reservation about to expire, sending callback\n");
+									cc_acc_client_stateful_sm_process(x, ACC_CC_EV_RSVN_WARNING, 0);
+								}
+
+							}
 						}
-						/* TODO: if reservation has expired we need to tear down the session. Ideally 
+						/* TODO: if reservation has expired we need to tear down the session. Ideally
 						 * the client application (module) should do this but for completeness we should
 						 * put a failsafe here too.
 						 */
@@ -589,8 +587,8 @@ AAASession* cdp_new_auth_session(str id,int is_client,int is_statefull)
 		s->u.auth.timeout=time(0)+config->default_auth_session_timeout;
 		s->u.auth.lifetime=0;
 		s->u.auth.grace_period=0;
-                s->u.auth.class = AUTH_CLASS_UNKNOWN;
-                s->u.auth.last_requested_grace = s->u.auth.last_requested_lifetime = s->u.auth.last_requested_timeout = 0;
+		s->u.auth.class = AUTH_CLASS_UNKNOWN;
+		s->u.auth.last_requested_grace = s->u.auth.last_requested_lifetime = s->u.auth.last_requested_timeout = 0;
 		cdp_add_session(s);
 	}
 	return s;
@@ -617,7 +615,7 @@ AAASession* cdp_new_cc_acc_session(str id, int is_statefull)
 		else
 			s->u.cc_acc.type = ACC_CC_TYPE_EVENT;
 
-//		s->u.cc_acc.timeout=time(0)+config->default_cc_acct_session_timeout;
+		//		s->u.cc_acc.timeout=time(0)+config->default_cc_acct_session_timeout;
 		cdp_add_session(s);
 	}
 	return s;
@@ -765,7 +763,7 @@ AAASession* AAACreateCCAccSession(AAASessionCallback_f *cb, int is_session, void
 
 	s = cdp_new_cc_acc_session(id, is_session);
 	if (s) {
-		if (generic_data) 
+		if (generic_data)
 			s->u.auth.generic_data = generic_data;
 		s->cb = cb;
 		if (s->cb)
@@ -776,7 +774,7 @@ AAASession* AAACreateCCAccSession(AAASessionCallback_f *cb, int is_session, void
 
 /**
  * Starts accounting on time-based CC App session (Credit control - RFC 4006) for the client
-  * @returns 0 on success, anything else on failure
+ * @returns 0 on success, anything else on failure
  */
 int AAAStartChargingCCAccSession(AAASession *s)
 {
@@ -827,32 +825,32 @@ void AAATerminateCCAccSession(AAASession *s)
 }
 
 void cdp_session_cleanup(cdp_session_t* s, AAAMessage* msg) {
-    // Here we should drop the session ! and free everything related to it
-    // but the generic_data thing should be freed by the callback function registered
-    // when the auth session was created
-    AAASessionCallback_f *cb;
-
-    LM_DBG("cleaning up session %.*s\n", s->id.len, s->id.s);
-    switch (s->type) {
-    	case ACCT_CC_CLIENT:
-    		if (s->cb) {
-    			cb = s->cb;
-    			(cb)(ACC_CC_EV_SESSION_TERMINATED, s);
-    		}
-    		AAADropCCAccSession(s);
-    		break;
-    	case AUTH_CLIENT_STATEFULL:
-    	case AUTH_CLIENT_STATELESS:
+	// Here we should drop the session ! and free everything related to it
+	// but the generic_data thing should be freed by the callback function registered
+	// when the auth session was created
+	AAASessionCallback_f *cb;
+
+	LM_DBG("cleaning up session %.*s\n", s->id.len, s->id.s);
+	switch (s->type) {
+		case ACCT_CC_CLIENT:
+			if (s->cb) {
+				cb = s->cb;
+				(cb)(ACC_CC_EV_SESSION_TERMINATED, s);
+			}
+			AAADropCCAccSession(s);
+			break;
+		case AUTH_CLIENT_STATEFULL:
+		case AUTH_CLIENT_STATELESS:
 			if (s->cb) {
 				cb = s->cb;
 				(cb)(AUTH_EV_SERVICE_TERMINATED, s);
 			}
 			AAADropAuthSession(s);
 			break;
-    	default:
-    		LM_WARN("asked to cleanup unknown/unhandled session type [%d]\n", s->type);
-    		break;
-    }
+		default:
+			LM_WARN("asked to cleanup unknown/unhandled session type [%d]\n", s->type);
+			break;
+	}
 
 }
 

+ 17 - 19
modules/cdp/session.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __DIAMETER_SESSION_H
@@ -112,7 +110,7 @@ typedef enum {
 
 /** Accounting states definition */
 typedef enum {
-        AUTH_CLASS_UNKNOWN              = 0,
+	AUTH_CLASS_UNKNOWN              = 0,
 	AUTH_CLASS_RXREG                = 1,
 	AUTH_CLASS_RXMEDIA              = 2
 } cdp_auth_session_class_t;
@@ -120,13 +118,13 @@ typedef enum {
 /** structure for auth session */
 typedef struct _cdp_auth_session_t {
 	cdp_auth_state state;           /**< current state */
-        cdp_auth_session_class_t class; /**< useful to know if this is Rx reg or Rx media for example */
+	cdp_auth_session_class_t class; /**< useful to know if this is Rx reg or Rx media for example */
 	time_t timeout;			/**< absolute time for session timeout  -1 means forever */
 	time_t lifetime;		/**< absolute time for auth lifetime -1 means forever */
 	time_t grace_period;            /**< grace_period in seconds 	*/
-        unsigned int last_requested_lifetime;   /**< the following 3 timers are used to store what we are */
-        unsigned int last_requested_timeout;    /**<requesitng in a request, if the answer does not have anything */
-        unsigned int last_requested_grace;      /**<different then we will use these values */ 
+	unsigned int last_requested_lifetime;   /**< the following 3 timers are used to store what we are */
+	unsigned int last_requested_timeout;    /**<requesitng in a request, if the answer does not have anything */
+	unsigned int last_requested_grace;      /**<different then we will use these values */
 
 	void* generic_data;
 } cdp_auth_session_t;
@@ -221,7 +219,7 @@ typedef struct _cc_acc_session {
 	time_t discon_time;						/**< the time we went into DISCON state. we use this to cleanup dead sessions*/
 	cdp_cc_acc_type_t type;					/**< type of CC, event or session (each have a different state machine - see RFC 4006 */
 	cdp_cc_acc_ccfh_t ccfh;					/**< credit control failure handling type set for this session */
-//	cdp_cc_acc_fua_t fua;					/**< final unit action */
+	//	cdp_cc_acc_fua_t fua;					/**< final unit action */
 	int fua;								/**< TODO: clean this up */
 	unsigned int acct_record_number; 		/**< number of last accounting record within this session */
 	time_t timeout;							/**< session timeout (seconds) - this is to prevent idle sessions from 'hanging' around */
@@ -241,8 +239,8 @@ typedef struct _cdp_session_t {
 	unsigned int vendor_id;				/**< specific vendor id for this session */
 	cdp_session_type_t type;
 	str dest_host, dest_realm; 			/*the destination host and realm, used only for auth, for the moment*/
-        str sticky_peer_fqdn;                           /*peer that we would like to stick for for this session*/
-        int sticky_peer_fqdn_buflen;                     /*length of buffer available for sticky peer*/
+	str sticky_peer_fqdn;                           /*peer that we would like to stick for for this session*/
+	int sticky_peer_fqdn_buflen;                     /*length of buffer available for sticky peer*/
 	union {
 		cdp_auth_session_t auth;
 		cdp_acc_session_t acc;

+ 39 - 41
modules/cdp/tcp_accept.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 
@@ -88,72 +86,72 @@ int create_socket(int listen_port,str bind_to,unsigned int *sock)
 	char buf[256],host[256],serv[256];
 	int error=0;
 	unsigned int option;
-	
+
 	memset (&hints, 0, sizeof(hints));
 	//hints.ai_protocol = IPPROTO_SCTP;
- 	//hints.ai_protocol = IPPROTO_TCP;
- 	hints.ai_flags = AI_PASSIVE|AI_ADDRCONFIG;
+	//hints.ai_protocol = IPPROTO_TCP;
+	hints.ai_flags = AI_PASSIVE|AI_ADDRCONFIG;
 	hints.ai_socktype = SOCK_STREAM;
 
 	sprintf(buf,"%d",listen_port);
-	
+
 	if (bind_to.len){
 		error = getaddrinfo(bind_to.s, buf, &hints, &res);
 		if (error!=0){
 			LM_WARN("create_socket(): Error opening %.*s port %d while doing gethostbyname >%s\n",
-				bind_to.len,bind_to.s,listen_port,gai_strerror(error));
+					bind_to.len,bind_to.s,listen_port,gai_strerror(error));
 			goto error;
 		}
 	}else{
 		error = getaddrinfo(NULL, buf, &hints, &res);
 		if (error!=0){
 			LM_WARN("create_socket(): Error opening ANY port %d while doing gethostbyname >%s\n",
-				listen_port,gai_strerror(error));
+					listen_port,gai_strerror(error));
 			goto error;
 		}
 	}
-		
+
 	LM_DBG("create_sockets: create socket and bind for IPv4...\n");
 
 	for(ainfo = res;ainfo;ainfo = ainfo->ai_next)
 	{
 		if (getnameinfo(ainfo->ai_addr,ainfo->ai_addrlen,
-			host,256,serv,256,NI_NUMERICHOST|NI_NUMERICSERV)==0){
-				LM_WARN("create_socket(): Trying to open/bind/listen on %s port %s\n",
+					host,256,serv,256,NI_NUMERICHOST|NI_NUMERICSERV)==0){
+			LM_WARN("create_socket(): Trying to open/bind/listen on %s port %s\n",
 					host,serv);
-		}				
+		}
 
 		if ((server_sock = socket(ainfo->ai_family, ainfo->ai_socktype, ainfo->ai_protocol)) == -1) {
 			LM_ERR("create_socket(): error creating server socket on %s port %s >"
-				" %s\n",host,serv,strerror(errno));
+					" %s\n",host,serv,strerror(errno));
 			goto error;
 		}
 		option = 1;
 		setsockopt(server_sock,SOL_SOCKET,SO_REUSEADDR,&option,sizeof(option));
-		
+
 		if (bind( 	server_sock,ainfo->ai_addr,ainfo->ai_addrlen)==-1 ) {
 			LM_ERR("create_socket(): error binding on %s port %s >"
-				" %s\n",host,serv,strerror(errno));
+					" %s\n",host,serv,strerror(errno));
 			goto error;
 		}
-	
+
 		if (listen( server_sock, 5) == -1) {
 			LM_ERR("create_socket(): error listening on %s port %s > %s\n",host,serv,strerror(errno) );
 			goto error;
 		}
-	
-		*sock = server_sock;	
-		
+
+		*sock = server_sock;
+
 		LM_WARN("create_socket(): Successful socket open/bind/listen on %s port %s\n",
-					host,serv);
+				host,serv);
 	}
-	if (res) freeaddrinfo(res);	
+	if (res) freeaddrinfo(res);
 	return 1;
 error:
 	if (res) freeaddrinfo(res);
 	if (server_sock!=-1) close(server_sock);
 	return 0;
-	
+
 }
 
 /**
@@ -166,7 +164,7 @@ inline static int accept_connection(int server_sock,int *new_sock)
 {
 	unsigned int length;
 	struct sockaddr_in remote;
-		
+
 	/* do accept */
 	length = sizeof( struct sockaddr_in);
 	*new_sock = accept( server_sock, (struct sockaddr*)&remote, &length);
@@ -176,11 +174,11 @@ inline static int accept_connection(int server_sock,int *new_sock)
 		goto error;
 	} else {
 		LM_INFO("accept_connection(): new tcp connection accepted!\n");
-		
+
 	}
-	
+
 	receiver_send_socket(*new_sock,0);
-	
+
 	return 1;
 error:
 	return 0;
@@ -197,7 +195,7 @@ void accept_loop()
 	struct timeval timeout;
 	int i=0,max_sock=0,nready;
 	int new_sock;
-	
+
 
 	while(listening_socks[i]){
 		if (listening_socks[i]>max_sock) max_sock=listening_socks[i];
@@ -206,15 +204,15 @@ void accept_loop()
 
 	while(1){
 		if (shutdownx && *shutdownx) break;
-		
+
 		cfg_update();
-		
+
 		timeout.tv_sec=2;
-		timeout.tv_usec=0;	
+		timeout.tv_usec=0;
 		FD_ZERO(&listen_set);
 		i=0;
 		while(listening_socks[i]){
-			FD_SET(listening_socks[i],&listen_set);					
+			FD_SET(listening_socks[i],&listen_set);
 			i++;
 		}
 
@@ -228,7 +226,7 @@ void accept_loop()
 				continue;
 			} else {
 				LM_ERR("accept_loop(): select fails: %s\n",
-					strerror(errno));
+						strerror(errno));
 				sleep(2);
 				continue;
 			}

+ 9 - 11
modules/cdp/tcp_accept.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __TCP_ACCEPT_H

+ 47 - 49
modules/cdp/timer.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,13 +35,13 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
-#include <time.h> 
+#include <time.h>
 #include <stdlib.h>
 #include <unistd.h>
 
@@ -81,42 +79,42 @@ void timer_loop()
 	callback_f cb=0;
 	void *ptr=0;
 	int interval=0;
-	
+
 	while(1){
 		if (shutdownx && *shutdownx) break;
 		now = time(0);
 		cfg_update();
-	
+
 		do {
 			cb = 0;
 			lock_get(timers_lock);
-				i = timers->head;
-				while(i && i->expires>now) i = i->next;
-				if (i){
-					cb = i->cb;
-					ptr = *(i->ptr);
-					if (i->one_time){
-						if (i->prev) i->prev->next = i->next;
-						else timers->head = i->next;
-						if (i->next) i->next->prev = i->prev;
-						else timers->tail = i->next;
-						shm_free(i);
-						i=0;
-					}
+			i = timers->head;
+			while(i && i->expires>now) i = i->next;
+			if (i){
+				cb = i->cb;
+				ptr = *(i->ptr);
+				if (i->one_time){
+					if (i->prev) i->prev->next = i->next;
+					else timers->head = i->next;
+					if (i->next) i->next->prev = i->prev;
+					else timers->tail = i->next;
+					shm_free(i);
+					i=0;
 				}
+			}
 			lock_release(timers_lock);
-	
-			if (cb) { 
+
+			if (cb) {
 				interval = cb(now,ptr);
 				if (i){
 					lock_get(timers_lock);
-						i->expires = now + interval;
+					i->expires = now + interval;
 					lock_release(timers_lock);
 				}
 			}
-	
+
 		} while(cb);
-				
+
 		sleep(TIMER_RESOLUTION);
 	}
 }
@@ -154,11 +152,11 @@ int add_timer(int expires_in,int one_time,callback_f cb,void *ptr)
 	*(n->ptr) = ptr;
 
 	lock_get(timers_lock);
-		n->prev = timers->tail;
-		n->next = 0;
-		if (!timers->head) timers->head = n;
-		if (timers->tail) timers->tail->next = n;
-		timers->tail = n;
+	n->prev = timers->tail;
+	n->next = 0;
+	if (!timers->head) timers->head = n;
+	if (timers->tail) timers->tail->next = n;
+	timers->tail = n;
 	lock_release(timers_lock);
 	return 1;
 }
@@ -172,7 +170,7 @@ void timer_cdp_init()
 	timers->head=0;
 	timers->tail=0;
 	timers_lock = lock_alloc();
-	timers_lock = lock_init(timers_lock);	
+	timers_lock = lock_init(timers_lock);
 }
 
 /**
@@ -181,7 +179,7 @@ void timer_cdp_init()
 void timer_cdp_destroy()
 {
 	timer_cb_t *n,*i;
-/*	lock_get(timers_lock);*/
+	/*	lock_get(timers_lock);*/
 	i = timers->head;
 	while(i){
 		n = i->next;
@@ -203,25 +201,25 @@ void timer_cdp_destroy()
 void timer_process(int returns)
 {
 	LM_INFO("Timer process starting up...\n");
-		
+
 	timer_loop();
-	
+
 	LM_INFO("... Timer process finished\n");
 	if (!returns) {
 #ifdef CDP_FOR_SER
 #else
 #ifdef PKG_MALLOC
-	#ifdef PKG_MALLOC
+#ifdef PKG_MALLOC
 		LM_DBG("Timer Memory status (pkg):\n");
 		//pkg_status();
-		#ifdef pkg_sums
-			pkg_sums();
-		#endif 
-	#endif
+#ifdef pkg_sums
+		pkg_sums();
 #endif
-		dp_del_pid(getpid());		
-#endif		
-		
+#endif
+#endif
+		dp_del_pid(getpid());
+#endif
+
 		exit(0);
 	}
 }

+ 11 - 13
modules/cdp/timer.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __TIMERCDP_H
@@ -57,9 +55,9 @@ typedef struct _timer_cb_t{
 	int one_time;		/**< if to trigger the event just one_time and then remove */
 	callback_f cb;		/**< callback function to be called on timer expiration */
 	void **ptr;			/**< generic parameter to call the callback with		*/
-	
+
 	struct _timer_cb_t *next;/**< next timer in the timer list */
-	struct _timer_cb_t *prev;/**< previous timer in the timer list */	
+	struct _timer_cb_t *prev;/**< previous timer in the timer list */
 } timer_cb_t;
 
 /** timer list */

+ 25 - 26
modules/cdp/transaction.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include "transaction.h"
@@ -100,7 +98,8 @@ int cdp_trans_destroy()
  * @param auto_drop - whether to auto drop the transaction on event, or let the application do it later
  * @returns the created cdp_trans_t* or NULL on error
  */
-inline cdp_trans_t* cdp_add_trans(AAAMessage *msg,AAATransactionCallback_f *cb, void *ptr,int timeout,int auto_drop)
+cdp_trans_t* cdp_add_trans(AAAMessage *msg,AAATransactionCallback_f *cb,
+		void *ptr,int timeout,int auto_drop)
 {
 	cdp_trans_t *x;
 	x = shm_malloc(sizeof(cdp_trans_t));
@@ -137,7 +136,7 @@ inline cdp_trans_t* cdp_add_trans(AAAMessage *msg,AAATransactionCallback_f *cb,
  * Remove from the list and deallocate a transaction.
  * @param msg - the message that relates to that particular transaction
  */
-inline void del_trans(AAAMessage *msg)
+void del_trans(AAAMessage *msg)
 {
 	cdp_trans_t *x;
 	lock_get(trans_list->lock);
@@ -158,7 +157,7 @@ inline void del_trans(AAAMessage *msg)
  * @param msg - the message that this transaction relates to
  * @returns the cdp_trans_t* if found or NULL if not
  */
-inline cdp_trans_t* cdp_take_trans(AAAMessage *msg)
+cdp_trans_t* cdp_take_trans(AAAMessage *msg)
 {
 	cdp_trans_t *x;
 	lock_get(trans_list->lock);
@@ -178,7 +177,7 @@ inline cdp_trans_t* cdp_take_trans(AAAMessage *msg)
  * Deallocate the memory taken by a transaction.
  * @param x - the transaction to deallocate
  */
-inline void cdp_free_trans(cdp_trans_t *x)
+void cdp_free_trans(cdp_trans_t *x)
 {
 	if (x->ptr) shm_free(x->ptr);
 	shm_free(x);
@@ -198,8 +197,8 @@ int cdp_trans_timer(time_t now, void* ptr)
 	while(x)
 	{
 		if (now>x->expires){
-            counter_inc(cdp_cnts_h.timeout);		//Transaction has timed out waiting for response
-	    
+			counter_inc(cdp_cnts_h.timeout);		//Transaction has timed out waiting for response
+
 			x->ans = 0;
 			if (x->cb){
 				(x->cb)(1,*(x->ptr),0, (now - x->expires));
@@ -225,11 +224,11 @@ int cdp_trans_timer(time_t now, void* ptr)
 /* TRANSACTIONS */
 
 /**
-* Create a AAATransaction for the given request.
-* @param app_id - id of the request's application
-* @param cmd_code - request's code
-* @returns the AAATransaction*
-*/
+ * Create a AAATransaction for the given request.
+ * @param app_id - id of the request's application
+ * @param cmd_code - request's code
+ * @returns the AAATransaction*
+ */
 AAATransaction *AAACreateTransaction(AAAApplicationId app_id,AAACommandCode cmd_code)
 {
 	AAATransaction *t;
@@ -242,10 +241,10 @@ AAATransaction *AAACreateTransaction(AAAApplicationId app_id,AAACommandCode cmd_
 }
 
 /**
-* Free the memory allocated for the AAATransaction.
-* @param trans - the AAATransaction to be deallocated
-* @returns 1 on success, 0 on failure
-*/
+ * Free the memory allocated for the AAATransaction.
+ * @param trans - the AAATransaction to be deallocated
+ * @returns 1 on success, 0 on failure
+ */
 int AAADropTransaction(AAATransaction *trans)
 {
 	if (!trans) return 0;

+ 16 - 18
modules/cdp/transaction.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __TRANSACTION_H_
@@ -66,25 +64,25 @@ typedef struct _cdp_trans_t{
 } cdp_trans_t;
 
 /** Diameter Transaction list */
-typedef struct {		
+typedef struct {
 	gen_lock_t *lock;				/**< lock for list operations */
-	cdp_trans_t *head,*tail;		/**< first, last transactions in the list */ 
+	cdp_trans_t *head,*tail;		/**< first, last transactions in the list */
 } cdp_trans_list_t;
 
 int cdp_trans_init();
 int cdp_trans_destroy();
 
-inline cdp_trans_t* cdp_add_trans(AAAMessage *msg,AAATransactionCallback_f *cb, void *ptr,int timeout,int auto_drop);
+cdp_trans_t* cdp_add_trans(AAAMessage *msg,AAATransactionCallback_f *cb, void *ptr,int timeout,int auto_drop);
 void del_trans(AAAMessage *msg);
-inline cdp_trans_t* cdp_take_trans(AAAMessage *msg);
-inline void cdp_free_trans(cdp_trans_t *x);
+cdp_trans_t* cdp_take_trans(AAAMessage *msg);
+void cdp_free_trans(cdp_trans_t *x);
 
 int cdp_trans_timer(time_t now, void* ptr);
 
 /*            API Exported    */
 
-/** Timeout for Diameter transactions (this is quite big, 
- * but increase in case that you have a slow peer) */ 				
+/** Timeout for Diameter transactions (this is quite big,
+ * but increase in case that you have a slow peer) */
 
 AAATransaction *AAACreateTransaction(AAAApplicationId app_id,AAACommandCode cmd_code);
 typedef AAATransaction * (*AAACreateTransaction_f)(AAAApplicationId app_id,AAACommandCode cmd_code);

+ 10 - 12
modules/cdp/utils.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __CDP_UTILS_H_
@@ -52,7 +50,7 @@
 #include "../../mem/shm_mem.h"
 #include "../../locking.h"
 #include "../../pt.h"
-#include "sem.h" 
+#include "sem.h"
 
 #ifndef LOG_NO_MEM
 	#define LOG_NO_MEM(mem_type,data_len) \

+ 238 - 238
modules/cdp/worker.c

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #include <time.h>
@@ -77,127 +75,127 @@ extern unsigned int workerq_length_threshold_percentage;	/**< default threshold
  * Initializes the worker structures, like the task queue.
  */
 void worker_init() {
-    tasks = shm_malloc(sizeof (task_queue_t));
-
-    tasks->lock = lock_alloc();
-    tasks->lock = lock_init(tasks->lock);
-
-    sem_new(tasks->empty, 0);
-
-    sem_new(tasks->full, 1);
-
-    tasks->start = 0;
-    tasks->end = 0;
-    tasks->max = config->queue_length;
-    tasks->queue = shm_malloc(tasks->max * sizeof (task_t));
-    if (!tasks->queue) {
-        LOG_NO_MEM("shm", tasks->max * sizeof (task_t));
-        goto out_of_memory;
-    }
-    memset(tasks->queue, 0, tasks->max * sizeof (task_t));
-
-    callbacks = shm_malloc(sizeof (cdp_cb_list_t));
-    if (!callbacks) goto out_of_memory;
-    callbacks->head = 0;
-    callbacks->tail = 0;
-    return;
+	tasks = shm_malloc(sizeof (task_queue_t));
+
+	tasks->lock = lock_alloc();
+	tasks->lock = lock_init(tasks->lock);
+
+	sem_new(tasks->empty, 0);
+
+	sem_new(tasks->full, 1);
+
+	tasks->start = 0;
+	tasks->end = 0;
+	tasks->max = config->queue_length;
+	tasks->queue = shm_malloc(tasks->max * sizeof (task_t));
+	if (!tasks->queue) {
+		LOG_NO_MEM("shm", tasks->max * sizeof (task_t));
+		goto out_of_memory;
+	}
+	memset(tasks->queue, 0, tasks->max * sizeof (task_t));
+
+	callbacks = shm_malloc(sizeof (cdp_cb_list_t));
+	if (!callbacks) goto out_of_memory;
+	callbacks->head = 0;
+	callbacks->tail = 0;
+	return;
 out_of_memory:
-    if (tasks) {
-        if (tasks->lock) {
-            lock_destroy(tasks->lock);
-            lock_dealloc(&(tasks->lock));
-        }
-        sem_free(tasks->full);
-        sem_free(tasks->empty);
-        if (tasks->queue) shm_free(tasks->queue);
-        shm_free(tasks);
-    }
-    if (callbacks) shm_free(callbacks);
+	if (tasks) {
+		if (tasks->lock) {
+			lock_destroy(tasks->lock);
+			lock_dealloc(&(tasks->lock));
+		}
+		sem_free(tasks->full);
+		sem_free(tasks->empty);
+		if (tasks->queue) shm_free(tasks->queue);
+		shm_free(tasks);
+	}
+	if (callbacks) shm_free(callbacks);
 }
 
 /**
  * Destroys the worker structures.
  */
 void worker_destroy() {
-    int i, sval = 0;
-    if (callbacks) {
-        while (callbacks->head)
-            cb_remove(callbacks->head);
-        shm_free(callbacks);
-    }
-
-    // to deny runing the poison queue again
-    config->workers = 0;
-    if (tasks) {
-        lock_get(tasks->lock);
-        for (i = 0; i < tasks->max; i++) {
-            if (tasks->queue[i].msg) AAAFreeMessage(&(tasks->queue[i].msg));
-            tasks->queue[i].msg = 0;
-            tasks->queue[i].p = 0;
-        }
-        lock_release(tasks->lock);
-
-        LM_INFO("Unlocking workers waiting on empty queue...\n");
-        for (i = 0; i < config->workers; i++)
-            sem_release(tasks->empty);
-        LM_INFO("Unlocking workers waiting on full queue...\n");
-        i = 0;
-        while (sem_getvalue(tasks->full, &sval) == 0)
-            if (sval <= 0) {
-                sem_release(tasks->full);
-                i = 1;
-            } else break;
-        sleep(i);
-
-        lock_get(tasks->lock);
-        shm_free(tasks->queue);
-        lock_destroy(tasks->lock);
-        lock_dealloc((void*) tasks->lock);
-
-        //lock_release(tasks->empty);
-        sem_free(tasks->full);
-        sem_free(tasks->empty);
-
-        shm_free(tasks);
-    }
+	int i, sval = 0;
+	if (callbacks) {
+		while (callbacks->head)
+			cb_remove(callbacks->head);
+		shm_free(callbacks);
+	}
+
+	// to deny runing the poison queue again
+	config->workers = 0;
+	if (tasks) {
+		lock_get(tasks->lock);
+		for (i = 0; i < tasks->max; i++) {
+			if (tasks->queue[i].msg) AAAFreeMessage(&(tasks->queue[i].msg));
+			tasks->queue[i].msg = 0;
+			tasks->queue[i].p = 0;
+		}
+		lock_release(tasks->lock);
+
+		LM_INFO("Unlocking workers waiting on empty queue...\n");
+		for (i = 0; i < config->workers; i++)
+			sem_release(tasks->empty);
+		LM_INFO("Unlocking workers waiting on full queue...\n");
+		i = 0;
+		while (sem_getvalue(tasks->full, &sval) == 0)
+			if (sval <= 0) {
+				sem_release(tasks->full);
+				i = 1;
+			} else break;
+		sleep(i);
+
+		lock_get(tasks->lock);
+		shm_free(tasks->queue);
+		lock_destroy(tasks->lock);
+		lock_dealloc((void*) tasks->lock);
+
+		//lock_release(tasks->empty);
+		sem_free(tasks->full);
+		sem_free(tasks->empty);
+
+		shm_free(tasks);
+	}
 }
 
 /*unsafe*/
 int cb_add(cdp_cb_f cb, void *ptr) {
-    cdp_cb_t *x;
-    x = shm_malloc(sizeof (cdp_cb_t));
-    if (!x) {
-        LOG_NO_MEM("shm", sizeof (cdp_cb_t));
-        return 0;
-    }
-    x->cb = cb;
-    x->ptr = shm_malloc(sizeof (void*));
-    if (!x->ptr) {
-        LOG_NO_MEM("shm", sizeof (void*));
-        return 0;
-    }
-    *(x->ptr) = ptr;
-    x->next = 0;
-    x->prev = callbacks->tail;
-    if (callbacks->tail) callbacks->tail->next = x;
-    callbacks->tail = x;
-    if (!callbacks->head) callbacks->head = x;
-    return 1;
+	cdp_cb_t *x;
+	x = shm_malloc(sizeof (cdp_cb_t));
+	if (!x) {
+		LOG_NO_MEM("shm", sizeof (cdp_cb_t));
+		return 0;
+	}
+	x->cb = cb;
+	x->ptr = shm_malloc(sizeof (void*));
+	if (!x->ptr) {
+		LOG_NO_MEM("shm", sizeof (void*));
+		return 0;
+	}
+	*(x->ptr) = ptr;
+	x->next = 0;
+	x->prev = callbacks->tail;
+	if (callbacks->tail) callbacks->tail->next = x;
+	callbacks->tail = x;
+	if (!callbacks->head) callbacks->head = x;
+	return 1;
 }
 
 /*unsafe*/
 void cb_remove(cdp_cb_t *cb) {
-    cdp_cb_t *x;
-    x = callbacks->head;
-    while (x && x != cb) x = x->next;
-    if (!x) return;
-    if (x->prev) x->prev->next = x->next;
-    else callbacks->head = x->next;
-    if (x->next) x->next->prev = x->prev;
-    else callbacks->tail = x->prev;
-
-    if (x->ptr) shm_free(x->ptr);
-    shm_free(x);
+	cdp_cb_t *x;
+	x = callbacks->head;
+	while (x && x != cb) x = x->next;
+	if (!x) return;
+	if (x->prev) x->prev->next = x->next;
+	else callbacks->head = x->next;
+	if (x->next) x->next->prev = x->prev;
+	else callbacks->tail = x->prev;
+
+	if (x->ptr) shm_free(x->ptr);
+	shm_free(x);
 }
 
 /**
@@ -209,62 +207,64 @@ void cb_remove(cdp_cb_t *cb) {
  */
 int put_task(peer *p, AAAMessage *msg) {
 
-    struct timeval start, stop;
-    int num_tasks, length_percentage;
-    
-    long elapsed_useconds=0, elapsed_seconds=0, elapsed_millis=0;
-    lock_get(tasks->lock);
-
-    gettimeofday(&start, NULL);
-    while ((tasks->end + 1) % tasks->max == tasks->start) {
-        lock_release(tasks->lock);
-
-        if (*shutdownx) {
-            sem_release(tasks->full);
-            return 0;
-        }
-
-        sem_get(tasks->full);
-
-        if (*shutdownx) {
-            sem_release(tasks->full);
-            return 0;
-        }
-
-        lock_get(tasks->lock);
-    }
-    
-    counter_inc(cdp_cnts_h.queuelength);
-
-    gettimeofday(&stop, NULL);
-    elapsed_useconds = stop.tv_usec - start.tv_usec;
-    elapsed_seconds = stop.tv_sec - start.tv_sec;
-
-    elapsed_useconds = elapsed_seconds*1000000 + elapsed_useconds;
-    elapsed_millis = elapsed_useconds/1000;
-    if (elapsed_millis > workerq_latency_threshold) {
-        LM_ERR("took too long to put task into task queue > %d - [%ld]\n", workerq_latency_threshold, elapsed_millis);
-    }
-
-    tasks->queue[tasks->end].p = p;
-    tasks->queue[tasks->end].msg = msg;
-    tasks->end = (tasks->end + 1) % tasks->max;
-    if (sem_release(tasks->empty) < 0)
-        LM_WARN("Error releasing tasks->empty semaphore > %s!\n", strerror(errno));
-    lock_release(tasks->lock);
-
-    if(workerq_length_threshold_percentage > 0) {
-        num_tasks = tasks->end - tasks->start;
-	length_percentage = num_tasks/tasks->max*100;
-	if(length_percentage > workerq_length_threshold_percentage) {
-	    LM_WARN("Queue length has exceeded length threshold percentage [%i] and is length [%i]", length_percentage, num_tasks);
+	struct timeval start, stop;
+	int num_tasks, length_percentage;
+
+	long elapsed_useconds=0, elapsed_seconds=0, elapsed_millis=0;
+	lock_get(tasks->lock);
+
+	gettimeofday(&start, NULL);
+	while ((tasks->end + 1) % tasks->max == tasks->start) {
+		lock_release(tasks->lock);
+
+		if (*shutdownx) {
+			sem_release(tasks->full);
+			return 0;
+		}
+
+		sem_get(tasks->full);
+
+		if (*shutdownx) {
+			sem_release(tasks->full);
+			return 0;
+		}
+
+		lock_get(tasks->lock);
 	}
-    }
-    //int num_tasks = tasks->end - tasks->start;
-    //LM_ERR("Added task to task queue.  Queue length [%i]", num_tasks);
 
+	counter_inc(cdp_cnts_h.queuelength);
 
-    return 1;
+	gettimeofday(&stop, NULL);
+	elapsed_useconds = stop.tv_usec - start.tv_usec;
+	elapsed_seconds = stop.tv_sec - start.tv_sec;
+
+	elapsed_useconds = elapsed_seconds*1000000 + elapsed_useconds;
+	elapsed_millis = elapsed_useconds/1000;
+	if (elapsed_millis > workerq_latency_threshold) {
+		LM_ERR("took too long to put task into task queue > %d - [%ld]\n",
+				workerq_latency_threshold, elapsed_millis);
+	}
+
+	tasks->queue[tasks->end].p = p;
+	tasks->queue[tasks->end].msg = msg;
+	tasks->end = (tasks->end + 1) % tasks->max;
+	if (sem_release(tasks->empty) < 0)
+		LM_WARN("Error releasing tasks->empty semaphore > %s!\n", strerror(errno));
+	lock_release(tasks->lock);
+
+	if(workerq_length_threshold_percentage > 0) {
+		num_tasks = tasks->end - tasks->start;
+		length_percentage = num_tasks/tasks->max*100;
+		if(length_percentage > workerq_length_threshold_percentage) {
+			LM_WARN("Queue length has exceeded length threshold percentage"
+					" [%i] and is length [%i]", length_percentage, num_tasks);
+		}
+	}
+	//int num_tasks = tasks->end - tasks->start;
+	//LM_ERR("Added task to task queue.  Queue length [%i]", num_tasks);
+
+
+	return 1;
 }
 
 /**
@@ -273,36 +273,36 @@ int put_task(peer *p, AAAMessage *msg) {
  * @returns the first task from the queue or an empty task on error (eg. shutdown in progress)
  */
 task_t take_task() {
-    task_t t = {0, 0};
-    lock_get(tasks->lock);
-    while (tasks->start == tasks->end) {
-        lock_release(tasks->lock);
-        if (*shutdownx) {
-            sem_release(tasks->empty);
-            return t;
-        }
-        sem_get(tasks->empty);
-        if (*shutdownx) {
-            sem_release(tasks->empty);
-            return t;
-        }
-
-        lock_get(tasks->lock);
-    }
-
-    counter_add(cdp_cnts_h.queuelength, -1);
-    t = tasks->queue[tasks->start];
-    tasks->queue[tasks->start].msg = 0;
-    tasks->start = (tasks->start + 1) % tasks->max;
-    if (sem_release(tasks->full) < 0)
-        LM_WARN("Error releasing tasks->full semaphore > %s!\n", strerror(errno));
-    lock_release(tasks->lock);
-
-    //int num_tasks = tasks->end - tasks->start;
-    //LM_ERR("Taken task from task queue.  Queue length [%i]", num_tasks);
-
-
-    return t;
+	task_t t = {0, 0};
+	lock_get(tasks->lock);
+	while (tasks->start == tasks->end) {
+		lock_release(tasks->lock);
+		if (*shutdownx) {
+			sem_release(tasks->empty);
+			return t;
+		}
+		sem_get(tasks->empty);
+		if (*shutdownx) {
+			sem_release(tasks->empty);
+			return t;
+		}
+
+		lock_get(tasks->lock);
+	}
+
+	counter_add(cdp_cnts_h.queuelength, -1);
+	t = tasks->queue[tasks->start];
+	tasks->queue[tasks->start].msg = 0;
+	tasks->start = (tasks->start + 1) % tasks->max;
+	if (sem_release(tasks->full) < 0)
+		LM_WARN("Error releasing tasks->full semaphore > %s!\n", strerror(errno));
+	lock_release(tasks->lock);
+
+	//int num_tasks = tasks->end - tasks->start;
+	//LM_ERR("Taken task from task queue.  Queue length [%i]", num_tasks);
+
+
+	return t;
 }
 
 /**
@@ -311,11 +311,11 @@ task_t take_task() {
  * if a shutdown is in process and exit.
  */
 void worker_poison_queue() {
-    int i;
-    if (config->workers && tasks)
-        for (i = 0; i < config->workers; i++)
-            if (sem_release(tasks->empty) < 0)
-                LM_WARN("Error releasing tasks->empty semaphore > %s!\n", strerror(errno));
+	int i;
+	if (config->workers && tasks)
+		for (i = 0; i < config->workers; i++)
+			if (sem_release(tasks->empty) < 0)
+				LM_WARN("Error releasing tasks->empty semaphore > %s!\n", strerror(errno));
 }
 
 /**
@@ -325,45 +325,45 @@ void worker_poison_queue() {
  * @returns never, exits on shutdown.
  */
 void worker_process(int id) {
-    task_t t;
-    cdp_cb_t *cb;
-    int r;
-    LM_INFO("[%d] Worker process started...\n", id);
-    /* init the application level for this child */
-    while (1) {
-        if (shutdownx && (*shutdownx)) break;
-	cfg_update();
-        t = take_task();
-        if (!t.msg) {
-            if (shutdownx && (*shutdownx)) break;
-            LM_INFO("[%d] got empty task Q(%d/%d)\n", id, tasks->start, tasks->end);
-            continue;
-        }
-        LM_DBG("worker_process(): [%d] got task Q(%d/%d)\n", id, tasks->start, tasks->end);
-        r = is_req(t.msg);
-        for (cb = callbacks->head; cb; cb = cb->next)
-            (*(cb->cb))(t.p, t.msg, *(cb->ptr));
-
-        if (r) {
-            AAAFreeMessage(&(t.msg));
-        } else {
-            /* will be freed by the user in upper api */
-            /*AAAFreeMessage(&(t.msg));*/
-        }
-    }
-    worker_poison_queue();
-    LM_INFO("[%d]... Worker process finished\n", id);
+	task_t t;
+	cdp_cb_t *cb;
+	int r;
+	LM_INFO("[%d] Worker process started...\n", id);
+	/* init the application level for this child */
+	while (1) {
+		if (shutdownx && (*shutdownx)) break;
+		cfg_update();
+		t = take_task();
+		if (!t.msg) {
+			if (shutdownx && (*shutdownx)) break;
+			LM_INFO("[%d] got empty task Q(%d/%d)\n", id, tasks->start, tasks->end);
+			continue;
+		}
+		LM_DBG("worker_process(): [%d] got task Q(%d/%d)\n", id, tasks->start, tasks->end);
+		r = is_req(t.msg);
+		for (cb = callbacks->head; cb; cb = cb->next)
+			(*(cb->cb))(t.p, t.msg, *(cb->ptr));
+
+		if (r) {
+			AAAFreeMessage(&(t.msg));
+		} else {
+			/* will be freed by the user in upper api */
+			/*AAAFreeMessage(&(t.msg));*/
+		}
+	}
+	worker_poison_queue();
+	LM_INFO("[%d]... Worker process finished\n", id);
 #ifdef CDP_FOR_SER
 #else
 #ifdef PKG_MALLOC
-    LM_DBG("Worker[%d] Memory status (pkg):\n", id);
-    //pkg_status();
+	LM_DBG("Worker[%d] Memory status (pkg):\n", id);
+	//pkg_status();
 #ifdef pkg_sums
-    pkg_sums();
+	pkg_sums();
 #endif
 #endif
-    dp_del_pid(getpid());
+	dp_del_pid(getpid());
 #endif
-    exit(0);
+	exit(0);
 }
 

+ 12 - 14
modules/cdp/worker.h

@@ -1,25 +1,23 @@
 /*
- * $Id$
- *
  * Copyright (C) 2012 Smile Communications, [email protected]
  * Copyright (C) 2012 Smile Communications, [email protected]
- * 
+ *
  * The initial version of this code was written by Dragos Vingarzan
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  * Fruanhofer Institute. It was and still is maintained in a separate
  * branch of the original SER. We are therefore migrating it to
  * Kamailio/SR and look forward to maintaining it from here on out.
  * 2011/2012 Smile Communications, Pty. Ltd.
- * ported/maintained/improved by 
+ * ported/maintained/improved by
  * Jason Penton (jason(dot)penton(at)smilecoms.com and
- * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  * effort to add full IMS support to Kamailio/SR using a new and
  * improved architecture
- * 
+ *
  * NB: Alot of this code was originally part of OpenIMSCore,
- * FhG Fokus. 
+ * FhG Fokus.
  * Copyright (C) 2004-2006 FhG Fokus
- * Thanks for great work! This is an effort to 
+ * Thanks for great work! This is an effort to
  * break apart the various CSCF functions into logically separate
  * components. We hope this will drive wider use. We also feel
  * that in this way the architecture is more complete and thereby easier
@@ -37,10 +35,10 @@
  * 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 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  */
 
 #ifndef __WORKER_H
@@ -53,7 +51,7 @@
 /** function to be called on worker initialization */
 typedef int (*worker_init_function)(int rank);
 
-/** task element */ 
+/** task element */
 typedef struct _task_t {
 	peer *p;			/**< peer that the message was received from */
 	AAAMessage *msg;	/**< diameter message received */
@@ -61,7 +59,7 @@ typedef struct _task_t {
 
 /** task queue */
 typedef struct {
-	gen_lock_t *lock;	/**< lock for task queue operations */ 
+	gen_lock_t *lock;	/**< lock for task queue operations */
 	int start;			/**< start position in the queue array (index of oldest task) */
 	int end;			/**< end position in the queue array (index of the youngest task) */
 	int max;			/**< size of the queue array */
@@ -80,7 +78,7 @@ typedef struct _cdp_cb_t{
 	struct _cdp_cb_t *next; 	/**< next callback in the list */
 	struct _cdp_cb_t *prev;		/**< previous callback in the list */
 } cdp_cb_t;
-	
+
 /** list of callback elements for message processing */
 typedef struct {
 	cdp_cb_t *head;	/**< first element in the list */

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است