From 5b18c3415478e5f610199f63ba8d221d3e48f472 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Wed, 17 May 2023 16:37:13 +0200 Subject: [PATCH] sipdump: clang-format for coherent indentation and coding style --- src/modules/sipdump/sipdump_mod.c | 207 +++++++++++++++------------- src/modules/sipdump/sipdump_pcap.c | 166 ++++++++++++---------- src/modules/sipdump/sipdump_write.c | 174 +++++++++++------------ src/modules/sipdump/sipdump_write.h | 14 +- 4 files changed, 291 insertions(+), 270 deletions(-) diff --git a/src/modules/sipdump/sipdump_mod.c b/src/modules/sipdump/sipdump_mod.c index 8e871cc9804..8201ab11e47 100644 --- a/src/modules/sipdump/sipdump_mod.c +++ b/src/modules/sipdump/sipdump_mod.c @@ -57,7 +57,7 @@ static int sipdump_fage = 0; static int sipdump_event_route_idx = -1; -static void sipdump_storage_clean(unsigned int ticks, void* param); +static void sipdump_storage_clean(unsigned int ticks, void *param); static int mod_init(void); static int child_init(int); @@ -69,8 +69,7 @@ int sipdump_msg_received(sr_event_param_t *evp); int sipdump_msg_sent(sr_event_param_t *evp); int pv_parse_sipdump_name(pv_spec_t *sp, str *in); -int pv_get_sipdump(sip_msg_t *msg, pv_param_t *param, - pv_value_t *res); +int pv_get_sipdump(sip_msg_t *msg, pv_param_t *param, pv_value_t *res); /* clang-format off */ static cmd_export_t cmds[]={ @@ -120,13 +119,14 @@ struct module_exports exports = { */ static int mod_init(void) { - if(!(sipdump_mode & (SIPDUMP_MODE_WTEXT |SIPDUMP_MODE_WPCAP - | SIPDUMP_MODE_EVROUTE))) { + if(!(sipdump_mode + & (SIPDUMP_MODE_WTEXT | SIPDUMP_MODE_WPCAP + | SIPDUMP_MODE_EVROUTE))) { LM_ERR("invalid mode parameter\n"); return -1; } - if(sipdump_rpc_init()<0) { + if(sipdump_rpc_init() < 0) { LM_ERR("failed to register rpc commands\n"); return -1; } @@ -143,21 +143,22 @@ static int mod_init(void) if(sipdump_mode & SIPDUMP_MODE_EVROUTE) { sipdump_event_route_idx = route_lookup(&event_rt, "sipdump:msg"); - if (sipdump_event_route_idx>=0 && event_rt.rlist[sipdump_event_route_idx]==0) { + if(sipdump_event_route_idx >= 0 + && event_rt.rlist[sipdump_event_route_idx] == 0) { sipdump_event_route_idx = -1; /* disable */ } - if(faked_msg_init() <0) { + if(faked_msg_init() < 0) { LM_ERR("cannot initialize faked msg structure\n"); return -1; } } - if(sipdump_mode & (SIPDUMP_MODE_WTEXT|SIPDUMP_MODE_WPCAP)) { + if(sipdump_mode & (SIPDUMP_MODE_WTEXT | SIPDUMP_MODE_WPCAP)) { register_basic_timers(1); } - if(sipdump_fage>0) { - if(sr_wtimer_add(sipdump_storage_clean, NULL, 600)<0) { + if(sipdump_fage > 0) { + if(sr_wtimer_add(sipdump_storage_clean, NULL, 600) < 0) { return -1; } } @@ -177,13 +178,13 @@ static int child_init(int rank) if(rank != PROC_MAIN) return 0; - if(!(sipdump_mode & (SIPDUMP_MODE_WTEXT|SIPDUMP_MODE_WPCAP))) { + if(!(sipdump_mode & (SIPDUMP_MODE_WTEXT | SIPDUMP_MODE_WPCAP))) { return 0; } if(fork_basic_utimer(PROC_TIMER, "SIPDUMP WRITE TIMER", 1 /*socks flag*/, sipdump_timer_exec, NULL, sipdump_wait /*usec*/) - < 0) { + < 0) { LM_ERR("failed to register timer routine as process\n"); return -1; /* error */ } @@ -211,7 +212,7 @@ int ki_sipdump_send(sip_msg_t *msg, str *stag) if(!sipdump_enabled()) return 1; - if(!(sipdump_mode & (SIPDUMP_MODE_WTEXT|SIPDUMP_MODE_WPCAP))) { + if(!(sipdump_mode & (SIPDUMP_MODE_WTEXT | SIPDUMP_MODE_WPCAP))) { LM_WARN("writing to file is disabled - ignoring\n"); return 1; } @@ -226,13 +227,13 @@ int ki_sipdump_send(sip_msg_t *msg, str *stag) isd.tag = *stag; isd.protoid = msg->rcv.proto; isd.afid = msg->rcv.src_ip.af; - isd.src_ip.len = ip_addr2sbuf(&msg->rcv.src_ip, srcip_buf, - IP_ADDR_MAX_STRZ_SIZE); + isd.src_ip.len = + ip_addr2sbuf(&msg->rcv.src_ip, srcip_buf, IP_ADDR_MAX_STRZ_SIZE); srcip_buf[isd.src_ip.len] = 0; isd.src_ip.s = srcip_buf; isd.src_port = msg->rcv.src_port; - if(msg->rcv.bind_address==NULL - || msg->rcv.bind_address->address_str.s==NULL) { + if(msg->rcv.bind_address == NULL + || msg->rcv.bind_address->address_str.s == NULL) { if(msg->rcv.src_ip.af == AF_INET6) { isd.dst_ip.len = 3; isd.dst_ip.s = "::2"; @@ -246,12 +247,12 @@ int ki_sipdump_send(sip_msg_t *msg, str *stag) isd.dst_port = (int)msg->rcv.bind_address->port_no; } - if(sipdump_data_clone(&isd, &osd)<0) { + if(sipdump_data_clone(&isd, &osd) < 0) { LM_ERR("failed to clone sipdump data\n"); return -1; } - if(sipdump_list_add(osd)<0) { + if(sipdump_list_add(osd) < 0) { LM_ERR("failed to add data to dump queue\n"); return -1; } @@ -268,7 +269,7 @@ static int w_sipdump_send(sip_msg_t *msg, char *ptag, char *str2) if(!sipdump_enabled()) return 1; - if(fixup_get_svalue(msg, (gparam_t*)ptag, &stag)<0) { + if(fixup_get_svalue(msg, (gparam_t *)ptag, &stag) < 0) { LM_ERR("failed to get tag parameter\n"); return -1; } @@ -278,12 +279,12 @@ static int w_sipdump_send(sip_msg_t *msg, char *ptag, char *str2) /** * */ -static sipdump_data_t* sipdump_event_data = NULL; +static sipdump_data_t *sipdump_event_data = NULL; /** * */ -int sipdump_event_route(sipdump_data_t* sdi) +int sipdump_event_route(sipdump_data_t *sdi) { int backup_rt; run_act_ctx_t ctx; @@ -298,15 +299,15 @@ int sipdump_event_route(sipdump_data_t* sdi) fmsg = faked_msg_next(); sipdump_event_data = sdi; - if(sipdump_event_route_idx>=0) { + if(sipdump_event_route_idx >= 0) { run_top_route(event_rt.rlist[sipdump_event_route_idx], fmsg, 0); } else { keng = sr_kemi_eng_get(); - if (keng!=NULL) { + if(keng != NULL) { bctx = sr_kemi_act_ctx_get(); sr_kemi_act_ctx_set(&ctx); - (void)sr_kemi_route(keng, fmsg, EVENT_ROUTE, - &sipdump_event_callback, &evname); + (void)sr_kemi_route( + keng, fmsg, EVENT_ROUTE, &sipdump_event_callback, &evname); sr_kemi_act_ctx_set(bctx); } } @@ -333,21 +334,23 @@ int sipdump_msg_received(sr_event_param_t *evp) memset(&isd, 0, sizeof(sipdump_data_t)); gettimeofday(&isd.tv, NULL); - isd.data = *((str*)evp->data); + isd.data = *((str *)evp->data); isd.tag.s = "rcv"; isd.tag.len = 3; isd.pid = my_pid(); isd.procno = process_no; isd.protoid = evp->rcv->proto; - isd.afid = (evp->rcv->bind_address!=NULL - && evp->rcv->bind_address->address.af==AF_INET6)?AF_INET6:AF_INET; - isd.src_ip.len = ip_addr2sbuf(&evp->rcv->src_ip, srcip_buf, - IP_ADDR_MAX_STRZ_SIZE); + isd.afid = (evp->rcv->bind_address != NULL + && evp->rcv->bind_address->address.af == AF_INET6) + ? AF_INET6 + : AF_INET; + isd.src_ip.len = + ip_addr2sbuf(&evp->rcv->src_ip, srcip_buf, IP_ADDR_MAX_STRZ_SIZE); srcip_buf[isd.src_ip.len] = '\0'; isd.src_ip.s = srcip_buf; isd.src_port = evp->rcv->src_port; - if(evp->rcv->bind_address==NULL - || evp->rcv->bind_address->address_str.s==NULL) { + if(evp->rcv->bind_address == NULL + || evp->rcv->bind_address->address_str.s == NULL) { if(isd.afid == AF_INET6) { isd.dst_ip.len = 3; isd.dst_ip.s = "::2"; @@ -368,16 +371,16 @@ int sipdump_msg_received(sr_event_param_t *evp) } } - if(!(sipdump_mode & (SIPDUMP_MODE_WTEXT|SIPDUMP_MODE_WPCAP))) { + if(!(sipdump_mode & (SIPDUMP_MODE_WTEXT | SIPDUMP_MODE_WPCAP))) { return 0; } - if(sipdump_data_clone(&isd, &osd)<0) { + if(sipdump_data_clone(&isd, &osd) < 0) { LM_ERR("failed to close sipdump data\n"); return -1; } - if(sipdump_list_add(osd)<0) { + if(sipdump_list_add(osd) < 0) { LM_ERR("failed to add data to dump queue\n"); return -1; } @@ -400,7 +403,7 @@ int sipdump_msg_sent(sr_event_param_t *evp) memset(&isd, 0, sizeof(sipdump_data_t)); gettimeofday(&isd.tv, NULL); - isd.data = *((str*)evp->data); + isd.data = *((str *)evp->data); isd.tag.s = "snd"; isd.tag.len = 3; isd.pid = my_pid(); @@ -408,7 +411,8 @@ int sipdump_msg_sent(sr_event_param_t *evp) isd.protoid = evp->dst->proto; isd.afid = evp->dst->send_sock->address.af; - if(evp->dst->send_sock==NULL || evp->dst->send_sock->address_str.s==NULL) { + if(evp->dst->send_sock == NULL + || evp->dst->send_sock->address_str.s == NULL) { if(evp->dst->send_sock->address.af == AF_INET6) { isd.src_ip.len = 3; isd.src_ip.s = "::2"; @@ -431,16 +435,16 @@ int sipdump_msg_sent(sr_event_param_t *evp) sipdump_event_route(&isd); } - if(!(sipdump_mode & (SIPDUMP_MODE_WTEXT|SIPDUMP_MODE_WPCAP))) { + if(!(sipdump_mode & (SIPDUMP_MODE_WTEXT | SIPDUMP_MODE_WPCAP))) { return 0; } - if(sipdump_data_clone(&isd, &osd)<0) { + if(sipdump_data_clone(&isd, &osd) < 0) { LM_ERR("failed to clone sipdump data\n"); return -1; } - if(sipdump_list_add(osd)<0) { + if(sipdump_list_add(osd) < 0) { LM_ERR("failed to add data to dump queue\n"); return -1; } @@ -450,7 +454,7 @@ int sipdump_msg_sent(sr_event_param_t *evp) /** * */ -static void sipdump_storage_clean(unsigned int ticks, void* param) +static void sipdump_storage_clean(unsigned int ticks, void *param) { DIR *dlist = NULL; struct stat fstatbuf; @@ -460,60 +464,65 @@ static void sipdump_storage_clean(unsigned int ticks, void* param) time_t tnow; int fcount = 0; - if(sipdump_folder.s==NULL || sipdump_folder.len<=0 - || sipdump_fprefix.s==NULL || sipdump_fprefix.len<=0) { + if(sipdump_folder.s == NULL || sipdump_folder.len <= 0 + || sipdump_fprefix.s == NULL || sipdump_fprefix.len <= 0) { return; } cwd = getcwd(NULL, 0); - if(cwd==NULL) { + if(cwd == NULL) { LM_ERR("getcwd failed\n"); return; } - if ((chdir(sipdump_folder.s)==-1)) { + if((chdir(sipdump_folder.s) == -1)) { LM_ERR("chdir to [%s] failed\n", sipdump_folder.s); free(cwd); return; } dlist = opendir(sipdump_folder.s); - if (dlist==NULL) { + if(dlist == NULL) { LM_ERR("unable to read directory [%s]\n", sipdump_folder.s); goto done; } tnow = time(NULL); - while ((dentry = readdir(dlist))) { + while((dentry = readdir(dlist))) { fname.s = dentry->d_name; fname.len = strlen(fname.s); /* ignore '.' and '..' */ - if(fname.len==1 && strcmp(fname.s, ".")==0) { continue; } - if(fname.len==2 && strcmp(fname.s, "..")==0) { continue; } + if(fname.len == 1 && strcmp(fname.s, ".") == 0) { + continue; + } + if(fname.len == 2 && strcmp(fname.s, "..") == 0) { + continue; + } - if(fname.len<=sipdump_fprefix.len - || strncmp(fname.s, sipdump_fprefix.s, sipdump_fprefix.len)!=0) { + if(fname.len <= sipdump_fprefix.len + || strncmp(fname.s, sipdump_fprefix.s, sipdump_fprefix.len) + != 0) { continue; } if(lstat(fname.s, &fstatbuf) == -1) { LM_ERR("stat failed on [%s]\n", fname.s); continue; } - if (S_ISREG(fstatbuf.st_mode)) { + if(S_ISREG(fstatbuf.st_mode)) { /* check last modification time */ - if ((tnow - sipdump_fage) > fstatbuf.st_mtime) { + if((tnow - sipdump_fage) > fstatbuf.st_mtime) { LM_DBG("deleting [%s]\n", fname.s); - unlink (fname.s); + unlink(fname.s); fcount++; } } } closedir(dlist); - if(fcount>0) { + if(fcount > 0) { LM_DBG("deleted %d files\n", fcount); } done: - if((chdir(cwd)==-1)) { + if((chdir(cwd) == -1)) { LM_ERR("chdir to [%s] failed\n", cwd); goto done; } @@ -528,11 +537,11 @@ static sr_kemi_xval_t _ksr_kemi_sipdump_xval = {0}; /** * */ -static sr_kemi_xval_t* ki_sipdump_get_buf(sip_msg_t *msg) +static sr_kemi_xval_t *ki_sipdump_get_buf(sip_msg_t *msg) { memset(&_ksr_kemi_sipdump_xval, 0, sizeof(sr_kemi_xval_t)); - if (sipdump_event_data==NULL) { + if(sipdump_event_data == NULL) { sr_kemi_xval_null(&_ksr_kemi_sipdump_xval, SR_KEMI_XVAL_NULL_EMPTY); return &_ksr_kemi_sipdump_xval; } @@ -544,11 +553,11 @@ static sr_kemi_xval_t* ki_sipdump_get_buf(sip_msg_t *msg) /** * */ -static sr_kemi_xval_t* ki_sipdump_get_tag(sip_msg_t *msg) +static sr_kemi_xval_t *ki_sipdump_get_tag(sip_msg_t *msg) { memset(&_ksr_kemi_sipdump_xval, 0, sizeof(sr_kemi_xval_t)); - if (sipdump_event_data==NULL) { + if(sipdump_event_data == NULL) { sr_kemi_xval_null(&_ksr_kemi_sipdump_xval, SR_KEMI_XVAL_NULL_EMPTY); return &_ksr_kemi_sipdump_xval; } @@ -560,11 +569,11 @@ static sr_kemi_xval_t* ki_sipdump_get_tag(sip_msg_t *msg) /** * */ -static sr_kemi_xval_t* ki_sipdump_get_src_ip(sip_msg_t *msg) +static sr_kemi_xval_t *ki_sipdump_get_src_ip(sip_msg_t *msg) { memset(&_ksr_kemi_sipdump_xval, 0, sizeof(sr_kemi_xval_t)); - if (sipdump_event_data==NULL) { + if(sipdump_event_data == NULL) { sr_kemi_xval_null(&_ksr_kemi_sipdump_xval, SR_KEMI_XVAL_NULL_EMPTY); return &_ksr_kemi_sipdump_xval; } @@ -576,11 +585,11 @@ static sr_kemi_xval_t* ki_sipdump_get_src_ip(sip_msg_t *msg) /** * */ -static sr_kemi_xval_t* ki_sipdump_get_dst_ip(sip_msg_t *msg) +static sr_kemi_xval_t *ki_sipdump_get_dst_ip(sip_msg_t *msg) { memset(&_ksr_kemi_sipdump_xval, 0, sizeof(sr_kemi_xval_t)); - if (sipdump_event_data==NULL) { + if(sipdump_event_data == NULL) { sr_kemi_xval_null(&_ksr_kemi_sipdump_xval, SR_KEMI_XVAL_NULL_EMPTY); return &_ksr_kemi_sipdump_xval; } @@ -629,46 +638,50 @@ static sr_kemi_t sr_kemi_sipdump_exports[] = { */ int pv_parse_sipdump_name(pv_spec_t *sp, str *in) { - if(sp==NULL || in==NULL || in->len<=0) + if(sp == NULL || in == NULL || in->len <= 0) return -1; - switch(in->len) - { + switch(in->len) { case 2: - if(strncmp(in->s, "af", 2)==0) + if(strncmp(in->s, "af", 2) == 0) sp->pvp.pvn.u.isname.name.n = 3; - else goto error; - break; + else + goto error; + break; case 3: - if(strncmp(in->s, "buf", 3)==0) + if(strncmp(in->s, "buf", 3) == 0) sp->pvp.pvn.u.isname.name.n = 1; - else if(strncmp(in->s, "len", 3)==0) + else if(strncmp(in->s, "len", 3) == 0) sp->pvp.pvn.u.isname.name.n = 2; - else if(strncmp(in->s, "tag", 3)==0) + else if(strncmp(in->s, "tag", 3) == 0) sp->pvp.pvn.u.isname.name.n = 0; - else goto error; - break; + else + goto error; + break; case 5: - if(strncmp(in->s, "proto", 5)==0) + if(strncmp(in->s, "proto", 5) == 0) sp->pvp.pvn.u.isname.name.n = 4; - else goto error; - break; + else + goto error; + break; case 6: - if(strncmp(in->s, "sproto", 6)==0) + if(strncmp(in->s, "sproto", 6) == 0) sp->pvp.pvn.u.isname.name.n = 5; - else if(strncmp(in->s, "src_ip", 6)==0) + else if(strncmp(in->s, "src_ip", 6) == 0) sp->pvp.pvn.u.isname.name.n = 6; - else if(strncmp(in->s, "dst_ip", 6)==0) + else if(strncmp(in->s, "dst_ip", 6) == 0) sp->pvp.pvn.u.isname.name.n = 7; - else goto error; - break; + else + goto error; + break; case 8: - if(strncmp(in->s, "src_port", 8)==0) + if(strncmp(in->s, "src_port", 8) == 0) sp->pvp.pvn.u.isname.name.n = 8; - else if(strncmp(in->s, "dst_port", 8)==0) + else if(strncmp(in->s, "dst_port", 8) == 0) sp->pvp.pvn.u.isname.name.n = 9; - else goto error; - break; + else + goto error; + break; default: goto error; } @@ -685,13 +698,12 @@ int pv_parse_sipdump_name(pv_spec_t *sp, str *in) /** * */ -int pv_get_sipdump(sip_msg_t *msg, pv_param_t *param, - pv_value_t *res) +int pv_get_sipdump(sip_msg_t *msg, pv_param_t *param, pv_value_t *res) { str saf = str_init("ipv4"); str sproto = str_init("none"); - if (sipdump_event_data==NULL) { + if(sipdump_event_data == NULL) { return pv_get_null(msg, param, res); } @@ -699,9 +711,10 @@ int pv_get_sipdump(sip_msg_t *msg, pv_param_t *param, case 1: /* buf */ return pv_get_strval(msg, param, res, &sipdump_event_data->data); case 2: /* len */ - return pv_get_uintval(msg, param, res, sipdump_event_data->data.len); + return pv_get_uintval( + msg, param, res, sipdump_event_data->data.len); case 3: /* af */ - if(sipdump_event_data->afid==AF_INET6) { + if(sipdump_event_data->afid == AF_INET6) { saf.s = "ipv6"; } return pv_get_strval(msg, param, res, &saf); @@ -713,9 +726,11 @@ int pv_get_sipdump(sip_msg_t *msg, pv_param_t *param, case 7: /* dst_ip*/ return pv_get_strval(msg, param, res, &sipdump_event_data->dst_ip); case 8: /* src_port */ - return pv_get_uintval(msg, param, res, sipdump_event_data->src_port); + return pv_get_uintval( + msg, param, res, sipdump_event_data->src_port); case 9: /* dst_port */ - return pv_get_uintval(msg, param, res, sipdump_event_data->dst_port); + return pv_get_uintval( + msg, param, res, sipdump_event_data->dst_port); default: /* 0 - tag */ return pv_get_strval(msg, param, res, &sipdump_event_data->tag); diff --git a/src/modules/sipdump/sipdump_pcap.c b/src/modules/sipdump/sipdump_pcap.c index 15e72403d70..00608c37735 100644 --- a/src/modules/sipdump/sipdump_pcap.c +++ b/src/modules/sipdump/sipdump_pcap.c @@ -35,76 +35,86 @@ extern int sipdump_mode; * source: res_pjsip_logger.c - License GPLv2 - Copyright (C) Digium, Inc.*/ /* PCAP Header */ -struct pcap_header { - uint32_t magic_number; /* PCAP file format magic number */ - uint16_t version_major; /* Major version number of the file format */ - uint16_t version_minor; /* Minor version number of the file format */ - int32_t thiszone; /* GMT to local correction */ - uint32_t sigfigs; /* Accuracy of timestamps */ - uint32_t snaplen; /* The maximum size that can be recorded in the file */ - uint32_t network; /* Type of packets held within the file */ +struct pcap_header +{ + uint32_t magic_number; /* PCAP file format magic number */ + uint16_t version_major; /* Major version number of the file format */ + uint16_t version_minor; /* Minor version number of the file format */ + int32_t thiszone; /* GMT to local correction */ + uint32_t sigfigs; /* Accuracy of timestamps */ + uint32_t snaplen; /* The maximum size that can be recorded in the file */ + uint32_t network; /* Type of packets held within the file */ }; /* PCAP Packet Record Header */ -struct pcap_record_header { - uint32_t ts_sec; /* When the record was created */ - uint32_t ts_usec; /* When the record was created */ - uint32_t incl_len; /* Length of packet as saved in the file */ - uint32_t orig_len; /* Length of packet as sent over network */ +struct pcap_record_header +{ + uint32_t ts_sec; /* When the record was created */ + uint32_t ts_usec; /* When the record was created */ + uint32_t incl_len; /* Length of packet as saved in the file */ + uint32_t orig_len; /* Length of packet as sent over network */ }; /* PCAP Ethernet Header */ -struct pcap_ethernet_header { - uint8_t dst[6]; /* Destination MAC address */ - uint8_t src[6]; /* Source MAC address */ +struct pcap_ethernet_header +{ + uint8_t dst[6]; /* Destination MAC address */ + uint8_t src[6]; /* Source MAC address */ uint16_t type; /*!The type of packet contained within */ } __attribute__((__packed__)); /*! PCAP IPv4 Header */ -struct pcap_ipv4_header { - uint8_t ver_ihl; /* IP header version and other bits */ - uint8_t ip_tos; /* Type of service details */ - uint16_t ip_len; /* Total length of the packet (including IPv4 header) */ - uint16_t ip_id; /* Identification value */ - uint16_t ip_off; /* Fragment offset */ - uint8_t ip_ttl; /* Time to live for the packet */ - uint8_t ip_protocol; /* Protocol of the data held within the packet (always UDP) */ - uint16_t ip_sum; /* Checksum (not calculated for our purposes */ - uint32_t ip_src; /* Source IP address */ - uint32_t ip_dst; /* Destination IP address */ +struct pcap_ipv4_header +{ + uint8_t ver_ihl; /* IP header version and other bits */ + uint8_t ip_tos; /* Type of service details */ + uint16_t ip_len; /* Total length of the packet (including IPv4 header) */ + uint16_t ip_id; /* Identification value */ + uint16_t ip_off; /* Fragment offset */ + uint8_t ip_ttl; /* Time to live for the packet */ + uint8_t ip_protocol; /* Protocol of the data held within the packet (always UDP) */ + uint16_t ip_sum; /* Checksum (not calculated for our purposes */ + uint32_t ip_src; /* Source IP address */ + uint32_t ip_dst; /* Destination IP address */ }; /* PCAP IPv6 Header */ -struct pcap_ipv6_header { - union { - struct ip6_hdrctl { - uint32_t ip6_un1_flow; /* Version, traffic class, flow label */ - uint16_t ip6_un1_plen; /* Length of the packet (not including IPv6 header) */ - uint8_t ip6_un1_nxt; /* Next header field */ - uint8_t ip6_un1_hlim; /* Hop Limit */ - } ip6_un1; - uint8_t ip6_un2_vfc; /* Version, traffic class */ - } ip6_ctlun; - struct in6_addr ip6_src; /* Source IP address */ - struct in6_addr ip6_dst; /* Destination IP address */ +struct pcap_ipv6_header +{ + union + { + struct ip6_hdrctl + { + uint32_t ip6_un1_flow; /* Version, traffic class, flow label */ + uint16_t + ip6_un1_plen; /* Length of the packet (not including IPv6 header) */ + uint8_t ip6_un1_nxt; /* Next header field */ + uint8_t ip6_un1_hlim; /* Hop Limit */ + } ip6_un1; + uint8_t ip6_un2_vfc; /* Version, traffic class */ + } ip6_ctlun; + struct in6_addr ip6_src; /* Source IP address */ + struct in6_addr ip6_dst; /* Destination IP address */ }; /* PCAP UDP Header */ -struct pcap_udp_header { - uint16_t src; /* Source IP port */ - uint16_t dst; /* Destination IP port */ - uint16_t length; /* Length of the UDP header plus UDP packet */ - uint16_t checksum; /* Packet checksum, left uncalculated for our purposes */ +struct pcap_udp_header +{ + uint16_t src; /* Source IP port */ + uint16_t dst; /* Destination IP port */ + uint16_t length; /* Length of the UDP header plus UDP packet */ + uint16_t checksum; /* Packet checksum, left uncalculated for our purposes */ }; void sipdump_init_pcap(FILE *fs) { struct pcap_header v_pcap_header = { - .magic_number = 0xa1b2c3d4, - .version_major = 2, - .version_minor = 4, - .snaplen = 65535, - .network = 1, /* use ethernet to combine IPv4 and IPv6 in same pcap */ + .magic_number = 0xa1b2c3d4, + .version_major = 2, + .version_minor = 4, + .snaplen = 65535, + .network = + 1, /* use ethernet to combine IPv4 and IPv6 in same pcap */ }; LM_DBG("writing the pcap file header\n"); @@ -125,18 +135,18 @@ void sipdump_write_pcap(FILE *fs, sipdump_data_t *spd) char *p = NULL; struct pcap_record_header v_pcap_record_header = { - .ts_sec = 0, - .ts_usec = 0, + .ts_sec = 0, + .ts_usec = 0, }; struct pcap_ethernet_header v_pcap_ethernet_header = { - .type = 0, + .type = 0, }; struct pcap_ipv4_header v_pcap_ipv4_header = { - .ver_ihl = 0x45, /* IPv4 + 20 bytes of header */ - .ip_ttl = 128, /* put a TTL of 128 to keep Wireshark less blue */ + .ver_ihl = 0x45, /* IPv4 + 20 bytes of header */ + .ip_ttl = 128, /* put a TTL of 128 to keep Wireshark less blue */ }; struct pcap_ipv6_header v_pcap_ipv6_header = { - .ip6_ctlun.ip6_un2_vfc = 0x60, + .ip6_ctlun.ip6_un2_vfc = 0x60, }; void *pcap_ip_header; size_t pcap_ip_header_len; @@ -152,9 +162,10 @@ void sipdump_write_pcap(FILE *fs, sipdump_data_t *spd) v_pcap_record_header.ts_usec = spd->tv.tv_usec; data = spd->data; - if((sipdump_mode & SIPDUMP_MODE_WPCAPEX) && (spd->data.len < BUF_SIZE - 256)) { + if((sipdump_mode & SIPDUMP_MODE_WPCAPEX) + && (spd->data.len < BUF_SIZE - 256)) { if(_sipdump_pcap_data_buf == NULL) { - _sipdump_pcap_data_buf = (char*)malloc(BUF_SIZE); + _sipdump_pcap_data_buf = (char *)malloc(BUF_SIZE); } if(_sipdump_pcap_data_buf != NULL) { data.s = _sipdump_pcap_data_buf; @@ -167,8 +178,8 @@ void sipdump_write_pcap(FILE *fs, sipdump_data_t *spd) p += data.len; get_valid_proto_string(spd->protoid, 0, 0, &sproto); mval.len = snprintf(p, BUF_SIZE - (data.len + 1), - "P-KSR-SIPDump: %.*s pid=%d pno=%d\r\n", - sproto.len, sproto.s, spd->pid, spd->procno); + "P-KSR-SIPDump: %.*s pid=%d pno=%d\r\n", sproto.len, + sproto.s, spd->pid, spd->procno); if(mval.len < 0 || mval.len >= BUF_SIZE - (data.len + 1)) { data = spd->data; } else { @@ -188,62 +199,67 @@ void sipdump_write_pcap(FILE *fs, sipdump_data_t *spd) v_pcap_udp_header.checksum = 0; /* IP header */ - if (spd->afid == AF_INET6) { + if(spd->afid == AF_INET6) { LM_DBG("ipv6 = %s -> %s\n", spd->src_ip.s, spd->dst_ip.s); v_pcap_ethernet_header.type = htons(0x86DD); /* IPv6 packet */ pcap_ip_header = &v_pcap_ipv6_header; pcap_ip_header_len = sizeof(struct pcap_ipv6_header); - if (inet_pton(AF_INET6, spd->src_ip.s, &ip6addr) != 1) { + if(inet_pton(AF_INET6, spd->src_ip.s, &ip6addr) != 1) { LM_ERR("failed to parse IPv6 address %s\n", spd->src_ip.s); return; } memcpy(&v_pcap_ipv6_header.ip6_src, &ip6addr, sizeof(struct in6_addr)); - if (inet_pton(AF_INET6, spd->dst_ip.s, &ip6addr) != 1) { + if(inet_pton(AF_INET6, spd->dst_ip.s, &ip6addr) != 1) { LM_ERR("failed to parse IPv6 address %s\n", spd->dst_ip.s); return; } memcpy(&v_pcap_ipv6_header.ip6_dst, &ip6addr, sizeof(struct in6_addr)); - v_pcap_ipv6_header.ip6_ctlun.ip6_un1.ip6_un1_plen = htons(sizeof(struct pcap_udp_header) - + data.len); + v_pcap_ipv6_header.ip6_ctlun.ip6_un1.ip6_un1_plen = + htons(sizeof(struct pcap_udp_header) + data.len); v_pcap_ipv6_header.ip6_ctlun.ip6_un1.ip6_un1_nxt = IPPROTO_UDP; } else { LM_DBG("ipv4 = %s -> %s\n", spd->src_ip.s, spd->dst_ip.s); v_pcap_ethernet_header.type = htons(0x0800); /* IPv4 packet */ pcap_ip_header = &v_pcap_ipv4_header; pcap_ip_header_len = sizeof(struct pcap_ipv4_header); - if (inet_pton(AF_INET, spd->src_ip.s, &ip4addr) != 1) { + if(inet_pton(AF_INET, spd->src_ip.s, &ip4addr) != 1) { LM_ERR("failed to parse IPv4 address %s\n", spd->src_ip.s); return; } memcpy(&v_pcap_ipv4_header.ip_src, &ip4addr, sizeof(uint32_t)); - if (inet_pton(AF_INET, spd->dst_ip.s, &ip4addr) != 1) { + if(inet_pton(AF_INET, spd->dst_ip.s, &ip4addr) != 1) { LM_ERR("failed to parse IPv4 address %s\n", spd->dst_ip.s); return; } memcpy(&v_pcap_ipv4_header.ip_dst, &ip4addr, sizeof(uint32_t)); - v_pcap_ipv4_header.ip_len = htons(sizeof(struct pcap_udp_header) - + sizeof(struct pcap_ipv4_header) + data.len); + v_pcap_ipv4_header.ip_len = + htons(sizeof(struct pcap_udp_header) + + sizeof(struct pcap_ipv4_header) + data.len); v_pcap_ipv4_header.ip_protocol = IPPROTO_UDP; /* UDP */ } /* add up all the sizes for this record */ - v_pcap_record_header.orig_len = sizeof(struct pcap_ethernet_header) + pcap_ip_header_len - + sizeof(struct pcap_udp_header) + data.len; + v_pcap_record_header.orig_len = sizeof(struct pcap_ethernet_header) + + pcap_ip_header_len + + sizeof(struct pcap_udp_header) + data.len; v_pcap_record_header.incl_len = v_pcap_record_header.orig_len; - if (fwrite(&v_pcap_record_header, sizeof(struct pcap_record_header), 1, fs) != 1) { + if(fwrite(&v_pcap_record_header, sizeof(struct pcap_record_header), 1, fs) + != 1) { LM_ERR("writing PCAP header failed: %s\n", strerror(errno)); } - if (fwrite(&v_pcap_ethernet_header, sizeof(struct pcap_ethernet_header), 1, fs) != 1) { + if(fwrite(&v_pcap_ethernet_header, sizeof(struct pcap_ethernet_header), 1, + fs) + != 1) { LM_ERR("writing ethernet header to pcap failed: %s\n", strerror(errno)); } - if (fwrite(pcap_ip_header, pcap_ip_header_len, 1, fs) != 1) { + if(fwrite(pcap_ip_header, pcap_ip_header_len, 1, fs) != 1) { LM_ERR("writing IP header to pcap failed: %s\n", strerror(errno)); } - if (fwrite(&v_pcap_udp_header, sizeof(struct pcap_udp_header), 1, fs) != 1) { + if(fwrite(&v_pcap_udp_header, sizeof(struct pcap_udp_header), 1, fs) != 1) { LM_ERR("writing UDP header to pcap failed: %s\n", strerror(errno)); } - if (fwrite(data.s, data.len, 1, fs) != 1) { + if(fwrite(data.s, data.len, 1, fs) != 1) { LM_ERR("writing UDP payload to pcap failed: %s\n", strerror(errno)); } fflush(fs); diff --git a/src/modules/sipdump/sipdump_write.c b/src/modules/sipdump/sipdump_write.c index 0dd89d3661e..8b61a2f6c8b 100644 --- a/src/modules/sipdump/sipdump_write.c +++ b/src/modules/sipdump/sipdump_write.c @@ -54,15 +54,15 @@ static FILE *_sipdump_pcap_file = NULL; */ int sipdump_list_init(int en) { - if(_sipdump_list!=NULL) + if(_sipdump_list != NULL) return 0; - _sipdump_list = (sipdump_list_t*)shm_malloc(sizeof(sipdump_list_t)); - if(_sipdump_list==NULL) { + _sipdump_list = (sipdump_list_t *)shm_malloc(sizeof(sipdump_list_t)); + if(_sipdump_list == NULL) { LM_ERR("not enough shared memory\n"); return -1; } memset(_sipdump_list, 0, sizeof(sipdump_list_t)); - if(lock_init(&_sipdump_list->lock)==NULL) { + if(lock_init(&_sipdump_list->lock) == NULL) { shm_free(_sipdump_list); LM_ERR("failed to init lock\n"); return -1; @@ -76,9 +76,9 @@ int sipdump_list_init(int en) */ int sipdump_enabled(void) { - if(_sipdump_list==NULL) + if(_sipdump_list == NULL) return 0; - if(_sipdump_list->enable==0) + if(_sipdump_list->enable == 0) return 0; return 1; } @@ -89,13 +89,13 @@ int sipdump_list_destroy(void) { sipdump_data_t *sdd = NULL; sipdump_data_t *sdd0 = NULL; - if(_sipdump_list==NULL) + if(_sipdump_list == NULL) return 0; - sdd=_sipdump_list->first; - while(sdd!=NULL) { + sdd = _sipdump_list->first; + while(sdd != NULL) { sdd0 = sdd; - sdd=sdd->next; + sdd = sdd->next; shm_free(sdd0); } return 0; @@ -127,10 +127,12 @@ int sipdump_data_clone(sipdump_data_t *isd, sipdump_data_t **osd) *osd = NULL; - dsize = sizeof(sipdump_data_t) + (isd->data.len + 1 + isd->tag.len + 1 - + isd->src_ip.len + 1 + isd->dst_ip.len + 1)*sizeof(char); - sdd = (sipdump_data_t*)shm_malloc(dsize); - if(sdd==NULL) { + dsize = sizeof(sipdump_data_t) + + (isd->data.len + 1 + isd->tag.len + 1 + isd->src_ip.len + 1 + + isd->dst_ip.len + 1) + * sizeof(char); + sdd = (sipdump_data_t *)shm_malloc(dsize); + if(sdd == NULL) { LM_ERR("no more shared memory\n"); return -1; } @@ -139,7 +141,7 @@ int sipdump_data_clone(sipdump_data_t *isd, sipdump_data_t **osd) memcpy(sdd, isd, sizeof(sipdump_data_t)); sdd->next = NULL; - sdd->data.s = (char*)sdd + sizeof(sipdump_data_t); + sdd->data.s = (char *)sdd + sizeof(sipdump_data_t); sdd->data.len = isd->data.len; memcpy(sdd->data.s, isd->data.s, isd->data.len); sdd->data.s[sdd->data.len] = '\0'; @@ -177,19 +179,19 @@ static int sipdump_write_meta(char *fpath) char t_buf[26] = {0}; len = strlen(fpath); - if(len>=SIPDUMP_FPATH_SIZE-1) { + if(len >= SIPDUMP_FPATH_SIZE - 1) { LM_ERR("file path too long\n"); return -1; } strcpy(mpath, fpath); - mpath[len-4] = 'm'; - mpath[len-3] = 'e'; - mpath[len-2] = 't'; - mpath[len-1] = 'a'; + mpath[len - 4] = 'm'; + mpath[len - 3] = 'e'; + mpath[len - 2] = 't'; + mpath[len - 1] = 'a'; LM_DBG("writing meta to file: %s (%d)\n", mpath, len); - mfile = fopen( mpath , "w" ); - if(mfile==NULL) { + mfile = fopen(mpath, "w"); + if(mfile == NULL) { LM_ERR("failed to open meta file %s (%d)\n", mpath, len); return -1; } @@ -199,14 +201,9 @@ static int sipdump_write_meta(char *fpath) "version: %s %s\n" "start: %s" "nrprocs: %d\n", - ver_name, ver_version, - asctime_r(&ti, t_buf), - *process_count - ); - for (i=0; i<*process_count; i++) { - fprintf(mfile, - "process: %d %d %s\n", - i, pt[i].pid, pt[i].desc); + ver_name, ver_version, asctime_r(&ti, t_buf), *process_count); + for(i = 0; i < *process_count; i++) { + fprintf(mfile, "process: %d %d %s\n", i, pt[i].pid, pt[i].desc); } fclose(mfile); @@ -224,15 +221,13 @@ static int sipdump_rotate_file(void) tv = time(NULL); - if(_sipdump_text_file!=NULL - && sipdump_last_rotate>0 - && sipdump_last_rotate+sipdump_rotate>tv) { + if(_sipdump_text_file != NULL && sipdump_last_rotate > 0 + && sipdump_last_rotate + sipdump_rotate > tv) { /* not yet the time for rotation */ return 0; } - if(_sipdump_pcap_file!=NULL - && sipdump_last_rotate>0 - && sipdump_last_rotate+sipdump_rotate>tv) { + if(_sipdump_pcap_file != NULL && sipdump_last_rotate > 0 + && sipdump_last_rotate + sipdump_rotate > tv) { /* not yet the time for rotation */ return 0; } @@ -246,27 +241,25 @@ static int sipdump_rotate_file(void) localtime_r(&tv, &ti); if(sipdump_mode & SIPDUMP_MODE_WTEXT) { - n = snprintf(_sipdump_fpath+_sipdump_fpath_prefix.len, - SIPDUMP_FPATH_SIZE-_sipdump_fpath_prefix.len, - "%d-%02d-%02d--%02d-%02d-%02d.data", - 1900+ti.tm_year, ti.tm_mon+1, ti.tm_mday, - ti.tm_hour, ti.tm_min, ti.tm_sec); + n = snprintf(_sipdump_fpath + _sipdump_fpath_prefix.len, + SIPDUMP_FPATH_SIZE - _sipdump_fpath_prefix.len, + "%d-%02d-%02d--%02d-%02d-%02d.data", 1900 + ti.tm_year, + ti.tm_mon + 1, ti.tm_mday, ti.tm_hour, ti.tm_min, ti.tm_sec); LM_DBG("writing to text file: %s (%d)\n", _sipdump_fpath, n); - _sipdump_text_file = fopen( _sipdump_fpath, "w" ); - if(_sipdump_text_file==NULL) { + _sipdump_text_file = fopen(_sipdump_fpath, "w"); + if(_sipdump_text_file == NULL) { LM_ERR("failed to open file %s\n", _sipdump_fpath); return -1; } } if(sipdump_mode & SIPDUMP_MODE_WPCAP) { - n = snprintf(_sipdump_fpath+_sipdump_fpath_prefix.len, - SIPDUMP_FPATH_SIZE-_sipdump_fpath_prefix.len, - "%d-%02d-%02d--%02d-%02d-%02d.pcap", - 1900+ti.tm_year, ti.tm_mon+1, ti.tm_mday, - ti.tm_hour, ti.tm_min, ti.tm_sec); + n = snprintf(_sipdump_fpath + _sipdump_fpath_prefix.len, + SIPDUMP_FPATH_SIZE - _sipdump_fpath_prefix.len, + "%d-%02d-%02d--%02d-%02d-%02d.pcap", 1900 + ti.tm_year, + ti.tm_mon + 1, ti.tm_mday, ti.tm_hour, ti.tm_min, ti.tm_sec); LM_DBG("writing to pcap file: %s (%d)\n", _sipdump_fpath, n); - _sipdump_pcap_file = fopen( _sipdump_fpath, "w" ); - if(_sipdump_pcap_file==NULL) { + _sipdump_pcap_file = fopen(_sipdump_fpath, "w"); + if(_sipdump_pcap_file == NULL) { LM_ERR("failed to open file %s\n", _sipdump_fpath); return -1; } @@ -284,12 +277,11 @@ static int sipdump_rotate_file(void) */ int sipdump_file_init(str *folder, str *fprefix) { - _sipdump_fpath_prefix.len = snprintf(_sipdump_fpath, SIPDUMP_FPATH_SIZE-64, - "%.*s/%.*s", - folder->len, folder->s, - fprefix->len, fprefix->s); - if(_sipdump_fpath_prefix.len<0 - || _sipdump_fpath_prefix.len>=SIPDUMP_FPATH_SIZE-64) { + _sipdump_fpath_prefix.len = + snprintf(_sipdump_fpath, SIPDUMP_FPATH_SIZE - 64, "%.*s/%.*s", + folder->len, folder->s, fprefix->len, fprefix->s); + if(_sipdump_fpath_prefix.len < 0 + || _sipdump_fpath_prefix.len >= SIPDUMP_FPATH_SIZE - 64) { LM_ERR("sipdump file path failed or is too long\n"); return -1; } @@ -310,7 +302,7 @@ int sipdump_data_print(sipdump_data_t *sd, str *obuf) str sproto = str_init("none"); str saf = str_init("ipv4"); - if(sd->afid==AF_INET6) { + if(sd->afid == AF_INET6) { saf.s = "ipv6"; } @@ -318,30 +310,25 @@ int sipdump_data_print(sipdump_data_t *sd, str *obuf) localtime_r(&sd->tv.tv_sec, &ti); obuf->len = snprintf(_sipdump_wbuf, SIPDUMP_WBUF_SIZE, - "====================\n" - "tag: %.*s\n" - "pid: %d\n" - "process: %d\n" - "time: %lu.%06lu\n" - "date: %s" - "proto: %.*s %.*s\n" - "srcip: %.*s\n" - "srcport: %d\n" - "dstip: %.*s\n" - "dstport: %d\n" - "~~~~~~~~~~~~~~~~~~~~\n" - "%.*s" - "||||||||||||||||||||\n", - sd->tag.len, sd->tag.s, - sd->pid, - sd->procno, - (unsigned long)sd->tv.tv_sec, (unsigned long)sd->tv.tv_usec, - asctime_r(&ti, t_buf), - sproto.len, sproto.s, saf.len, saf.s, - sd->src_ip.len, sd->src_ip.s, sd->src_port, - sd->dst_ip.len, sd->dst_ip.s, sd->dst_port, - sd->data.len, sd->data.s - ); + "====================\n" + "tag: %.*s\n" + "pid: %d\n" + "process: %d\n" + "time: %lu.%06lu\n" + "date: %s" + "proto: %.*s %.*s\n" + "srcip: %.*s\n" + "srcport: %d\n" + "dstip: %.*s\n" + "dstport: %d\n" + "~~~~~~~~~~~~~~~~~~~~\n" + "%.*s" + "||||||||||||||||||||\n", + sd->tag.len, sd->tag.s, sd->pid, sd->procno, + (unsigned long)sd->tv.tv_sec, (unsigned long)sd->tv.tv_usec, + asctime_r(&ti, t_buf), sproto.len, sproto.s, saf.len, saf.s, + sd->src_ip.len, sd->src_ip.s, sd->src_port, sd->dst_ip.len, + sd->dst_ip.s, sd->dst_port, sd->data.len, sd->data.s); obuf->s = _sipdump_wbuf; return 0; @@ -356,38 +343,39 @@ void sipdump_timer_exec(unsigned int ticks, void *param) str odata = str_init(""); int cnt = 0; - if(_sipdump_list==NULL || _sipdump_list->first==NULL) + if(_sipdump_list == NULL || _sipdump_list->first == NULL) return; - if(sipdump_rotate_file()<0) { + if(sipdump_rotate_file() < 0) { LM_ERR("sipdump rotate file failed\n"); return; } while(1) { lock_get(&_sipdump_list->lock); - if(_sipdump_list->first==NULL) { + if(_sipdump_list->first == NULL) { lock_release(&_sipdump_list->lock); - if(_sipdump_text_file) fflush(_sipdump_text_file); + if(_sipdump_text_file) + fflush(_sipdump_text_file); return; } sdd = _sipdump_list->first; _sipdump_list->first = sdd->next; - if(sdd->next==NULL) { + if(sdd->next == NULL) { _sipdump_list->last = NULL; } _sipdump_list->count--; lock_release(&_sipdump_list->lock); cnt++; - if(cnt>2000) { - if(sipdump_rotate_file()<0) { + if(cnt > 2000) { + if(sipdump_rotate_file() < 0) { LM_ERR("sipdump rotate file failed\n"); return; } - cnt=0; + cnt = 0; } if(sipdump_mode & SIPDUMP_MODE_WTEXT) { - if(_sipdump_text_file==NULL) { + if(_sipdump_text_file == NULL) { LM_ERR("sipdump text file is not open\n"); return; } @@ -398,7 +386,7 @@ void sipdump_timer_exec(unsigned int ticks, void *param) fflush(_sipdump_text_file); } if(sipdump_mode & SIPDUMP_MODE_WPCAP) { - if(_sipdump_pcap_file==NULL) { + if(_sipdump_pcap_file == NULL) { LM_ERR("sipdump pcap file is not open\n"); return; } @@ -409,7 +397,7 @@ void sipdump_timer_exec(unsigned int ticks, void *param) } static const char *sipdump_rpc_enable_doc[2] = { - "Command to control sipdump enable value", 0}; + "Command to control sipdump enable value", 0}; /* @@ -434,7 +422,7 @@ static void sipdump_rpc_enable(rpc_t *rpc, void *ctx) if(_sipdump_list) { oval = _sipdump_list->enable; - if(enval==0 || enval==1) { + if(enval == 0 || enval == 1) { _sipdump_list->enable = enval; nval = enval; } else { diff --git a/src/modules/sipdump/sipdump_write.h b/src/modules/sipdump/sipdump_write.h index 34c696066fd..4daf98ddace 100644 --- a/src/modules/sipdump/sipdump_write.h +++ b/src/modules/sipdump/sipdump_write.h @@ -28,12 +28,13 @@ #include "../../core/str.h" #include "../../core/locking.h" -#define SIPDUMP_MODE_WTEXT (1<<0) -#define SIPDUMP_MODE_EVROUTE (1<<1) -#define SIPDUMP_MODE_WPCAP (1<<2) -#define SIPDUMP_MODE_WPCAPEX (1<<3) +#define SIPDUMP_MODE_WTEXT (1 << 0) +#define SIPDUMP_MODE_EVROUTE (1 << 1) +#define SIPDUMP_MODE_WPCAP (1 << 2) +#define SIPDUMP_MODE_WPCAPEX (1 << 3) -typedef struct sipdump_data { +typedef struct sipdump_data +{ int pid; int procno; struct timeval tv; @@ -48,7 +49,8 @@ typedef struct sipdump_data { struct sipdump_data *next; } sipdump_data_t; -typedef struct sipdump_list { +typedef struct sipdump_list +{ int count; int enable; gen_lock_t lock;