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

Function AliasHandlePptpOut

freebsd/netinet/libalias/alias_pptp.c:298–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296static PptpCallId AliasVerifyPptp(struct ip *, u_int16_t *);
297
298static void
299AliasHandlePptpOut(struct libalias *la,
300 struct ip *pip, /* IP packet to examine/patch */
301 struct alias_link *lnk)
302{ /* The PPTP control link */
303 struct alias_link *pptp_lnk;
304 PptpCallId cptr;
305 PptpCode codes;
306 u_int16_t ctl_type; /* control message type */
307 struct tcphdr *tc;
308
309 /* Verify valid PPTP control message */
310 if ((cptr = AliasVerifyPptp(pip, &ctl_type)) == NULL)
311 return;
312
313 /* Modify certain PPTP messages */
314 switch (ctl_type) {
315 case PPTP_OutCallRequest:
316 case PPTP_OutCallReply:
317 case PPTP_InCallRequest:
318 case PPTP_InCallReply:
319 /*
320 * Establish PPTP link for address and Call ID found in
321 * control message.
322 */
323 pptp_lnk = AddPptp(la, GetOriginalAddress(lnk), GetDestAddress(lnk),
324 GetAliasAddress(lnk), cptr->cid1);
325 break;
326 case PPTP_CallClearRequest:
327 case PPTP_CallDiscNotify:
328 /*
329 * Find PPTP link for address and Call ID found in control
330 * message.
331 */
332 pptp_lnk = FindPptpOutByCallId(la, GetOriginalAddress(lnk),
333 GetDestAddress(lnk),
334 cptr->cid1);
335 break;
336 default:
337 return;
338 }
339
340 if (pptp_lnk != NULL) {
341 int accumulate = cptr->cid1;
342
343 /* alias the Call Id */
344 cptr->cid1 = GetAliasPort(pptp_lnk);
345
346 /* Compute TCP checksum for revised packet */
347 tc = (struct tcphdr *)ip_next(pip);
348 accumulate -= cptr->cid1;
349 ADJUST_CHECKSUM(accumulate, tc->th_sum);
350
351 switch (ctl_type) {
352 case PPTP_OutCallReply:
353 case PPTP_InCallReply:
354 codes = (PptpCode) (cptr + 1);
355 if (codes->resCode == 1) /* Connection

Callers 1

protohandleroutFunction · 0.85

Calls 10

AliasVerifyPptpFunction · 0.85
AddPptpFunction · 0.85
GetOriginalAddressFunction · 0.85
GetDestAddressFunction · 0.85
GetAliasAddressFunction · 0.85
FindPptpOutByCallIdFunction · 0.85
GetAliasPortFunction · 0.85
ip_nextFunction · 0.85
SetDestCallIdFunction · 0.85
SetExpireFunction · 0.85

Tested by

no test coverage detected