Skip to content

Commit

Permalink
siptrace: siptrace_copy_proto() converted to macro
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Jan 9, 2018
1 parent ed4a2bc commit aaf3b2e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
23 changes: 0 additions & 23 deletions src/modules/siptrace/siptrace_send.c
Expand Up @@ -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;
}

/**
*
*/
Expand Down
37 changes: 36 additions & 1 deletion src/modules/siptrace/siptrace_send.h
Expand Up @@ -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

0 comments on commit aaf3b2e

Please sign in to comment.