aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-01-22 17:36:01 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-01-22 21:33:11 +0100
commitddf8eae7da02b20dd4310af9428a1eb18b1dd57d (patch)
tree530001939877c4e7a75adf02d33eb5f6a8c2b4dd /src
parentc6bfa27b5e56845491c6d03406d4dba65d86095f (diff)
pcap: Run all pcap operations through one method
Diffstat (limited to 'src')
-rw-r--r--src/link_udp.c6
-rw-r--r--src/links.c9
-rw-r--r--src/sctp_m2ua.c6
3 files changed, 13 insertions, 8 deletions
diff --git a/src/link_udp.c b/src/link_udp.c
index f7c6703..a9b2d9b 100644
--- a/src/link_udp.c
+++ b/src/link_udp.c
@@ -61,8 +61,7 @@ static int udp_write_cb(struct bsc_fd *fd, struct msgb *msg)
}
LOGP(DINP, LOGL_DEBUG, "Sending MSU: %s\n", hexdump(msg->data, msg->len));
- if (link->base.pcap_fd >= 0)
- mtp_pcap_write_msu(link->base.pcap_fd, msg->l2h, msgb_l2len(msg));
+ mtp_handle_pcap(&link->base, msg->l2h, msgb_l2len(msg));
/* the assumption is we have connected the socket to the remote */
rc = sendto(fd->fd, msg->data, msg->len, 0,
@@ -137,8 +136,7 @@ static int udp_read_cb(struct bsc_fd *fd)
msg->l2h = msgb_put(msg, length);
LOGP(DINP, LOGL_DEBUG, "MSU data on: %p data %s.\n", link, hexdump(msg->data, msg->len));
- if (link->pcap_fd >= 0)
- mtp_pcap_write_msu(link->pcap_fd, msg->l2h, msgb_l2len(msg));
+ mtp_handle_pcap(link, msg->l2h, msgb_l2len(msg));
mtp_link_set_data(link, msg);
exit:
diff --git a/src/links.c b/src/links.c
index 7a114fb..1acc8bf 100644
--- a/src/links.c
+++ b/src/links.c
@@ -23,6 +23,7 @@
#include <bsc_data.h>
#include <cellmgr_debug.h>
#include <mtp_data.h>
+#include <mtp_pcap.h>
#include <snmp_mtp.h>
#include <osmocore/talloc.h>
@@ -175,3 +176,11 @@ int link_clear_all(struct mtp_link_set *set)
lnk->clear_queue(lnk);
return 0;
}
+
+int mtp_handle_pcap(struct mtp_link *link, const uint8_t *data, int len)
+{
+ if (link->pcap_fd < 0)
+ return 0;
+ mtp_pcap_write_msu(link->pcap_fd, data, len);
+ return 0;
+}
diff --git a/src/sctp_m2ua.c b/src/sctp_m2ua.c
index d3a64c9..3f67665 100644
--- a/src/sctp_m2ua.c
+++ b/src/sctp_m2ua.c
@@ -327,8 +327,7 @@ static int m2ua_handle_data(struct sctp_m2ua_conn *conn,
memcpy(msg->l2h, data->dat, data->len);
link = &conn->trans->base;
- if (link->pcap_fd >= 0)
- mtp_pcap_write_msu(link->pcap_fd, msg->l2h, msgb_l2len(msg));
+ mtp_handle_pcap(link, msg->l2h, msgb_l2len(msg));
mtp_link_set_data(link, msg);
msgb_free(msg);
@@ -470,8 +469,7 @@ static int sctp_m2ua_write(struct mtp_link *link, struct msgb *msg)
if (!m2ua)
return -1;
- if (link->pcap_fd >= 0)
- mtp_pcap_write_msu(link->pcap_fd, msg->data, msg->len);
+ mtp_handle_pcap(link, msg->data, msg->len);
m2ua->hdr.msg_class = M2UA_CLS_MAUP;
m2ua->hdr.msg_type = M2UA_MAUP_DATA;