@ingroup Hash * @brief Find the SCTP association for a T-Flag message (given the global port and local vtag) * * Searches the local look-up table for a unique association entry matching the * provided global port and local vtag information * * @param la Pointer to the relevant libalias instance * @param g_addr global address * @param l_vtag local Vtag * @param g_port global Port * @param
| 2135 | * @return pointer to association or NULL |
| 2136 | */ |
| 2137 | static struct sctp_nat_assoc* |
| 2138 | FindSctpLocalT(struct libalias *la, struct in_addr g_addr, uint32_t l_vtag, uint16_t g_port, uint16_t l_port) |
| 2139 | { |
| 2140 | u_int i; |
| 2141 | struct sctp_nat_assoc *assoc = NULL, *lastmatch = NULL; |
| 2142 | struct sctp_GlobalAddress *G_Addr = NULL; |
| 2143 | int cnt = 0; |
| 2144 | |
| 2145 | if (l_vtag != 0) { /* an init packet, vtag==0 */ |
| 2146 | i = SN_TABLE_HASH(l_vtag, g_port, la->sctpNatTableSize); |
| 2147 | LIST_FOREACH(assoc, &la->sctpTableGlobal[i], list_G) { |
| 2148 | if ((assoc->g_vtag == l_vtag) && (assoc->g_port == g_port) && (assoc->l_port == l_port)) { |
| 2149 | if (assoc->num_Gaddr) { |
| 2150 | LIST_FOREACH(G_Addr, &(assoc->Gaddr), list_Gaddr) { |
| 2151 | if (G_Addr->g_addr.s_addr == g_addr.s_addr) |
| 2152 | return (assoc); /* full match */ |
| 2153 | } |
| 2154 | } else { |
| 2155 | if (++cnt > 1) return (NULL); |
| 2156 | lastmatch = assoc; |
| 2157 | } |
| 2158 | } |
| 2159 | } |
| 2160 | } |
| 2161 | /* If there is more than one match we do not know which local address to send to */ |
| 2162 | return (cnt ? lastmatch : NULL); |
| 2163 | } |
| 2164 | |
| 2165 | /** @ingroup Hash |
| 2166 | * @brief Find the SCTP association for a T-Flag message (given the local port and global vtag) |