* @brief Handles SCTP packets passed from libalias * * This function needs to actually NAT/drop packets and possibly create and * send AbortM or ErrorM packets in response. The process involves: * - Validating the direction parameter passed by the caller * - Checking and handling any expired timers for the NAT * - Calling sctp_PktParser() to parse the packet * - Call ProcessSctpMsg() to dec
| 724 | * @return PKT_ALIAS_OK | PKT_ALIAS_IGNORE | PKT_ALIAS_ERROR |
| 725 | */ |
| 726 | int |
| 727 | SctpAlias(struct libalias *la, struct ip *pip, int direction) |
| 728 | { |
| 729 | int rtnval; |
| 730 | struct sctp_nat_msg msg; |
| 731 | struct sctp_nat_assoc *assoc = NULL; |
| 732 | |
| 733 | if ((direction != SN_TO_LOCAL) && (direction != SN_TO_GLOBAL)) { |
| 734 | SctpAliasLog("ERROR: Invalid direction\n"); |
| 735 | return (PKT_ALIAS_ERROR); |
| 736 | } |
| 737 | |
| 738 | sctp_CheckTimers(la); /* Check timers */ |
| 739 | |
| 740 | /* Parse the packet */ |
| 741 | rtnval = sctp_PktParser(la, direction, pip, &msg, &assoc); //using *char (change to mbuf when get code from paolo) |
| 742 | switch (rtnval) { |
| 743 | case SN_PARSE_OK: |
| 744 | break; |
| 745 | case SN_PARSE_ERROR_CHHL: |
| 746 | /* Not an error if there is a chunk length parsing error and this is a fragmented packet */ |
| 747 | if (ntohs(pip->ip_off) & IP_MF) { |
| 748 | rtnval = SN_PARSE_OK; |
| 749 | break; |
| 750 | } |
| 751 | SN_LOG(SN_LOG_EVENT, |
| 752 | logsctperror("SN_PARSE_ERROR", msg.sctp_hdr->v_tag, rtnval, direction)); |
| 753 | return (PKT_ALIAS_ERROR); |
| 754 | case SN_PARSE_ERROR_PARTIALLOOKUP: |
| 755 | if (sysctl_error_on_ootb > SN_LOCALandPARTIAL_ERROR_ON_OOTB) { |
| 756 | SN_LOG(SN_LOG_EVENT, |
| 757 | logsctperror("SN_PARSE_ERROR", msg.sctp_hdr->v_tag, rtnval, direction)); |
| 758 | return (PKT_ALIAS_ERROR); |
| 759 | } |
| 760 | case SN_PARSE_ERROR_LOOKUP: |
| 761 | if (sysctl_error_on_ootb == SN_ERROR_ON_OOTB || |
| 762 | (sysctl_error_on_ootb == SN_LOCALandPARTIAL_ERROR_ON_OOTB && direction == SN_TO_LOCAL) || |
| 763 | (sysctl_error_on_ootb == SN_LOCAL_ERROR_ON_OOTB && direction == SN_TO_GLOBAL)) { |
| 764 | TxAbortErrorM(la, &msg, assoc, SN_REFLECT_ERROR, direction); /*NB assoc=NULL */ |
| 765 | return (PKT_ALIAS_RESPOND); |
| 766 | } |
| 767 | default: |
| 768 | SN_LOG(SN_LOG_EVENT, |
| 769 | logsctperror("SN_PARSE_ERROR", msg.sctp_hdr->v_tag, rtnval, direction)); |
| 770 | return (PKT_ALIAS_ERROR); |
| 771 | } |
| 772 | |
| 773 | SN_LOG(SN_LOG_DETAIL, |
| 774 | logsctpassoc(assoc, "*"); |
| 775 | logsctpparse(direction, &msg); |
| 776 | ); |
| 777 | |
| 778 | /* Process the SCTP message */ |
| 779 | rtnval = ProcessSctpMsg(la, direction, &msg, assoc); |
| 780 | |
| 781 | SN_LOG(SN_LOG_DEBUG_MAX, |
| 782 | logsctpassoc(assoc, "-"); |
| 783 | logSctpLocal(la); |
no test coverage detected