Skip to content

Commit a63600a

Browse files
committed
gre: add support for MikroTik Ethernet-over-IP hack.
More from OpenBSD's tcpdump.
1 parent 2654afb commit a63600a

File tree

1 file changed

+46
-3
lines changed

1 file changed

+46
-3
lines changed

print-gre.c

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ static const struct tok gre_flag_values[] = {
8686
*/
8787
#define GRE_CDP 0x2000 /* Cisco Discovery Protocol */
8888
#define GRE_NHRP 0x2001 /* Next Hop Resolution Protocol */
89+
#define GRE_MIKROTIK_EOIP 0x6400 /* MikroTik RouterBoard Ethernet over IP (EoIP) */
8990
#define GRE_ERSPAN_III 0x22eb
9091
#define GRE_WCCP 0x883e /* Web Cache C* Protocol */
9192
#define GRE_ERSPAN_I_II 0x88be
@@ -348,6 +349,31 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
348349
len -= 2;
349350
bp += 2;
350351

352+
/*
353+
* This version is used for two purposes:
354+
*
355+
* RFC 2637 PPTP;
356+
* Some Mikrotik Ethernet-over-IP hack.
357+
*/
358+
switch (prot) {
359+
case GRE_MIKROTIK_EOIP:
360+
/*
361+
* The MikroTik hack uses only the key field, and uses it
362+
* for its own purposes. If anything other than the version
363+
* and K bit are set, report an error and give up.
364+
*/
365+
if ((flags & ~GRE_VERS_MASK) != GRE_KP) {
366+
ND_PRINT(" unknown-eoip-flags-%04x!", flags);
367+
return;
368+
}
369+
break;
370+
default:
371+
/*
372+
* XXX - what should we do if it's not ETHERTYPE_PPP?
373+
*/
374+
break;
375+
}
376+
351377
if (flags & GRE_KP) {
352378
/* Skip payload length? */
353379
ND_ICHECK_U(len, <, 2);
@@ -356,7 +382,11 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
356382
bp += 2;
357383

358384
ND_ICHECK_U(len, <, 2);
359-
ND_PRINT(", call %u", GET_BE_U_2(bp));
385+
if (prot == GRE_MIKROTIK_EOIP) {
386+
/* Non-standard */
387+
ND_PRINT(", tunnel-id %u", GET_BE_U_2(bp));
388+
} else
389+
ND_PRINT(", call %u", GET_BE_U_2(bp));
360390
len -= 2;
361391
bp += 2;
362392
} else
@@ -376,7 +406,10 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
376406
len -= 4;
377407
}
378408

379-
if ((flags & GRE_SP) == 0)
409+
/*
410+
* More non-standard EoIP behavior.
411+
*/
412+
if (prot != GRE_MIKROTIK_EOIP && (flags & GRE_SP) == 0)
380413
ND_PRINT(", no-payload");
381414

382415
if (ndo->ndo_eflag)
@@ -385,7 +418,10 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
385418

386419
ND_PRINT(", length %u",length);
387420

388-
if ((flags & GRE_SP) == 0)
421+
/*
422+
* More non-standard EoIP behavior.
423+
*/
424+
if (prot != GRE_MIKROTIK_EOIP && (flags & GRE_SP) == 0)
389425
return;
390426

391427
if (ndo->ndo_vflag < 1)
@@ -397,6 +433,13 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
397433
case ETHERTYPE_PPP:
398434
ppp_print(ndo, bp, len);
399435
break;
436+
case GRE_MIKROTIK_EOIP:
437+
/* MikroTik RouterBoard Ethernet over IP (EoIP) */
438+
if (len == 0)
439+
ND_PRINT("keepalive");
440+
else
441+
ether_print(ndo, bp, len, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL);
442+
break;
400443
default:
401444
ND_PRINT("gre-proto-0x%x", prot);
402445
break;

0 commit comments

Comments
 (0)