Add server to the pool of servers */
| 2246 | |
| 2247 | /* Add server to the pool of servers */ |
| 2248 | int |
| 2249 | LibAliasAddServer(struct libalias *la, struct alias_link *lnk, struct in_addr addr, u_short port) |
| 2250 | { |
| 2251 | struct server *server; |
| 2252 | int res; |
| 2253 | |
| 2254 | LIBALIAS_LOCK(la); |
| 2255 | (void)la; |
| 2256 | |
| 2257 | server = malloc(sizeof(struct server)); |
| 2258 | |
| 2259 | if (server != NULL) { |
| 2260 | struct server *head; |
| 2261 | |
| 2262 | server->addr = addr; |
| 2263 | server->port = port; |
| 2264 | |
| 2265 | head = lnk->server; |
| 2266 | if (head == NULL) |
| 2267 | server->next = server; |
| 2268 | else { |
| 2269 | struct server *s; |
| 2270 | |
| 2271 | for (s = head; s->next != head; s = s->next); |
| 2272 | s->next = server; |
| 2273 | server->next = head; |
| 2274 | } |
| 2275 | lnk->server = server; |
| 2276 | res = 0; |
| 2277 | } else |
| 2278 | res = -1; |
| 2279 | |
| 2280 | LIBALIAS_UNLOCK(la); |
| 2281 | return (res); |
| 2282 | } |
| 2283 | |
| 2284 | /* Redirect packets of a given IP protocol from a specific |
| 2285 | public address to a private address */ |
no test coverage detected