From ee604b6e7ac655ea55fbea153e854e70c6ef04af Mon Sep 17 00:00:00 2001 From: Minh Date: Thu, 21 Jul 2022 18:59:09 +0700 Subject: [PATCH 1/5] support capture_nodename --- libsofia-sip-ua/msg/msg_internal.h | 1 + libsofia-sip-ua/tport/tport_internal.h | 1 + libsofia-sip-ua/tport/tport_logging.c | 11 ++++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libsofia-sip-ua/msg/msg_internal.h b/libsofia-sip-ua/msg/msg_internal.h index 3b1ac9bb..27cbcd5d 100644 --- a/libsofia-sip-ua/msg/msg_internal.h +++ b/libsofia-sip-ua/msg/msg_internal.h @@ -231,6 +231,7 @@ struct hep_generic { hep_chunk_uint32_t time_usec; hep_chunk_uint8_t proto_t; hep_chunk_uint32_t capt_id; + hep_chunk_uint32_t capt_nodename; } PACKED; #ifdef _MSC_VER diff --git a/libsofia-sip-ua/tport/tport_internal.h b/libsofia-sip-ua/tport/tport_internal.h index e639ec60..eb4ebbeb 100644 --- a/libsofia-sip-ua/tport/tport_internal.h +++ b/libsofia-sip-ua/tport/tport_internal.h @@ -308,6 +308,7 @@ struct tport_master { tport_primary_t *mr_primaries; /**< List of primary contacts */ unsigned mr_prot_ver; /* hep version */ unsigned mr_agent_id; /* agent version */ + unsigned mr_agent_nodename; /* agent node name */ tport_params_t mr_params[1]; diff --git a/libsofia-sip-ua/tport/tport_logging.c b/libsofia-sip-ua/tport/tport_logging.c index 47f80316..0a3a55b9 100644 --- a/libsofia-sip-ua/tport/tport_logging.c +++ b/libsofia-sip-ua/tport/tport_logging.c @@ -191,7 +191,7 @@ int tport_open_log(tport_master_t *mr, tagi_t *tags) /* default values for capture protocol and agent id */ mr->mr_prot_ver = 3; mr->mr_agent_id = 200; - + mr->mr_agent_nodename = "default"; /* get all params */ while(p) { @@ -225,6 +225,10 @@ int tport_open_log(tport_master_t *mr, tagi_t *tags) return n; } } + else if(strncmp(p, "capture_nodename=", 17) == 0) { + p+=17; + mr->mr_agent_nodename = p; + } else { su_log("unsupported capture param\n"); return n; @@ -737,6 +741,11 @@ int tport_capt_msg_hepv3 (tport_t const *self, msg_t *msg, size_t n, hg->capt_id.data = htonl(mr->mr_agent_id); hg->capt_id.chunk.length = htons(sizeof(hg->capt_id)); + /* Capture NODE NAME */ + hg->capt_nodename.chunk.vendor_id = htons(0x0000); + hg->capt_nodename.chunk.type_id = htons(0x0013); + hg->capt_nodename.data = htonl(mr->mr_agent_nodename); + hg->capt_nodename.chunk.length = htons(sizeof(hg->capt_nodename)); /* Payload caclulation */ orig_n = n; From 1ba22f2dc6e7b2ccac7bef46e162bf490b98b982 Mon Sep 17 00:00:00 2001 From: Minh Date: Fri, 22 Jul 2022 16:12:37 +0700 Subject: [PATCH 2/5] type update --- libsofia-sip-ua/msg/msg_internal.h | 2 +- libsofia-sip-ua/tport/tport_logging.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libsofia-sip-ua/msg/msg_internal.h b/libsofia-sip-ua/msg/msg_internal.h index 27cbcd5d..8d650b40 100644 --- a/libsofia-sip-ua/msg/msg_internal.h +++ b/libsofia-sip-ua/msg/msg_internal.h @@ -231,7 +231,7 @@ struct hep_generic { hep_chunk_uint32_t time_usec; hep_chunk_uint8_t proto_t; hep_chunk_uint32_t capt_id; - hep_chunk_uint32_t capt_nodename; + hep_chunk_str_t capt_nodename; } PACKED; #ifdef _MSC_VER diff --git a/libsofia-sip-ua/tport/tport_logging.c b/libsofia-sip-ua/tport/tport_logging.c index 0a3a55b9..b20d9231 100644 --- a/libsofia-sip-ua/tport/tport_logging.c +++ b/libsofia-sip-ua/tport/tport_logging.c @@ -744,7 +744,7 @@ int tport_capt_msg_hepv3 (tport_t const *self, msg_t *msg, size_t n, /* Capture NODE NAME */ hg->capt_nodename.chunk.vendor_id = htons(0x0000); hg->capt_nodename.chunk.type_id = htons(0x0013); - hg->capt_nodename.data = htonl(mr->mr_agent_nodename); + hg->capt_nodename.data = mr->mr_agent_nodename; hg->capt_nodename.chunk.length = htons(sizeof(hg->capt_nodename)); /* Payload caclulation */ From f9bb86dd5585466f71a11f52b7fadab201188b8d Mon Sep 17 00:00:00 2001 From: Minh Date: Fri, 22 Jul 2022 17:16:51 +0700 Subject: [PATCH 3/5] type update --- libsofia-sip-ua/tport/tport_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsofia-sip-ua/tport/tport_internal.h b/libsofia-sip-ua/tport/tport_internal.h index eb4ebbeb..8688b9e1 100644 --- a/libsofia-sip-ua/tport/tport_internal.h +++ b/libsofia-sip-ua/tport/tport_internal.h @@ -308,7 +308,7 @@ struct tport_master { tport_primary_t *mr_primaries; /**< List of primary contacts */ unsigned mr_prot_ver; /* hep version */ unsigned mr_agent_id; /* agent version */ - unsigned mr_agent_nodename; /* agent node name */ + char mr_agent_nodename; /* agent node name */ tport_params_t mr_params[1]; From 84a8696690d3f0d4484cf6365a8fbb0fa93d91f7 Mon Sep 17 00:00:00 2001 From: Minh Date: Fri, 22 Jul 2022 19:09:58 +0700 Subject: [PATCH 4/5] move capname to body --- libsofia-sip-ua/msg/msg_internal.h | 1 - libsofia-sip-ua/tport/tport_logging.c | 20 +++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/libsofia-sip-ua/msg/msg_internal.h b/libsofia-sip-ua/msg/msg_internal.h index 8d650b40..3b1ac9bb 100644 --- a/libsofia-sip-ua/msg/msg_internal.h +++ b/libsofia-sip-ua/msg/msg_internal.h @@ -231,7 +231,6 @@ struct hep_generic { hep_chunk_uint32_t time_usec; hep_chunk_uint8_t proto_t; hep_chunk_uint32_t capt_id; - hep_chunk_str_t capt_nodename; } PACKED; #ifdef _MSC_VER diff --git a/libsofia-sip-ua/tport/tport_logging.c b/libsofia-sip-ua/tport/tport_logging.c index b20d9231..a5f7595a 100644 --- a/libsofia-sip-ua/tport/tport_logging.c +++ b/libsofia-sip-ua/tport/tport_logging.c @@ -604,6 +604,7 @@ int tport_capt_msg_hepv3 (tport_t const *self, msg_t *msg, size_t n, su_time_t now; hep_chunk_ip4_t src_ip4 = {{0}}, dst_ip4 = {{0}}; hep_chunk_t payload_chunk; + hep_chunk_t nodename_chunk; int orig_n = 0; #if SU_HAVE_IN6 @@ -741,11 +742,6 @@ int tport_capt_msg_hepv3 (tport_t const *self, msg_t *msg, size_t n, hg->capt_id.data = htonl(mr->mr_agent_id); hg->capt_id.chunk.length = htons(sizeof(hg->capt_id)); - /* Capture NODE NAME */ - hg->capt_nodename.chunk.vendor_id = htons(0x0000); - hg->capt_nodename.chunk.type_id = htons(0x0013); - hg->capt_nodename.data = mr->mr_agent_nodename; - hg->capt_nodename.chunk.length = htons(sizeof(hg->capt_nodename)); /* Payload caclulation */ orig_n = n; @@ -766,6 +762,13 @@ int tport_capt_msg_hepv3 (tport_t const *self, msg_t *msg, size_t n, tlen = sizeof(struct hep_generic) + payload_len + iplen + sizeof(hep_chunk_t); + /* NODE NAME */ + tlen += sizeof(hep_chunk_t); + nodename_chunk.vendor_id = htons(0x0000); + nodename_chunk.type_id = htons(0x0013); + nodename_chunk.length = htons(sizeof(nodename_chunk) + strlen(mr->mr_agent_nodename)); + tlen += strlen(mr->mr_agent_nodename); + /* total */ hg->header.length = htons(tlen); @@ -800,6 +803,13 @@ int tport_capt_msg_hepv3 (tport_t const *self, msg_t *msg, size_t n, } #endif + /* NODE NAME */ + memcpy((void*) buffer + buflen, &nodename_chunk, sizeof(struct hep_chunk)); + buflen += sizeof(struct hep_chunk); + /* Now copying payload self */ + memcpy((void*) buffer + buflen, mr->mr_agent_nodename, strlen(mr->mr_agent_nodename)); + buflen += strlen(mr->mr_agent_nodename); + /* PAYLOAD CHUNK */ memcpy((char*) *buffer+buflen, &payload_chunk, sizeof(struct hep_chunk)); buflen += sizeof(struct hep_chunk); From b9f9e8119571d1171b8a1ddaee16f15298478da7 Mon Sep 17 00:00:00 2001 From: Minh Date: Fri, 22 Jul 2022 19:25:42 +0700 Subject: [PATCH 5/5] pointer --- libsofia-sip-ua/tport/tport_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsofia-sip-ua/tport/tport_internal.h b/libsofia-sip-ua/tport/tport_internal.h index 8688b9e1..b7cd98f2 100644 --- a/libsofia-sip-ua/tport/tport_internal.h +++ b/libsofia-sip-ua/tport/tport_internal.h @@ -308,7 +308,7 @@ struct tport_master { tport_primary_t *mr_primaries; /**< List of primary contacts */ unsigned mr_prot_ver; /* hep version */ unsigned mr_agent_id; /* agent version */ - char mr_agent_nodename; /* agent node name */ + char *mr_agent_nodename; /* agent node name */ tport_params_t mr_params[1];