MCPcopy Create free account
hub / github.com/F-Stack/f-stack / AliasHandlePptpGreIn

Function AliasHandlePptpGreIn

freebsd/netinet/libalias/alias_pptp.c:497–522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495}
496
497static int
498AliasHandlePptpGreIn(struct libalias *la, struct ip *pip)
499{
500 GreHdr *gr;
501 struct alias_link *lnk;
502
503 gr = (GreHdr *) ip_next(pip);
504
505 /* Check GRE header bits. */
506 if ((ntohl(*((u_int32_t *) gr)) & PPTP_INIT_MASK) != PPTP_INIT_VALUE)
507 return (-1);
508
509 lnk = FindPptpInByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
510 if (lnk != NULL) {
511 struct in_addr src_addr = GetOriginalAddress(lnk);
512
513 /* De-alias the Peer's Call Id. */
514 gr->gh_call_id = GetOriginalPort(lnk);
515
516 /* Restore original IP address. */
517 DifferentialChecksum(&pip->ip_sum,
518 &src_addr, &pip->ip_dst, 2);
519 pip->ip_dst = src_addr;
520 }
521 return (0);
522}

Callers 1

protohandlergreinFunction · 0.85

Calls 5

ip_nextFunction · 0.85
FindPptpInByPeerCallIdFunction · 0.85
GetOriginalAddressFunction · 0.85
GetOriginalPortFunction · 0.85
DifferentialChecksumFunction · 0.85

Tested by

no test coverage detected