Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homer capture support nodename #178

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libsofia-sip-ua/tport/tport_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
char *mr_agent_nodename; /* agent node name */

tport_params_t mr_params[1];

Expand Down
21 changes: 20 additions & 1 deletion libsofia-sip-ua/tport/tport_logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -600,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
Expand Down Expand Up @@ -757,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);

Expand Down Expand Up @@ -791,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);
Expand Down