| 434 | } |
| 435 | |
| 436 | static PptpCallId |
| 437 | AliasVerifyPptp(struct ip *pip, u_int16_t * ptype) |
| 438 | { /* IP packet to examine/patch */ |
| 439 | int hlen, tlen, dlen; |
| 440 | PptpMsgHead hptr; |
| 441 | struct tcphdr *tc; |
| 442 | |
| 443 | /* Calculate some lengths */ |
| 444 | tc = (struct tcphdr *)ip_next(pip); |
| 445 | hlen = (pip->ip_hl + tc->th_off) << 2; |
| 446 | tlen = ntohs(pip->ip_len); |
| 447 | dlen = tlen - hlen; |
| 448 | |
| 449 | /* Verify data length */ |
| 450 | if (dlen < (int)(sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds))) |
| 451 | return (NULL); |
| 452 | |
| 453 | /* Move up to PPTP message header */ |
| 454 | hptr = (PptpMsgHead) tcp_next(tc); |
| 455 | |
| 456 | /* Return the control message type */ |
| 457 | *ptype = ntohs(hptr->type); |
| 458 | |
| 459 | /* Verify PPTP Control Message */ |
| 460 | if ((ntohs(hptr->msgType) != PPTP_CTRL_MSG_TYPE) || |
| 461 | (ntohl(hptr->magic) != PPTP_MAGIC)) |
| 462 | return (NULL); |
| 463 | |
| 464 | /* Verify data length. */ |
| 465 | if ((*ptype == PPTP_OutCallReply || *ptype == PPTP_InCallReply) && |
| 466 | (dlen < (int)(sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds) + |
| 467 | sizeof(struct pptpCodes)))) |
| 468 | return (NULL); |
| 469 | else |
| 470 | return (PptpCallId) (hptr + 1); |
| 471 | } |
| 472 | |
| 473 | static int |
| 474 | AliasHandlePptpGreOut(struct libalias *la, struct ip *pip) |
no test coverage detected