[sr-dev] git:master:aaf3b2e3: siptrace: siptrace_copy_proto() converted to macro
Daniel-Constantin Mierla
miconda at gmail.com
Tue Jan 9 10:07:55 CET 2018
Module: kamailio
Branch: master
Commit: aaf3b2e35bf58ad19b2b375f26909b102b7d512f
URL: https://github.com/kamailio/kamailio/commit/aaf3b2e35bf58ad19b2b375f26909b102b7d512f
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-01-09T10:00:31+01:00
siptrace: siptrace_copy_proto() converted to macro
---
Modified: src/modules/siptrace/siptrace_send.c
Modified: src/modules/siptrace/siptrace_send.h
---
Diff: https://github.com/kamailio/kamailio/commit/aaf3b2e35bf58ad19b2b375f26909b102b7d512f.diff
Patch: https://github.com/kamailio/kamailio/commit/aaf3b2e35bf58ad19b2b375f26909b102b7d512f.patch
---
diff --git a/src/modules/siptrace/siptrace_send.c b/src/modules/siptrace/siptrace_send.c
index 0a57d3b1f7..eeb91c20c7 100644
--- a/src/modules/siptrace/siptrace_send.c
+++ b/src/modules/siptrace/siptrace_send.c
@@ -41,29 +41,6 @@ extern int *xheaders_read_flag;
extern str dup_uri_str;
extern sip_uri_t *dup_uri;
-/**
- *
- */
-int siptrace_copy_proto(int proto, char *buf)
-{
- if(buf == 0)
- return -1;
- if(proto == PROTO_TCP) {
- strcpy(buf, "tcp:");
- } else if(proto == PROTO_TLS) {
- strcpy(buf, "tls:");
- } else if(proto == PROTO_SCTP) {
- strcpy(buf, "sctp:");
- } else if(proto == PROTO_WS) {
- strcpy(buf, "ws:");
- } else if(proto == PROTO_WSS) {
- strcpy(buf, "wss:");
- } else {
- strcpy(buf, "udp:");
- }
- return 0;
-}
-
/**
*
*/
diff --git a/src/modules/siptrace/siptrace_send.h b/src/modules/siptrace/siptrace_send.h
index 288566b75a..a83eebad22 100644
--- a/src/modules/siptrace/siptrace_send.h
+++ b/src/modules/siptrace/siptrace_send.h
@@ -28,11 +28,46 @@
#include "../../core/ip_addr.h"
#include "siptrace_data.h"
-int siptrace_copy_proto(int proto, char *buf);
int sip_trace_prepare(sip_msg_t *msg);
int sip_trace_xheaders_write(struct _siptrace_data *sto);
int sip_trace_xheaders_read(struct _siptrace_data *sto);
int sip_trace_xheaders_free(struct _siptrace_data *sto);
int trace_send_duplicate(char *buf, int len, struct dest_info *dst2);
+/**
+ *
+ */
+#define siptrace_copy_proto_olen(vproto, vbuf, vlen) do { \
+ switch(vproto) { \
+ case PROTO_TCP: \
+ strcpy(vbuf, "tcp:"); \
+ vlen = 4; \
+ break; \
+ case PROTO_TLS: \
+ strcpy(vbuf, "tls:"); \
+ vlen = 4; \
+ break; \
+ case PROTO_SCTP: \
+ strcpy(vbuf, "sctp:"); \
+ vlen = 5; \
+ break; \
+ case PROTO_WS: \
+ strcpy(vbuf, "ws:"); \
+ vlen = 3; \
+ break; \
+ case PROTO_WSS: \
+ strcpy(vbuf, "wss:"); \
+ vlen = 4; \
+ break; \
+ default: \
+ strcpy(vbuf, "udp:"); \
+ vlen = 4; \
+ } \
+ } while(0)
+
+#define siptrace_copy_proto(vproto, vbuf) do { \
+ int __olen; \
+ siptrace_copy_proto_olen(vproto, vbuf, __olen); \
+ } while(0)
+
#endif
More information about the sr-dev
mailing list