[pcap] Write incoming packages without the extra mISDN header
This patch fixes the PCAP logging. If frames are received from E1
interface, an 8 byte mISDN header (MISDN_HEADER_LEN) is in front of the
RSL packet. When frames are transmitted to the E1 interface, the
pcap_write_packet function will get a message buffer without the mISDN
header in front of the RSL packet. The pcap file was tested and the
output is correct.
Follow up patches should make use the msgb->l2, make the ipaccess
code use the pcap writing too...
diff --git a/openbsc/src/e1_input.c b/openbsc/src/e1_input.c
index c3c7c75..034bd97 100644
--- a/openbsc/src/e1_input.c
+++ b/openbsc/src/e1_input.c
@@ -140,6 +140,7 @@
int ret;
time_t cur_time;
struct tm *tm;
+ int mi_head = (direction==PCAP_INPUT) ? MISDN_HEADER_LEN : 0;
struct fake_linux_lapd_header header = {
.pkttype = 4,
@@ -163,13 +164,15 @@
.ts_usec = 0,
.incl_len = msg->len + sizeof(struct fake_linux_lapd_header)
+ sizeof(struct lapd_header)
- - MISDN_HEADER_LEN,
+ - mi_head,
.orig_len = msg->len + sizeof(struct fake_linux_lapd_header)
+ sizeof(struct lapd_header)
- - MISDN_HEADER_LEN,
+ - mi_head,
};
+ printf("Packet of: %d\n", direction);
+
cur_time = time(NULL);
tm = localtime(&cur_time);
payload_header.ts_sec = mktime(tm);
@@ -177,8 +180,8 @@
ret = write(pcap_fd, &payload_header, sizeof(payload_header));
ret = write(pcap_fd, &header, sizeof(header));
ret = write(pcap_fd, &lapd_header, sizeof(lapd_header));
- ret = write(pcap_fd, msg->data + MISDN_HEADER_LEN,
- msg->len - MISDN_HEADER_LEN);
+ ret = write(pcap_fd, msg->data + mi_head,
+ msg->len - mi_head);
}
static const char *sign_types[] = {