Commit 392c109a authored by venaas's avatar venaas Committed by venaas

minor fixes to hostport stuff

git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@464 e88ac4ed-0b26-0410-9574-a7f39faa03bf
parent 9f542fc2
......@@ -14,7 +14,7 @@
#include "list.h"
#include "hostport.h"
static void freehostport(struct hostportres *hp) {
void freehostport(struct hostportres *hp) {
if (hp) {
free(hp->host);
free(hp->port);
......@@ -74,7 +74,7 @@ static int parsehostport(struct hostportres *hp, char *hostport, char *default_p
return 1;
}
static struct hostportres *newhostport(char *hostport, char *default_port, uint8_t prefixok) {
struct hostportres *newhostport(char *hostport, char *default_port, uint8_t prefixok) {
struct hostportres *hp;
char *slash, *s;
int plen;
......@@ -126,7 +126,7 @@ static struct hostportres *newhostport(char *hostport, char *default_port, uint8
return NULL;
}
static int resolvehostport(struct hostportres *hp, int socktype, uint8_t passive) {
int resolvehostport(struct hostportres *hp, int socktype, uint8_t passive) {
struct addrinfo hints, *res;
memset(&hints, 0, sizeof(hints));
......
......@@ -13,8 +13,11 @@ struct hostportres {
struct addrinfo *addrinfo;
};
struct hostportres *newhostport(char *hostport, char *default_port, uint8_t prefixok);
int addhostport(struct list **hostports, char *hostport, char *portdefault, uint8_t prefixok);
void freehostport(struct hostportres *hp);
void freehostports(struct list *hostports);
int resolvehostport(struct hostportres *hp, int socktype, uint8_t passive);
int resolvehostports(struct list *hostports, int socktype);
struct addrinfo *resolvepassiveaddrinfo(char *hostport, char *default_port, int socktype);
int addressmatches(struct list *hostports, struct sockaddr *addr);
......
......@@ -1884,14 +1884,14 @@ void *clientwr(void *arg) {
void createlistener(uint8_t type, char *arg) {
pthread_t th;
struct addrinfo *listenres, *res;
struct addrinfo *res;
int s = -1, on = 1, *sp = NULL;
listenres = resolvepassiveaddrinfo(arg, protodefs[type]->portdefault, protodefs[type]->socktype);
if (!listenres)
struct hostportres *hp = newhostport(arg, protodefs[type]->portdefault, 0);
if (!hp || !resolvehostport(hp, protodefs[type]->socktype, 1))
debugx(1, DBG_ERR, "createlistener: failed to resolve %s", arg);
for (res = listenres; res; res = res->ai_next) {
for (res = hp->addrinfo; res; res = res->ai_next) {
s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (s < 0) {
debug(DBG_WARN, "createlistener: socket failed");
......@@ -1920,8 +1920,8 @@ void createlistener(uint8_t type, char *arg) {
if (!sp)
debugx(1, DBG_ERR, "createlistener: socket/bind failed");
debug(DBG_WARN, "createlistener: listening for %s on %s", protodefs[type]->name, arg);
freeaddrinfo(listenres);
debug(DBG_WARN, "createlistener: listening for %s on %s:%s", protodefs[type]->name, hp->host ? hp->host : "*", hp->port);
freehostport(hp);
}
void createlisteners(uint8_t type) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment