Module: kamailio
Branch: master
Commit: 83c370414cb288b113ad4f075a2261e7d701d6d3
URL:
https://github.com/kamailio/kamailio/commit/83c370414cb288b113ad4f075a2261e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-11-17T11:02:04+01:00
core: udp - print up to first 100 chars from received packet
---
Modified: src/core/udp_server.c
---
Diff:
https://github.com/kamailio/kamailio/commit/83c370414cb288b113ad4f075a2261e…
Patch:
https://github.com/kamailio/kamailio/commit/83c370414cb288b113ad4f075a2261e…
---
diff --git a/src/core/udp_server.c b/src/core/udp_server.c
index 5262162362..0392136385 100644
--- a/src/core/udp_server.c
+++ b/src/core/udp_server.c
@@ -425,6 +425,10 @@ int udp_rcv_loop()
unsigned int fromlen;
struct receive_info ri;
sr_event_param_t evp = {0};
+ char printbuf[512];
+ int i;
+ int j;
+ int l;
from=(union sockaddr_union*) pkg_malloc(sizeof(union sockaddr_union));
@@ -466,6 +470,23 @@ int udp_rcv_loop()
/* we must 0-term the messages, receive_msg expects it */
buf[len]=0; /* no need to save the previous char */
+ if(is_printable(L_DBG) && len>10) {
+ j = 0;
+ for(i=0; i<len && i<100; i++) {
+ if(isprint(buf[i])) {
+ printbuf[j++] = buf[i];
+ } else {
+ l = snprintf(printbuf+j, 6, " %02X ", buf[i]);
+ if(l<0 || l>=6) {
+ LM_ERR("print buffer building failed\n");
+ goto error;
+ }
+ j += l;
+ }
+ }
+ LM_DBG("received on udp socket: (%d/%d) [[%.*s]]\n",
+ j, len, len, printbuf);
+ }
ri.src_su=*from;
su2ip_addr(&ri.src_ip, from);
ri.src_port=su_getport(from);