From 20152a35e35e790ae281cd2445b746e338eb669c Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Wed, 10 Jun 2009 14:47:33 +0200 Subject: [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... --- openbsc/src/e1_input.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'openbsc') diff --git a/openbsc/src/e1_input.c b/openbsc/src/e1_input.c index c3c7c7597..034bd9723 100644 --- a/openbsc/src/e1_input.c +++ b/openbsc/src/e1_input.c @@ -140,6 +140,7 @@ static void write_pcap_packet(int direction, int sapi, int tei, 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 @@ static void write_pcap_packet(int direction, int sapi, int tei, .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 @@ static void write_pcap_packet(int direction, int sapi, int tei, 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[] = { -- cgit v1.2.3