Skip to content
Snippets Groups Projects
Commit c53fdd6d authored by deuce's avatar deuce
Browse files

We'll need socket cration callbacks for the socket option settings, and

a bind callback for seteuid() stuff.
parent 81a70dbb
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,7 @@ void xpms_destroy(struct xpms_set *xpms_set) ...@@ -42,7 +42,7 @@ void xpms_destroy(struct xpms_set *xpms_set)
BOOL xpms_add(struct xpms_set *xpms_set, int domain, int type, BOOL xpms_add(struct xpms_set *xpms_set, int domain, int type,
int protocol, const char *addr, uint16_t port, const char *prot, int protocol, const char *addr, uint16_t port, const char *prot,
void *cbdata) void (*sock_init)(SOCKET, void *), void(*bind_init)(BOOL), void *cbdata)
{ {
struct xpms_sockdef *new_socks; struct xpms_sockdef *new_socks;
struct addrinfo hints; struct addrinfo hints;
...@@ -92,13 +92,27 @@ BOOL xpms_add(struct xpms_set *xpms_set, int domain, int type, ...@@ -92,13 +92,27 @@ BOOL xpms_add(struct xpms_set *xpms_set, int domain, int type,
FREE_AND_NULL(xpms_set->socks[xpms_set->sock_count].prot); FREE_AND_NULL(xpms_set->socks[xpms_set->sock_count].prot);
continue; continue;
} }
if(sock_init)
sock_init(cb_data);
if(bind_init) {
if(port < IPPORT_RESERVED && port > 0)
bind_init(FALSE);
}
if(retry_bind(xpms_set->socks[xpms_set->sock_count].sock, cur->ai_addr, cur->ai_addrlen, xpms_set->retries, xpms_set->wait_secs, prot, xpms_set->lprintf)==-1) { if(retry_bind(xpms_set->socks[xpms_set->sock_count].sock, cur->ai_addr, cur->ai_addrlen, xpms_set->retries, xpms_set->wait_secs, prot, xpms_set->lprintf)==-1) {
closesocket(xpms_set->socks[xpms_set->sock_count].sock); closesocket(xpms_set->socks[xpms_set->sock_count].sock);
FREE_AND_NULL(xpms_set->socks[xpms_set->sock_count].address); FREE_AND_NULL(xpms_set->socks[xpms_set->sock_count].address);
FREE_AND_NULL(xpms_set->socks[xpms_set->sock_count].prot); FREE_AND_NULL(xpms_set->socks[xpms_set->sock_count].prot);
if(bind_init) {
if(startup->telnet_port < IPPORT_RESERVED)
bind_init(TRUE);
}
continue; continue;
} }
if(bind_init) {
if(port < IPPORT_RESERVED && && port > 0)
bind_init(TRUE);
}
if(!listen(xpms_set->socks[xpms_set->sock_count].sock, SOMAXCONN)) { if(!listen(xpms_set->socks[xpms_set->sock_count].sock, SOMAXCONN)) {
if(xpms_set->lprintf) if(xpms_set->lprintf)
......
...@@ -30,7 +30,7 @@ struct xpms_set *xpms_create(unsigned int retries, unsigned int wait_secs, ...@@ -30,7 +30,7 @@ struct xpms_set *xpms_create(unsigned int retries, unsigned int wait_secs,
void xpms_destroy(struct xpms_set *xpms_set); void xpms_destroy(struct xpms_set *xpms_set);
BOOL xpms_add(struct xpms_set *xpms_set, int domain, int type, BOOL xpms_add(struct xpms_set *xpms_set, int domain, int type,
int protocol, const char *addr, uint16_t port, const char *prot, int protocol, const char *addr, uint16_t port, const char *prot,
void *cbdata); void (*sock_init)(SOCKET, void *), void(*bind_init)(BOOL), void *cbdata);
SOCKET xpms_accept(struct xpms_set *, struct sockaddr * addr, SOCKET xpms_accept(struct xpms_set *, struct sockaddr * addr,
socklen_t * addrlen, unsigned int timeout, void **cb_data); socklen_t * addrlen, unsigned int timeout, void **cb_data);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment