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

Function SctpAlias

freebsd/netinet/libalias/alias_sctp.c:726–845  ·  view source on GitHub ↗

* @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

Source from the content-addressed store, hash-verified

724 * @return PKT_ALIAS_OK | PKT_ALIAS_IGNORE | PKT_ALIAS_ERROR
725 */
726int
727SctpAlias(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);

Callers 2

LibAliasInLockedFunction · 0.85
LibAliasOutLockedFunction · 0.85

Calls 15

SctpAliasLogFunction · 0.85
sctp_CheckTimersFunction · 0.85
sctp_PktParserFunction · 0.85
logsctperrorFunction · 0.85
TxAbortErrorMFunction · 0.85
logsctpassocFunction · 0.85
logsctpparseFunction · 0.85
ProcessSctpMsgFunction · 0.85
logSctpLocalFunction · 0.85
logSctpGlobalFunction · 0.85
logTimerQFunction · 0.85
DifferentialChecksumFunction · 0.85

Tested by

no test coverage detected