1 /* Based on ipsvd utilities written by Gerrit Pape <pape@smarden.org>
2 * which are released into public domain by the author.
3 * Homepage: http://smarden.sunsite.dk/ipsvd/
5 * Copyright (C) 2007 Denys Vlasenko.
7 * Licensed under GPLv2, see file LICENSE in this source tree.
11 #include "tcpudp_perhost.h"
13 static struct hcc *cc;
14 static unsigned cclen;
18 void ipsvd_perhost_init(unsigned c)
21 cc = xzalloc(c * sizeof(*cc));
25 unsigned ipsvd_perhost_add(char *ip, unsigned maxconn, struct hcc **hccpp)
31 for (i = 0; i < cclen; ++i) {
36 if (strcmp(cc[i].ip, ip) == 0) {
41 if (freepos == -1) return 0;
42 if (conn <= maxconn) {
44 *hccpp = &cc[freepos];
49 void ipsvd_perhost_remove(int pid)
52 for (i = 0; i < cclen; ++i) {
53 if (cc[i].pid == pid) {
62 //void ipsvd_perhost_free(void)