| 296 | static PptpCallId AliasVerifyPptp(struct ip *, u_int16_t *); |
| 297 | |
| 298 | static void |
| 299 | AliasHandlePptpOut(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 |
no test coverage detected