laforge has submitted this change. (
https://gerrit.osmocom.org/c/dahdi-tools/+/27276 )
Change subject: dahdi_pcap: Allow caller to specify network / user mode
......................................................................
dahdi_pcap: Allow caller to specify network / user mode
A LAPD dissector (such as the one in wireshark) needs to know if
the local side is the user or the network in order to properly
decode/display the trace. This is encoded in the sll_addr field
whose first octet indicates if the local (capturing) node serves
as the network or user side of ISDN.
Change-Id: Ief575bc4118fe5f20ef4b374d29eca442b04dabb
---
M dahdi_pcap.c
1 file changed, 22 insertions(+), 9 deletions(-)
Approvals:
Jenkins Builder: Verified
manawyrm: Looks good to me, approved
diff --git a/dahdi_pcap.c b/dahdi_pcap.c
index 0eadde3..1e69a36 100644
--- a/dahdi_pcap.c
+++ b/dahdi_pcap.c
@@ -101,7 +101,7 @@
return fd;
}
-int log_packet(struct chan_fds * fd, char is_read, pcap_dumper_t * dump)
+int log_packet(struct chan_fds * fd, char is_read, int we_are_network, pcap_dumper_t *
dump)
{
unsigned char buf[BLOCK_SIZE * 4];
int res = 0;
@@ -165,7 +165,7 @@
lapd->sll_pkttype = htons(is_read ? PACKET_HOST : PACKET_OUTGOING);
lapd->sll_hatype = 0;
lapd->sll_halen = htons(8);
- // lapd->sll_addr = ???
+ lapd->sll_addr[0] = we_are_network;
lapd->sll_protocol[0] = 0x00;
lapd->sll_protocol[1] = 0x30;
@@ -198,10 +198,11 @@
printf("Usage: dahdi_pcap [OPTIONS]\n");
printf("Capture packets from DAHDI channels to pcap file\n\n");
printf("Options:\n");
- printf(" -p, --proto=[mtp2|lapd] The protocol to capture, default mtp2\n");
- printf(" -c, --chan=<channels> Comma separated list of channels to capture
from, max %d. Mandatory\n", MAX_CHAN);
- printf(" -f, --file=<filename> The pcap file to capture to.
Mandatory\n");
- printf(" -h, --help Display this text\n");
+ printf(" -p, --proto=[mtp2|lapd] The protocol to capture, default
mtp2\n");
+ printf(" -c, --chan=<channels> Comma separated list of channels to
capture from, max %d. Mandatory\n", MAX_CHAN);
+ printf(" -r, --role=[network|user] Is the local side the network or user side in
ISDN?\n");
+ printf(" -f, --file=<filename> The pcap file to capture to.
Mandatory\n");
+ printf(" -h, --help Display this text\n");
}
int main(int argc, char **argv)
@@ -211,6 +212,7 @@
int num_chans = 0;
int max_fd = 0;
int proto = DLT_MTP2_WITH_PHDR;
+ int we_are_network = 0;
int i;
int packetcount;
@@ -221,12 +223,13 @@
static struct option long_options[] = {
{"proto", required_argument, 0, 'p'},
{"chan", required_argument, 0, 'c'},
+ {"role", required_argument, 0, 'r'},
{"file", required_argument, 0, 'f'},
{"help", 0, 0, 'h'},
{0, 0, 0, 0}
};
- c = getopt_long(argc, argv, "p:c:f:?",
+ c = getopt_long(argc, argv, "p:c:r:f:?",
long_options, &option_index);
if (c == -1)
break;
@@ -269,6 +272,16 @@
}
max_fd++;
break;
+ case 'r':
+ if (!strcasecmp("network", optarg))
+ we_are_network = 1;
+ else if (!strcasecmp("user", optarg))
+ we_are_network = 0;
+ else {
+ fprintf(stderr, "Role must be user or network!\n");
+ exit(1);
+ }
+ break;
case 'f':
// File to capture to
filename=optarg;
@@ -318,11 +331,11 @@
{
if(FD_ISSET(chans[i].rfd, &rd_set))
{
- packetcount += log_packet(&chans[i], 1, dump);
+ packetcount += log_packet(&chans[i], 1, we_are_network, dump);
}
if(FD_ISSET(chans[i].tfd, &rd_set))
{
- packetcount += log_packet(&chans[i], 0, dump);
+ packetcount += log_packet(&chans[i], 0, we_are_network, dump);
}
}
printf("Packets captured: %d\r", packetcount);
--
To view, visit
https://gerrit.osmocom.org/c/dahdi-tools/+/27276
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: dahdi-tools
Gerrit-Branch: master
Gerrit-Change-Id: Ief575bc4118fe5f20ef4b374d29eca442b04dabb
Gerrit-Change-Number: 27276
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: manawyrm <osmocom.account(a)tbspace.de>
Gerrit-Reviewer: roox <mardnh(a)gmx.de>
Gerrit-MessageType: merged