X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=daemon%2Ffnet-adc.c;h=a72935b17b10acf9b12695f2b40ae1ace5a62481;hb=0d6c5363e8da57e184e5db8306dd4d2a703f5888;hp=459ef9abd108dfe8e8e808d7f91b37a8af31f81f;hpb=5ec60e4217863b0e2d6a86ba3f60f60c68608227;p=doldaconnect.git diff --git a/daemon/fnet-adc.c b/daemon/fnet-adc.c index 459ef9a..a72935b 100644 --- a/daemon/fnet-adc.c +++ b/daemon/fnet-adc.c @@ -192,7 +192,15 @@ static void freeqcmd(struct qcmd *qcmd) } #define ADC_CMDFN(name) static void name(struct fnetnode *fn, wchar_t *command, wchar_t *sender, int argc, wchar_t **argv) -#define ADC_CMDCOM struct socket *sk = fn->sk; struct adchub *hub = fn->data; +#ifdef __GNUC__ +#define ADC_CMDCOM \ + struct socket *sk __attribute__ ((unused)) = fn->sk; \ + struct adchub *hub __attribute__ ((unused)) = fn->data; +#else +#define ADC_CMDCOM \ + struct socket *sk = fn->sk; \ + struct adchub *hub = fn->data; +#endif ADC_CMDFN(cmd_sup) { @@ -286,7 +294,7 @@ static void dispatch(struct qcmd *qcmd, struct fnetnode *fn) flog(LOG_DEBUG, "unknown adc command: %ls", qcmd->args[0]); } -static int hubread(struct socket *sk, struct fnetnode *fn) +static void hubread(struct socket *sk, struct fnetnode *fn) { int ret; struct adchub *hub; @@ -296,7 +304,7 @@ static int hubread(struct socket *sk, struct fnetnode *fn) hub = fn->data; if((newbuf = sockgetinbuf(sk, &datalen)) == NULL) - return(0); + return; if(hub->inbufdata > 1024) hub->inbufdata = 0; bufcat(hub->inbuf, newbuf, datalen); @@ -321,14 +329,14 @@ static int hubread(struct socket *sk, struct fnetnode *fn) if(errno == EILSEQ) { flog(LOG_DEBUG, "adc fnetnode %i sent illegal utf-8 sequence", fn->id); killfnetnode(fn); - return(0); + return; } else if(errno == EINVAL) { break; } else if(errno == E2BIG) { /* continue; */ } else { flog(LOG_WARNING, "bug? iconv returned unexpected error: %s", strerror(errno)); - return(0); + return; } } } @@ -337,21 +345,21 @@ static int hubread(struct socket *sk, struct fnetnode *fn) newqcmd(&hub->queue, parseadc(hub->cb)); memmove(hub->cb, p, (hub->cbdata -= (p - hub->cb)) * sizeof(*(hub->cb))); } - return(0); } -static int huberr(struct socket *sk, int err, struct fnetnode *fn) +static void huberr(struct socket *sk, int err, struct fnetnode *fn) { killfnetnode(fn); - return(0); } static void hubconnect(struct fnetnode *fn) { struct adchub *hub; - CBREG(fn->sk, socket_read, (int (*)(struct socket *, void *))hubread, (void (*)(void *))putfnetnode, fn); - CBREG(fn->sk, socket_err, (int (*)(struct socket *, int, void *))huberr, (void (*)(void *))putfnetnode, fn); + fn->sk->readcb = (void (*)(struct socket *, void *))hubread; + fn->sk->errcb = (void (*)(struct socket *, int, void *))huberr; + fn->sk->data = fn; + getfnetnode(fn); hub = smalloc(sizeof(*hub)); memset(hub, 0, sizeof(*hub)); @@ -469,7 +477,15 @@ static void terminate(void) } static struct configvar myvars[] = { + /** Specifies a specific UDP port to use for ADC search + * results. If left unspecified, a port is allocated + * dynamically. Useful for NAT routers (see also the + * net.visibleipv4 address for those cases). */ {CONF_VAR_INT, "udpport", {.num = 0}}, + /** Specifies a specific TCP port to use for ADC peer + * connections. If left unspecified, a port is allocated + * dynamically. Useful for NAT routers (see also the + * net.visibleipv4 address for those cases). */ {CONF_VAR_INT, "tcpport", {.num = 0}}, {CONF_VAR_END} };