X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=regress%2Fhcommon.c;h=301fb2f53446fd2596c42b2e14b6b03ad8e8e258;hb=f80690def49ab15ee32f01aaa3d2577807fef4ce;hp=0324e5803ffbd4abde12c6387d096864c72d69d6;hpb=0e45654b30d8dd31eb4ab9f32ca0bbee7d1c2c6d;p=adns.git diff --git a/regress/hcommon.c b/regress/hcommon.c index 0324e58..301fb2f 100644 --- a/regress/hcommon.c +++ b/regress/hcommon.c @@ -67,9 +67,12 @@ void Qpoll( const struct pollfd *fds , int nfds , int timeout ) { Q_vb(); } #endif -void Qsocket( int type ) { +void Qsocket( int domain , int type ) { vb.used= 0; Tvba("socket"); + Tvbf(domain==AF_INET ? " domain=AF_INET" : + domain==AF_INET6 ? " domain=AF_INET6" : + " domain=AF_???"); Tvbf(type==SOCK_STREAM ? " type=SOCK_STREAM" : " type=SOCK_DGRAM"); Q_vb(); } @@ -126,7 +129,6 @@ void Qrecvfrom( int fd , int buflen , int addrlen ) { Tvba("recvfrom"); Tvbf(" fd=%d",fd); Tvbf(" buflen=%lu",(unsigned long)buflen); - Tvbf(" *addrlen=%d",addrlen); Q_vb(); } void Qread( int fd , size_t buflen ) { @@ -144,10 +146,12 @@ void Qwrite( int fd , const void *buf , size_t len ) { Q_vb(); } void Tvbaddr(const struct sockaddr *addr, int len) { - const struct sockaddr_in *ai= (const struct sockaddr_in*)addr; - assert(len==sizeof(struct sockaddr_in)); - assert(ai->sin_family==AF_INET); - Tvbf("%s:%u",inet_ntoa(ai->sin_addr),htons(ai->sin_port)); + char buf[ADNS_ADDR2TEXT_BUFLEN]; + int err, port; + int sz= sizeof(buf); + err= adns_addr2text(addr, 0, buf,&sz, &port); + assert(!err); + Tvbf(strchr(buf, ':') ? "[%s]:%d" : "%s:%d", buf,port); } void Tvbbytes(const void *buf, int len) { const byte *bp; @@ -163,6 +167,10 @@ void Tvbbytes(const void *buf, int len) { void Tvbfdset(int max, const fd_set *fds) { int i; const char *comma= ""; + if (!fds) { + Tvba("null"); + return; + } Tvba("["); for (i=0; isz; } else { osz= 0; } np= Hmalloc(nsz); - memcpy(np,op, osz>nsz ? nsz : osz); + if (osz) memcpy(np,op, osz>nsz ? nsz : osz); Hfree(op); return np; }