diff options
author | Stefan Metzmacher <metze@samba.org> | 2010-08-27 11:42:05 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2010-08-27 13:00:26 +0200 |
commit | 44b2a7941c1da4c565cb14bae7acc355787ecc6e (patch) | |
tree | 069e627963275c54842ca3a665a0c95c2c87b6aa /lib/tsocket | |
parent | 8e1d3b5f8fe4b5bbb61a357e9db62adad7d767f1 (diff) | |
download | samba-44b2a7941c1da4c565cb14bae7acc355787ecc6e.tar.gz samba-44b2a7941c1da4c565cb14bae7acc355787ecc6e.tar.xz samba-44b2a7941c1da4c565cb14bae7acc355787ecc6e.zip |
lib/tsocket: sa_socklen is a macro on irix, so better use sasocklen
metze
Diffstat (limited to 'lib/tsocket')
-rw-r--r-- | lib/tsocket/tsocket.h | 16 | ||||
-rw-r--r-- | lib/tsocket/tsocket_bsd.c | 58 | ||||
-rw-r--r-- | lib/tsocket/tsocket_guide.txt | 4 |
3 files changed, 39 insertions, 39 deletions
diff --git a/lib/tsocket/tsocket.h b/lib/tsocket/tsocket.h index 3dd96664ea..fb76fe5d8f 100644 --- a/lib/tsocket/tsocket.h +++ b/lib/tsocket/tsocket.h @@ -843,7 +843,7 @@ struct sockaddr; * * @param[in] sa The sockaddr structure to convert. * - * @param[in] sa_socklen The lenth of the sockaddr sturucte. + * @param[in] sasocklen The lenth of the sockaddr sturucte. * * @param[out] addr The tsocket pointer to allocate and fill. * @@ -851,17 +851,17 @@ struct sockaddr; */ int tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx, struct sockaddr *sa, - size_t sa_socklen, + size_t sasocklen, struct tsocket_address **addr); #else int _tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx, struct sockaddr *sa, - size_t sa_socklen, + size_t sasocklen, struct tsocket_address **_addr, const char *location); -#define tsocket_address_bsd_from_sockaddr(mem_ctx, sa, sa_socklen, _addr) \ - _tsocket_address_bsd_from_sockaddr(mem_ctx, sa, sa_socklen, _addr, \ +#define tsocket_address_bsd_from_sockaddr(mem_ctx, sa, sasocklen, _addr) \ + _tsocket_address_bsd_from_sockaddr(mem_ctx, sa, sasocklen, _addr, \ __location__) #endif @@ -872,10 +872,10 @@ int _tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx, * * @param[in] sa The bsd sockaddr structure to fill out. * - * @param[in] sa_socklen The length of the bsd sockaddr structure to fill out. + * @param[in] sasocklen The length of the bsd sockaddr structure to fill out. * * @return The actual size of the sockaddr structure, -1 on error - * with errno set. The size could differ from sa_socklen. + * with errno set. The size could differ from sasocklen. * * @code * ssize_t socklen; @@ -891,7 +891,7 @@ int _tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx, */ ssize_t tsocket_address_bsd_sockaddr(const struct tsocket_address *addr, struct sockaddr *sa, - size_t sa_socklen); + size_t sasocklen); #ifdef DOXYGEN /** diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c index dfc9685bc9..c8322f8052 100644 --- a/lib/tsocket/tsocket_bsd.c +++ b/lib/tsocket/tsocket_bsd.c @@ -190,7 +190,7 @@ static ssize_t tsocket_bsd_pending(int fd) static const struct tsocket_address_ops tsocket_address_bsd_ops; struct tsocket_address_bsd { - socklen_t sa_socklen; + socklen_t sasocklen; union { struct sockaddr sa; struct sockaddr_in in; @@ -204,38 +204,38 @@ struct tsocket_address_bsd { int _tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx, struct sockaddr *sa, - size_t sa_socklen, + size_t sasocklen, struct tsocket_address **_addr, const char *location) { struct tsocket_address *addr; struct tsocket_address_bsd *bsda; - if (sa_socklen < sizeof(sa->sa_family)) { + if (sasocklen < sizeof(sa->sa_family)) { errno = EINVAL; return -1; } switch (sa->sa_family) { case AF_UNIX: - if (sa_socklen > sizeof(struct sockaddr_un)) { - sa_socklen = sizeof(struct sockaddr_un); + if (sasocklen > sizeof(struct sockaddr_un)) { + sasocklen = sizeof(struct sockaddr_un); } break; case AF_INET: - if (sa_socklen < sizeof(struct sockaddr_in)) { + if (sasocklen < sizeof(struct sockaddr_in)) { errno = EINVAL; return -1; } - sa_socklen = sizeof(struct sockaddr_in); + sasocklen = sizeof(struct sockaddr_in); break; #ifdef HAVE_IPV6 case AF_INET6: - if (sa_socklen < sizeof(struct sockaddr_in6)) { + if (sasocklen < sizeof(struct sockaddr_in6)) { errno = EINVAL; return -1; } - sa_socklen = sizeof(struct sockaddr_in6); + sasocklen = sizeof(struct sockaddr_in6); break; #endif default: @@ -243,7 +243,7 @@ int _tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx, return -1; } - if (sa_socklen > sizeof(struct sockaddr_storage)) { + if (sasocklen > sizeof(struct sockaddr_storage)) { errno = EINVAL; return -1; } @@ -260,9 +260,9 @@ int _tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx, ZERO_STRUCTP(bsda); - memcpy(&bsda->u.ss, sa, sa_socklen); + memcpy(&bsda->u.ss, sa, sasocklen); - bsda->sa_socklen = sa_socklen; + bsda->sasocklen = sasocklen; *_addr = addr; return 0; @@ -270,7 +270,7 @@ int _tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx, ssize_t tsocket_address_bsd_sockaddr(const struct tsocket_address *addr, struct sockaddr *sa, - size_t sa_socklen) + size_t sasocklen) { struct tsocket_address_bsd *bsda = talloc_get_type(addr->private_data, struct tsocket_address_bsd); @@ -280,18 +280,18 @@ ssize_t tsocket_address_bsd_sockaddr(const struct tsocket_address *addr, return -1; } - if (sa_socklen < bsda->sa_socklen) { + if (sasocklen < bsda->sasocklen) { errno = EINVAL; return -1; } - if (sa_socklen > bsda->sa_socklen) { - memset(sa, 0, sa_socklen); - sa_socklen = bsda->sa_socklen; + if (sasocklen > bsda->sasocklen) { + memset(sa, 0, sasocklen); + sasocklen = bsda->sasocklen; } - memcpy(sa, &bsda->u.ss, sa_socklen); - return sa_socklen; + memcpy(sa, &bsda->u.ss, sasocklen); + return sasocklen; } bool tsocket_address_is_inet(const struct tsocket_address *addr, const char *fam) @@ -627,7 +627,7 @@ static struct tsocket_address *tsocket_address_bsd_copy(const struct tsocket_add ret = _tsocket_address_bsd_from_sockaddr(mem_ctx, &bsda->u.sa, - bsda->sa_socklen, + bsda->sasocklen, ©, location); if (ret != 0) { @@ -899,10 +899,10 @@ static void tdgram_bsd_recvfrom_handler(void *private_data) } ZERO_STRUCTP(bsda); - bsda->sa_socklen = sizeof(bsda->u.ss); + bsda->sasocklen = sizeof(bsda->u.ss); ret = recvfrom(bsds->fd, state->buf, state->len, 0, - &bsda->u.sa, &bsda->sa_socklen); + &bsda->u.sa, &bsda->sasocklen); err = tsocket_bsd_error_from_errno(ret, errno, &retry); if (retry) { /* retry later */ @@ -1037,7 +1037,7 @@ static void tdgram_bsd_sendto_handler(void *private_data) struct tdgram_context *dgram = state->dgram; struct tdgram_bsd *bsds = tdgram_context_data(dgram, struct tdgram_bsd); struct sockaddr *sa = NULL; - socklen_t sa_socklen = 0; + socklen_t sasocklen = 0; ssize_t ret; int err; bool retry; @@ -1048,10 +1048,10 @@ static void tdgram_bsd_sendto_handler(void *private_data) struct tsocket_address_bsd); sa = &bsda->u.sa; - sa_socklen = bsda->sa_socklen; + sasocklen = bsda->sasocklen; } - ret = sendto(bsds->fd, state->buf, state->len, 0, sa, sa_socklen); + ret = sendto(bsds->fd, state->buf, state->len, 0, sa, sasocklen); err = tsocket_bsd_error_from_errno(ret, errno, &retry); if (retry) { /* retry later */ @@ -1302,7 +1302,7 @@ static int tdgram_bsd_dgram_socket(const struct tsocket_address *local, } if (do_bind) { - ret = bind(fd, &lbsda->u.sa, lbsda->sa_socklen); + ret = bind(fd, &lbsda->u.sa, lbsda->sasocklen); if (ret == -1) { int saved_errno = errno; talloc_free(dgram); @@ -1318,7 +1318,7 @@ static int tdgram_bsd_dgram_socket(const struct tsocket_address *local, return -1; } - ret = connect(fd, &rbsda->u.sa, rbsda->sa_socklen); + ret = connect(fd, &rbsda->u.sa, rbsda->sasocklen); if (ret == -1) { int saved_errno = errno; talloc_free(dgram); @@ -2116,7 +2116,7 @@ static struct tevent_req * tstream_bsd_connect_send(TALLOC_CTX *mem_ctx, } if (do_bind) { - ret = bind(state->fd, &lbsda->u.sa, lbsda->sa_socklen); + ret = bind(state->fd, &lbsda->u.sa, lbsda->sasocklen); if (ret == -1) { tevent_req_error(req, errno); goto post; @@ -2128,7 +2128,7 @@ static struct tevent_req * tstream_bsd_connect_send(TALLOC_CTX *mem_ctx, goto post; } - ret = connect(state->fd, &rbsda->u.sa, rbsda->sa_socklen); + ret = connect(state->fd, &rbsda->u.sa, rbsda->sasocklen); err = tsocket_bsd_error_from_errno(ret, errno, &retry); if (retry) { /* retry later */ diff --git a/lib/tsocket/tsocket_guide.txt b/lib/tsocket/tsocket_guide.txt index f937385a82..51b1687536 100644 --- a/lib/tsocket/tsocket_guide.txt +++ b/lib/tsocket/tsocket_guide.txt @@ -439,7 +439,7 @@ Otherwise it returns 0. int tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx, struct sockaddr *sa, - socklen_t sa_socklen, + socklen_t sasocklen, struct tsocket_address **addr); In some situations it's needed to get a 'struct sockaddr' from a @@ -450,7 +450,7 @@ success, otherwise it returns -1 and sets 'errno'. ssize_t tsocket_address_bsd_sockaddr(const struct tsocket_address *addr, struct sockaddr *sa, - socklen_t sa_socklen); + socklen_t sasocklen); In some situations it's needed to wrap existing file descriptors into the tstream abstraction. You can use tstream_bsd_existing_socket() |