diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-01-22 21:01:23 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-01-22 21:33:18 +0100 |
commit | f6375b49d34a6adc7eaf42ebd06ab64037df9f0a (patch) | |
tree | 23e2f178494ce97faf6ef21f0ee861ea2b3c4c93 | |
parent | 36260e915a23892e5275866ef943783ec6a8e404 (diff) |
pcap: Allow to log on a link or linkset level
-rw-r--r-- | include/mtp_data.h | 2 | ||||
-rw-r--r-- | src/links.c | 8 | ||||
-rw-r--r-- | src/main_stp.c | 3 |
3 files changed, 9 insertions, 4 deletions
diff --git a/include/mtp_data.h b/include/mtp_data.h index e6cd872..b991f46 100644 --- a/include/mtp_data.h +++ b/include/mtp_data.h @@ -59,6 +59,8 @@ struct mtp_link_set { struct mtp_link *slc[16]; int sltm_once; + int pcap_fd; + /* special handling */ int pass_all_isup; diff --git a/src/links.c b/src/links.c index 05ac2ee..628992b 100644 --- a/src/links.c +++ b/src/links.c @@ -107,6 +107,7 @@ int link_init(struct bsc_data *bsc) bsc->link_set->ni = bsc->ni_ni; bsc->link_set->spare = bsc->ni_spare; bsc->link_set->bsc = bsc; + bsc->link_set->pcap_fd = bsc->pcap_fd; if (!bsc->src_port) { LOGP(DINP, LOGL_ERROR, "You need to set a UDP address.\n"); @@ -121,7 +122,7 @@ int link_init(struct bsc_data *bsc) for (i = 1; i <= bsc->udp_nr_links; ++i) { lnk = talloc_zero(bsc->link_set, struct mtp_udp_link); - lnk->base.pcap_fd = bsc->pcap_fd; + lnk->base.pcap_fd = -1; lnk->bsc = bsc; lnk->data = &bsc->udp_data; lnk->link_index = i; @@ -180,7 +181,8 @@ int link_clear_all(struct mtp_link_set *set) int mtp_handle_pcap(struct mtp_link *link, int dir, const uint8_t *data, int len) { if (link->pcap_fd < 0) - return 0; - mtp_pcap_write_msu(link->pcap_fd, data, len); + mtp_pcap_write_msu(link->pcap_fd, data, len); + if (link->set->pcap_fd < 0) + mtp_pcap_write_msu(link->set->pcap_fd, data, len); return 0; } diff --git a/src/main_stp.c b/src/main_stp.c index a957478..1ae2e11 100644 --- a/src/main_stp.c +++ b/src/main_stp.c @@ -249,13 +249,14 @@ int main(int argc, char **argv) bsc.m2ua_set->isup_opc = 9; bsc.m2ua_set->ni = 3; bsc.m2ua_set->bsc = &bsc; + bsc.m2ua_set->pcap_fd = bsc.pcap_fd; /* for both links we want to have all isup messages */ bsc.m2ua_set->pass_all_isup = 1; bsc.link_set->pass_all_isup = 1; lnk = sctp_m2ua_transp_create("0.0.0.0", 2904); - lnk->base.pcap_fd = bsc.pcap_fd; + lnk->base.pcap_fd = -1; mtp_link_set_add_link(bsc.m2ua_set, (struct mtp_link *) lnk); llist_for_each_entry(data, &bsc.m2ua_set->links, entry) |