9
0
Fork 0

pcap: Run all pcap operations through one method

This commit is contained in:
Holger Hans Peter Freyther 2011-01-22 17:36:01 +01:00
parent c6bfa27b5e
commit ddf8eae7da
5 changed files with 18 additions and 10 deletions

View File

@ -160,4 +160,7 @@ int link_clear_all(struct mtp_link_set *);
/* MGCP */
void mgcp_forward(struct bsc_data *bsc, const uint8_t *data, unsigned int length);
/* pcap */
int mtp_handle_pcap(struct mtp_link *, const uint8_t *data, int length);
#endif

View File

@ -1,6 +1,6 @@
/*
* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2010 by On-Waves
* (C) 2010-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2010-2011 by On-Waves
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify

View File

@ -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:

View File

@ -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;
}

View File

@ -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;