From 2e4e8b5fd240d7f3647ba662b43d4e28f62260d7 Mon Sep 17 00:00:00 2001 From: venaas Date: Tue, 27 Jan 2009 14:02:35 +0000 Subject: rewriting code for hosts,ports,resolving,builds but needs testing git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@462 e88ac4ed-0b26-0410-9574-a7f39faa03bf --- hostport.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'hostport.c') diff --git a/hostport.c b/hostport.c index 5f248f2..00c31c8 100644 --- a/hostport.c +++ b/hostport.c @@ -264,3 +264,20 @@ int addressmatches(struct list *hostports, struct sockaddr *addr) { } return 0; } + +int connecttcphostlist(struct list *hostports, struct addrinfo *src) { + int s; + struct list_node *entry; + struct hostportres *hp = NULL; + + for (entry = list_first(hostports); entry; entry = list_next(entry)) { + hp = (struct hostportres *)entry->data; + debug(DBG_WARN, "connecttcphostlist: trying to open TCP connection to %s port %s", hp->host, hp->port); + if ((s = connecttcp(hp->addrinfo, src)) >= 0) { + debug(DBG_WARN, "connecttcphostlist: TCP connection to %s port %s up", hp->host, hp->port); + return s; + } + } + debug(DBG_ERR, "connecttcphostlist: failed"); + return -1; +} -- cgit v1.2.3