Skip to content

Commit

Permalink
Merge pull request appneta#204 from P1sec/master
Browse files Browse the repository at this point in the history
tcprewrite: Handle loopback for linux cooked capture files (Linux SLL)
  • Loading branch information
fklassen committed Oct 26, 2015
2 parents d4596a1 + 92a36dd commit 5285dee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tcpedit/plugins/dlt_linuxsll/linuxsll.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ dlt_linuxsll_parse_opts(tcpeditdlt_t *ctx)
int
dlt_linuxsll_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
{
int type;
linux_sll_header_t *linux_sll;
assert(ctx);
assert(packet);
Expand All @@ -185,10 +186,11 @@ dlt_linuxsll_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
ctx->l2len = sizeof(linux_sll_header_t);


if (ntohs(linux_sll->type) == ARPHRD_ETHER) { /* ethernet */
type = ntohs(linux_sll->type);
if (type == ARPHRD_ETHER || type == ARPHRD_LOOPBACK) { /* ethernet or loopback */
memcpy(&(ctx->srcaddr), linux_sll->address, ETHER_ADDR_LEN);
} else {
tcpedit_seterr(ctx->tcpedit, "%s", "DLT_LINUX_SLL pcap's must contain only ethernet packets");
tcpedit_seterr(ctx->tcpedit, "%s", "DLT_LINUX_SLL pcap's must contain only ethernet or loopback packets");
return TCPEDIT_ERROR;
}

Expand Down
1 change: 1 addition & 0 deletions src/tcpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ struct tcpr_arp_hdr
#define ARPHRD_ATM 19 /* ATM */
#define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id) */
#define ARPHRD_IPSEC 31 /* IPsec tunnel */
#define ARPHRD_LOOPBACK 772 /* Loopback device */
uint16_t ar_pro; /* format of protocol address */
uint8_t ar_hln; /* length of hardware address */
uint8_t ar_pln; /* length of protocol addres */
Expand Down

0 comments on commit 5285dee

Please sign in to comment.