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

Function INi_process

freebsd/netinet/libalias/alias_sctp.c:1821–1858  ·  view source on GitHub ↗

@ingroup state_machine * @brief Process SCTP message while waiting for an INIT-ACK message * * Only an INIT-ACK, resent INIT, or an ABORT SCTP packet are valid in this * state, all other packets 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 the ass

Source from the content-addressed store, hash-verified

1819 * @return SN_NAT_PKT | SN_DROP_PKT | SN_REPLY_ABORT
1820 */
1821static int
1822INi_process(struct libalias *la, int direction, struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm)
1823{
1824 switch (sm->msg) {
1825 case SN_SCTP_INIT: /* a packet containing a retransmitted INIT chunk */
1826 sctp_ResetTimeOut(la, assoc, SN_I_T(la));
1827 return (SN_NAT_PKT);
1828 case SN_SCTP_INITACK: /* a packet containing an INIT-ACK chunk */
1829 switch (direction) {
1830 case SN_TO_LOCAL:
1831 if (assoc->num_Gaddr) /*If tracking global addresses for this association */
1832 AddGlobalIPAddresses(sm, assoc, direction);
1833 assoc->l_vtag = sm->sctpchnk.Init->initiate_tag;
1834 if (AddSctpAssocLocal(la, assoc, sm->ip_hdr->ip_src)) { /* DB clash */
1835 assoc->state = SN_RM;/* Mark for removal*/
1836 return (SN_SEND_ABORT);
1837 }
1838 break;
1839 case SN_TO_GLOBAL:
1840 assoc->l_addr = sm->ip_hdr->ip_src; // Only if not set in Init! *
1841 assoc->g_vtag = sm->sctpchnk.Init->initiate_tag;
1842 if (AddSctpAssocGlobal(la, assoc)) { /* DB clash */
1843 assoc->state = SN_RM;/* Mark for removal*/
1844 return (SN_SEND_ABORT);
1845 }
1846 break;
1847 }
1848 assoc->state = SN_UP;/* association established for NAT */
1849 sctp_ResetTimeOut(la,assoc, SN_U_T(la));
1850 return (SN_NAT_PKT);
1851 case SN_SCTP_ABORT: /* a packet containing an ABORT chunk */
1852 assoc->state = SN_RM;/* Mark for removal*/
1853 return (SN_NAT_PKT);
1854 default:
1855 return (SN_DROP_PKT);
1856 }
1857 return (SN_DROP_PKT);/* shouldn't get here very bad: log, drop and hope for the best */
1858}
1859
1860/** @ingroup state_machine
1861 * @brief Process SCTP message while waiting for an AddIp-ACK message

Callers 1

ProcessSctpMsgFunction · 0.85

Calls 4

sctp_ResetTimeOutFunction · 0.85
AddGlobalIPAddressesFunction · 0.85
AddSctpAssocLocalFunction · 0.85
AddSctpAssocGlobalFunction · 0.85

Tested by

no test coverage detected