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

Function ID_process

freebsd/netinet/libalias/alias_sctp.c:1752–1806  ·  view source on GitHub ↗

@ingroup state_machine * @brief Process SCTP message while in the Idle state * * This function looks for an Incoming INIT or AddIP message. * * All other SCTP messages are invalid when in SN_ID, and are dropped. * * @param la Pointer to the relevant libalias instance * @param direction SN_TO_LOCAL | SN_TO_GLOBAL * @param sm Pointer to sctp message information * @param assoc Pointer to th

Source from the content-addressed store, hash-verified

1750 * @return SN_NAT_PKT | SN_DROP_PKT | SN_REPLY_ABORT | SN_REPLY_ERROR
1751 */
1752static int
1753ID_process(struct libalias *la, int direction, struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm)
1754{
1755 switch (sm->msg) {
1756 case SN_SCTP_ASCONF: /* a packet containing an ASCONF chunk with ADDIP */
1757 if (!sysctl_accept_global_ootb_addip && (direction == SN_TO_LOCAL))
1758 return (SN_DROP_PKT);
1759 /* if this Asconf packet does not contain the Vtag parameters it is of no use in Idle state */
1760 if (!GetAsconfVtags(la, sm, &(assoc->l_vtag), &(assoc->g_vtag), direction))
1761 return (SN_DROP_PKT);
1762 /* FALLTHROUGH */
1763 case SN_SCTP_INIT: /* a packet containing an INIT chunk or an ASCONF AddIP */
1764 if (sysctl_track_global_addresses)
1765 AddGlobalIPAddresses(sm, assoc, direction);
1766 switch (direction) {
1767 case SN_TO_GLOBAL:
1768 assoc->l_addr = sm->ip_hdr->ip_src;
1769 assoc->a_addr = FindAliasAddress(la, assoc->l_addr);
1770 assoc->l_port = sm->sctp_hdr->src_port;
1771 assoc->g_port = sm->sctp_hdr->dest_port;
1772 if (sm->msg == SN_SCTP_INIT)
1773 assoc->g_vtag = sm->sctpchnk.Init->initiate_tag;
1774 if (AddSctpAssocGlobal(la, assoc)) /* DB clash *///**** need to add dst address
1775 return ((sm->msg == SN_SCTP_INIT) ? SN_REPLY_ABORT : SN_REPLY_ERROR);
1776 if (sm->msg == SN_SCTP_ASCONF) {
1777 if (AddSctpAssocLocal(la, assoc, sm->ip_hdr->ip_dst)) /* DB clash */
1778 return (SN_REPLY_ERROR);
1779 assoc->TableRegister |= SN_WAIT_TOLOCAL; /* wait for tolocal ack */
1780 }
1781 break;
1782 case SN_TO_LOCAL:
1783 assoc->l_addr = FindSctpRedirectAddress(la, sm);
1784 assoc->a_addr = sm->ip_hdr->ip_dst;
1785 assoc->l_port = sm->sctp_hdr->dest_port;
1786 assoc->g_port = sm->sctp_hdr->src_port;
1787 if (sm->msg == SN_SCTP_INIT)
1788 assoc->l_vtag = sm->sctpchnk.Init->initiate_tag;
1789 if (AddSctpAssocLocal(la, assoc, sm->ip_hdr->ip_src)) /* DB clash */
1790 return ((sm->msg == SN_SCTP_INIT) ? SN_REPLY_ABORT : SN_REPLY_ERROR);
1791 if (sm->msg == SN_SCTP_ASCONF) {
1792 if (AddSctpAssocGlobal(la, assoc)) /* DB clash */ //**** need to add src address
1793 return (SN_REPLY_ERROR);
1794 assoc->TableRegister |= SN_WAIT_TOGLOBAL; /* wait for toglobal ack */
1795 }
1796 break;
1797 }
1798 assoc->state = (sm->msg == SN_SCTP_INIT) ? SN_INi : SN_INa;
1799 assoc->exp = SN_I_T(la);
1800 sctp_AddTimeOut(la,assoc);
1801 return (SN_NAT_PKT);
1802 default: /* Any other type of SCTP message is not valid in Idle */
1803 return (SN_DROP_PKT);
1804 }
1805 return (SN_DROP_PKT);/* shouldn't get here very bad: log, drop and hope for the best */
1806}
1807
1808/** @ingroup state_machine
1809 * @brief Process SCTP message while waiting for an INIT-ACK message

Callers 1

ProcessSctpMsgFunction · 0.85

Calls 7

GetAsconfVtagsFunction · 0.85
AddGlobalIPAddressesFunction · 0.85
FindAliasAddressFunction · 0.85
AddSctpAssocGlobalFunction · 0.85
AddSctpAssocLocalFunction · 0.85
FindSctpRedirectAddressFunction · 0.85
sctp_AddTimeOutFunction · 0.85

Tested by

no test coverage detected