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

Function AddSctpAssocGlobal

freebsd/netinet/libalias/alias_sctp.c:2277–2309  ·  view source on GitHub ↗

@ingroup Hash * @brief Add the sctp association information to the global look up table * * Searches the global look-up table for an existing association with the same * details. If a match exists and is ONLY in the global look-up table then this * is a repeated INIT packet, we need to remove this association from the * look-up table and add the new association * * The new association is

Source from the content-addressed store, hash-verified

2275 * @return SN_ADD_OK | SN_ADD_CLASH
2276 */
2277static int
2278AddSctpAssocGlobal(struct libalias *la, struct sctp_nat_assoc *assoc)
2279{
2280 struct sctp_nat_assoc *found;
2281
2282 LIBALIAS_LOCK_ASSERT(la);
2283 found = FindSctpGlobalClash(la, assoc);
2284 if (found != NULL) {
2285 if ((found->TableRegister == SN_GLOBAL_TBL) && \
2286 (found->l_addr.s_addr == assoc->l_addr.s_addr) && (found->l_port == assoc->l_port)) { /* resent message */
2287 RmSctpAssoc(la, found);
2288 sctp_RmTimeOut(la, found);
2289 freeGlobalAddressList(found);
2290 sn_free(found);
2291 } else
2292 return (SN_ADD_CLASH);
2293 }
2294
2295 LIST_INSERT_HEAD(&la->sctpTableGlobal[SN_TABLE_HASH(assoc->g_vtag, assoc->g_port, la->sctpNatTableSize)],
2296 assoc, list_G);
2297 assoc->TableRegister |= SN_GLOBAL_TBL;
2298 la->sctpLinkCount++; //increment link count
2299
2300 if (assoc->TableRegister == SN_BOTH_TBL) {
2301 /* libalias log -- controlled by libalias */
2302 if (la->packetAliasMode & PKT_ALIAS_LOG)
2303 SctpShowAliasStats(la);
2304
2305 SN_LOG(SN_LOG_INFO, logsctpassoc(assoc, "^"));
2306 }
2307
2308 return (SN_ADD_OK);
2309}
2310
2311/** @ingroup Hash
2312 * @brief Remove the sctp association information from the look up table

Callers 2

ID_processFunction · 0.85
INi_processFunction · 0.85

Calls 6

FindSctpGlobalClashFunction · 0.85
RmSctpAssocFunction · 0.85
sctp_RmTimeOutFunction · 0.85
freeGlobalAddressListFunction · 0.85
SctpShowAliasStatsFunction · 0.85
logsctpassocFunction · 0.85

Tested by

no test coverage detected