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

Function AliasHandlePptpIn

freebsd/netinet/libalias/alias_pptp.c:370–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368}
369
370static void
371AliasHandlePptpIn(struct libalias *la,
372 struct ip *pip, /* IP packet to examine/patch */
373 struct alias_link *lnk)
374{ /* The PPTP control link */
375 struct alias_link *pptp_lnk;
376 PptpCallId cptr;
377 u_int16_t *pcall_id;
378 u_int16_t ctl_type; /* control message type */
379 struct tcphdr *tc;
380
381 /* Verify valid PPTP control message */
382 if ((cptr = AliasVerifyPptp(pip, &ctl_type)) == NULL)
383 return;
384
385 /* Modify certain PPTP messages */
386 switch (ctl_type) {
387 case PPTP_InCallConn:
388 case PPTP_WanErrorNotify:
389 case PPTP_SetLinkInfo:
390 pcall_id = &cptr->cid1;
391 break;
392 case PPTP_OutCallReply:
393 case PPTP_InCallReply:
394 pcall_id = &cptr->cid2;
395 break;
396 case PPTP_CallDiscNotify: /* Connection closed. */
397 pptp_lnk = FindPptpInByCallId(la, GetDestAddress(lnk),
398 GetAliasAddress(lnk),
399 cptr->cid1);
400 if (pptp_lnk != NULL)
401 SetExpire(pptp_lnk, 0);
402 return;
403 default:
404 return;
405 }
406
407 /* Find PPTP link for address and Call ID found in PPTP Control Msg */
408 pptp_lnk = FindPptpInByPeerCallId(la, GetDestAddress(lnk),
409 GetAliasAddress(lnk),
410 *pcall_id);
411
412 if (pptp_lnk != NULL) {
413 int accumulate = *pcall_id;
414
415 /* De-alias the Peer's Call Id. */
416 *pcall_id = GetOriginalPort(pptp_lnk);
417
418 /* Compute TCP checksum for modified packet */
419 tc = (struct tcphdr *)ip_next(pip);
420 accumulate -= *pcall_id;
421 ADJUST_CHECKSUM(accumulate, tc->th_sum);
422
423 if (ctl_type == PPTP_OutCallReply || ctl_type == PPTP_InCallReply) {
424 PptpCode codes = (PptpCode) (cptr + 1);
425
426 if (codes->resCode == 1) /* Connection
427 * established, */

Callers 1

protohandlerinFunction · 0.85

Calls 9

AliasVerifyPptpFunction · 0.85
FindPptpInByCallIdFunction · 0.85
GetDestAddressFunction · 0.85
GetAliasAddressFunction · 0.85
SetExpireFunction · 0.85
FindPptpInByPeerCallIdFunction · 0.85
GetOriginalPortFunction · 0.85
ip_nextFunction · 0.85
SetDestCallIdFunction · 0.85

Tested by

no test coverage detected