@ingroup Hash * @brief Add the sctp association information to the local look up table * * Searches the local look-up table for an existing association with the same * details. If a match exists and is ONLY in the local 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 add
| 2218 | * @return SN_ADD_OK | SN_ADD_CLASH |
| 2219 | */ |
| 2220 | static int |
| 2221 | AddSctpAssocLocal(struct libalias *la, struct sctp_nat_assoc *assoc, struct in_addr g_addr) |
| 2222 | { |
| 2223 | struct sctp_nat_assoc *found; |
| 2224 | |
| 2225 | LIBALIAS_LOCK_ASSERT(la); |
| 2226 | found = FindSctpLocal(la, assoc->l_addr, g_addr, assoc->l_vtag, assoc->l_port, assoc->g_port); |
| 2227 | /* |
| 2228 | * Note that if a different global address initiated this Init, |
| 2229 | * ie it wasn't resent as presumed: |
| 2230 | * - the local receiver if receiving it for the first time will establish |
| 2231 | * an association with the new global host |
| 2232 | * - if receiving an init from a different global address after sending a |
| 2233 | * lost initack it will send an initack to the new global host, the first |
| 2234 | * association attempt will then be blocked if retried. |
| 2235 | */ |
| 2236 | if (found != NULL) { |
| 2237 | if ((found->TableRegister == SN_LOCAL_TBL) && (found->g_port == assoc->g_port)) { /* resent message */ |
| 2238 | RmSctpAssoc(la, found); |
| 2239 | sctp_RmTimeOut(la, found); |
| 2240 | freeGlobalAddressList(found); |
| 2241 | sn_free(found); |
| 2242 | } else |
| 2243 | return (SN_ADD_CLASH); |
| 2244 | } |
| 2245 | |
| 2246 | LIST_INSERT_HEAD(&la->sctpTableLocal[SN_TABLE_HASH(assoc->l_vtag, assoc->l_port, la->sctpNatTableSize)], |
| 2247 | assoc, list_L); |
| 2248 | assoc->TableRegister |= SN_LOCAL_TBL; |
| 2249 | la->sctpLinkCount++; //increment link count |
| 2250 | |
| 2251 | if (assoc->TableRegister == SN_BOTH_TBL) { |
| 2252 | /* libalias log -- controlled by libalias */ |
| 2253 | if (la->packetAliasMode & PKT_ALIAS_LOG) |
| 2254 | SctpShowAliasStats(la); |
| 2255 | |
| 2256 | SN_LOG(SN_LOG_INFO, logsctpassoc(assoc, "^")); |
| 2257 | } |
| 2258 | |
| 2259 | return (SN_ADD_OK); |
| 2260 | } |
| 2261 | |
| 2262 | /** @ingroup Hash |
| 2263 | * @brief Add the sctp association information to the global look up table |
no test coverage detected