Dump something that can be read by wireshark
We need to append the Linux LAPD header for wireshark. This means that we currently can not support B Channels or such. Maybe we will need to add another LAPD header.
This commit is contained in:
parent
62a923d46a
commit
4e0d137a2c
50
src/misdn.c
50
src/misdn.c
|
@ -31,6 +31,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
#include <mISDNif.h>
|
#include <mISDNif.h>
|
||||||
|
|
||||||
//#define AF_COMPATIBILITY_FUNC
|
//#define AF_COMPATIBILITY_FUNC
|
||||||
|
@ -73,19 +74,20 @@ struct pcaprec_hdr {
|
||||||
u_int32_t orig_len;
|
u_int32_t orig_len;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
struct pseudo_isdn_header {
|
struct fake_linux_lapd_header {
|
||||||
int32_t uton;
|
u_int16_t pkttype;
|
||||||
u_int8_t channel;
|
u_int16_t hatype;
|
||||||
|
u_int16_t halen;
|
||||||
|
u_int64_t addr;
|
||||||
|
int16_t protocol;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
struct fake_lapd_frame {
|
static_assert((int)&((struct fake_linux_lapd_header*)NULL)->hatype == 2, hatype_offset);
|
||||||
u_int8_t ea1 : 1;
|
static_assert((int)&((struct fake_linux_lapd_header*)NULL)->halen == 4, halen_offset);
|
||||||
u_int8_t cr : 1;
|
static_assert((int)&((struct fake_linux_lapd_header*)NULL)->addr == 6, addr_offset);
|
||||||
u_int8_t sapi : 6;
|
static_assert((int)&((struct fake_linux_lapd_header*)NULL)->protocol == 14, proto_offset);
|
||||||
u_int8_t ea2 : 1;
|
static_assert(sizeof(struct fake_linux_lapd_header) == 16, lapd_header_size);
|
||||||
u_int8_t tei : 7;
|
|
||||||
u_int8_t control_foo; /* fake UM's ... */
|
|
||||||
} __attribute__((packed));
|
|
||||||
|
|
||||||
static int pcap_fd = -1;
|
static int pcap_fd = -1;
|
||||||
|
|
||||||
|
@ -116,40 +118,30 @@ static void write_pcap_packet(int direction, struct sockaddr_mISDN* addr,
|
||||||
time_t cur_time;
|
time_t cur_time;
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
|
|
||||||
struct pseudo_isdn_header isdn = {
|
struct fake_linux_lapd_header header = {
|
||||||
/* user to network.. we are the network.. gboolean is a init */
|
.pkttype = 4,
|
||||||
.uton = 0,
|
.hatype = 0,
|
||||||
.channel = addr->channel,
|
.halen = 0,
|
||||||
|
.addr = 0x1,
|
||||||
|
.protocol = ntohs(48),
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fake_lapd_frame header = {
|
|
||||||
.ea1 = 0,
|
|
||||||
.cr = PCAP_OUTPUT ? 1 : 0,
|
|
||||||
.sapi = addr->sapi & 0x3F,
|
|
||||||
.ea2 = 1,
|
|
||||||
.tei = addr->tei & 0x7F,
|
|
||||||
.control_foo = 0x13 /* UI with P set */,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pcaprec_hdr payload_header = {
|
struct pcaprec_hdr payload_header = {
|
||||||
.ts_sec = 0,
|
.ts_sec = 0,
|
||||||
.ts_usec = 0,
|
.ts_usec = 0,
|
||||||
.incl_len = msg->len + sizeof(struct fake_lapd_frame)
|
.incl_len = msg->len + sizeof(struct fake_linux_lapd_header)
|
||||||
+ sizeof(struct pseudo_isdn_header)
|
|
||||||
- MISDN_HEADER_LEN,
|
- MISDN_HEADER_LEN,
|
||||||
.orig_len = msg->len + sizeof(struct fake_lapd_frame)
|
.orig_len = msg->len + sizeof(struct fake_linux_lapd_header)
|
||||||
+ sizeof(struct pseudo_isdn_header)
|
|
||||||
- MISDN_HEADER_LEN,
|
- MISDN_HEADER_LEN,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cur_time = time(NULL);
|
cur_time = time(NULL);
|
||||||
tm = localtime(&cur_time);
|
tm = localtime(&cur_time);
|
||||||
payload_header.ts_sec = mktime(tm);
|
payload_header.ts_sec = mktime(tm);
|
||||||
|
|
||||||
ret = write(pcap_fd, &payload_header, sizeof(payload_header));
|
ret = write(pcap_fd, &payload_header, sizeof(payload_header));
|
||||||
ret = write(pcap_fd, &isdn, sizeof(isdn));
|
|
||||||
ret = write(pcap_fd, &header, sizeof(header));
|
ret = write(pcap_fd, &header, sizeof(header));
|
||||||
ret = write(pcap_fd, msg->data + MISDN_HEADER_LEN,
|
ret = write(pcap_fd, msg->data + MISDN_HEADER_LEN,
|
||||||
msg->len - MISDN_HEADER_LEN);
|
msg->len - MISDN_HEADER_LEN);
|
||||||
|
|
Loading…
Reference in New Issue