[sr-dev] git:master: core: merged proto id to name functions

Daniel-Constantin Mierla miconda at gmail.com
Thu Dec 15 13:04:02 CET 2011


Module: sip-router
Branch: master
Commit: a077f5e104fe92a1b3ea51dbf00589fc77c9666c
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a077f5e104fe92a1b3ea51dbf00589fc77c9666c

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Thu Dec 15 13:01:51 2011 +0100

core: merged proto id to name functions

---

 dst_blacklist.c |   18 ------------------
 forward.c       |    8 ++++++++
 forward.h       |    1 +
 ip_addr.c       |    7 +++----
 ip_addr.h       |    3 ++-
 socket_info.c   |   16 ++++++++--------
 6 files changed, 22 insertions(+), 31 deletions(-)

diff --git a/dst_blacklist.c b/dst_blacklist.c
index 0f7351d..024114d 100644
--- a/dst_blacklist.c
+++ b/dst_blacklist.c
@@ -937,24 +937,6 @@ void dst_blst_mem_info(rpc_t* rpc, void* ctx)
 
 
 
-static char* get_proto_name(unsigned char proto)
-{
-	switch(proto){
-		case PROTO_NONE:
-			return "*";
-		case PROTO_UDP:
-			return "udp";
-		case PROTO_TCP:
-			return "tcp";
-		case PROTO_TLS:
-			return "tls";
-		case PROTO_SCTP:
-			return "sctp";
-		default:
-			return "unknown";
-	}
-}
-
 
 #ifdef USE_DST_BLACKLIST_STATS
 
diff --git a/forward.c b/forward.c
index 690ff47..d3ecb00 100644
--- a/forward.c
+++ b/forward.c
@@ -399,6 +399,14 @@ static struct _check_self_func {
 	struct _check_self_func *next;
 } *_check_self_func_list = NULL;
 
+/* check if _check_self_func_list is set
+ * - return 1 if yes, 0 if no
+ */
+int is_check_self_func_list_set(void)
+{
+	return (_check_self_func_list)?1:0;
+}
+
 /* register a function to be called when matching for myself
  * - return 0 on success, -1 on error
  * - f must have same prototype as check_self() and return same kind of values
diff --git a/forward.h b/forward.h
index 7600535..674a6f0 100644
--- a/forward.h
+++ b/forward.h
@@ -105,6 +105,7 @@ int update_sock_struct_from_via( union sockaddr_union* to,
 
 int forward_reply( struct sip_msg* msg);
 
+int is_check_self_func_list_set(void);
 
 
 /* params:
diff --git a/ip_addr.c b/ip_addr.c
index 502b4ea..06c57c3 100644
--- a/ip_addr.c
+++ b/ip_addr.c
@@ -337,7 +337,7 @@ int is_mcast(struct ip_addr* ip)
  * @param proto - protocol number
  * @return  string with the protocol name or "unknown".
  */
-char* proto2a(enum sip_protos proto)
+char* get_proto_name(unsigned int proto)
 {
 	switch(proto){
 		case PROTO_NONE:
@@ -350,8 +350,7 @@ char* proto2a(enum sip_protos proto)
 			return "tls";
 		case PROTO_SCTP:
 			return "sctp";
-		case PROTO_OTHER:
-			return "other";
+		default:
+			return "unknown";
 	}
-	return "unknown";
 }
diff --git a/ip_addr.h b/ip_addr.h
index 86c2502..0c1a129 100644
--- a/ip_addr.h
+++ b/ip_addr.h
@@ -250,7 +250,8 @@ void print_ip(char* prefix, struct ip_addr* ip, char* suffix);
 void stdout_print_ip(struct ip_addr* ip);
 void print_net(struct net* net);
 
-char* proto2a(enum sip_protos proto);
+char* get_proto_name(unsigned int proto);
+#define proto2a get_proto_name
 
 
 
diff --git a/socket_info.c b/socket_info.c
index 09aba4d..c0303b0 100644
--- a/socket_info.c
+++ b/socket_info.c
@@ -282,7 +282,7 @@ static void free_sock_info(struct socket_info* si)
 
 
 
-static char* get_proto_name(unsigned short proto)
+static char* get_valid_proto_name(unsigned short proto)
 {
 	switch(proto){
 		case PROTO_NONE:
@@ -325,7 +325,7 @@ int socket2str(char* s, int* len, struct socket_info* si)
 	str proto;
 	int l;
 	
-	proto.s = get_proto_name(si->proto);
+	proto.s = get_valid_proto_name(si->proto);
 	proto.len = strlen(proto.s);
 	
 	l = proto.len + si->address_str.len + si->port_no_str.len + 2;
@@ -1650,7 +1650,7 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
 			){
 			if (si->flags & SI_IS_MCAST){
 				LOG(L_WARN, "WARNING: removing entry %s:%s [%s]:%s\n",
-					get_proto_name(si->proto), si->name.s, 
+					get_valid_proto_name(si->proto), si->name.s, 
 					si->address_str.s, si->port_no_str.s);
 				l = si;
 				si=si->next;
@@ -1662,7 +1662,7 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
 					if (ail->flags & SI_IS_MCAST){
 						LOG(L_WARN, "WARNING: removing mh entry %s:%s"
 								" [%s]:%s\n",
-								get_proto_name(si->proto), ail->name.s, 
+								get_valid_proto_name(si->proto), ail->name.s, 
 								ail->address_str.s, si->port_no_str.s);
 						tmp_ail=ail;
 						ail=ail->next;
@@ -1866,7 +1866,7 @@ void print_all_socket_lists()
 		for(si=list?*list:0; si; si=si->next){
 			if (si->addr_info_lst){
 				printf("             %s: (%s",
-						get_proto_name(proto),
+						get_valid_proto_name(proto),
 						si->address_str.s);
 				for (ai=si->addr_info_lst; ai; ai=ai->next)
 					printf(", %s", ai->address_str.s);
@@ -1876,7 +1876,7 @@ void print_all_socket_lists()
 						si->flags & SI_IS_MHOMED? " mhomed" : "");
 			}else{
 				printf("             %s: %s",
-						get_proto_name(proto),
+						get_valid_proto_name(proto),
 						si->name.s);
 				if (!si->flags & SI_IS_IP)
 					printf(" [%s]", si->address_str.s);
@@ -1896,10 +1896,10 @@ void print_aliases()
 
 	for(a=aliases; a; a=a->next) 
 		if (a->port)
-			printf("             %s: %.*s:%d\n", get_proto_name(a->proto), 
+			printf("             %s: %.*s:%d\n", get_valid_proto_name(a->proto), 
 					a->alias.len, a->alias.s, a->port);
 		else
-			printf("             %s: %.*s:*\n", get_proto_name(a->proto), 
+			printf("             %s: %.*s:*\n", get_valid_proto_name(a->proto), 
 					a->alias.len, a->alias.s);
 }
 




More information about the sr-dev mailing list