diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-06-29 19:25:46 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-06-29 19:25:46 +0300 |
commit | 46c6513c2b686d4a6e26c0fe0d0db4280baf5f3e (patch) | |
tree | 03b6b6c03bc47584e730b083b22277b1bc61e8bf /src | |
parent | 499a8f9ac87765252dc3656c7aac900825475a51 (diff) | |
download | unit-46c6513c2b686d4a6e26c0fe0d0db4280baf5f3e.tar.gz unit-46c6513c2b686d4a6e26c0fe0d0db4280baf5f3e.tar.bz2 |
Fixed port processing in nxt_sockaddr_text().
Diffstat (limited to '')
-rw-r--r-- | src/nxt_sockaddr.c | 7 | ||||
-rw-r--r-- | src/nxt_sockaddr.h | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/nxt_sockaddr.c b/src/nxt_sockaddr.c index 79d01b8a..f1e0eb77 100644 --- a/src/nxt_sockaddr.c +++ b/src/nxt_sockaddr.c @@ -195,6 +195,7 @@ nxt_sockaddr_text(nxt_sockaddr_t *sa) offset = offsetof(nxt_sockaddr_t, u) + sa->socklen; sa->start = offset; + sa->port_start = offset; start = nxt_pointer_to(sa, offset); end = nxt_pointer_to(sa, sa->sockaddr_size); @@ -210,7 +211,7 @@ nxt_sockaddr_text(nxt_sockaddr_t *sa) octet[0], octet[1], octet[2], octet[3]); sa->address_length = p - start; - sa->port_start = sa->address_length + 1; + sa->port_start += sa->address_length + 1; port = sa->u.sockaddr_in.sin_port; @@ -227,7 +228,7 @@ nxt_sockaddr_text(nxt_sockaddr_t *sa) p = nxt_inet6_ntop(sa->u.sockaddr_in6.sin6_addr.s6_addr, p, end); sa->address_length = p - (start + 1); - sa->port_start = sa->address_length + 2; + sa->port_start += sa->address_length + 3; *p++ = ']'; @@ -265,7 +266,7 @@ nxt_sockaddr_text(nxt_sockaddr_t *sa) #endif sa->address_length = p - start; - sa->port_start = sa->address_length; + sa->port_start += sa->address_length; sa->length = p - start; return; diff --git a/src/nxt_sockaddr.h b/src/nxt_sockaddr.h index 007d42e6..1119ee2e 100644 --- a/src/nxt_sockaddr.h +++ b/src/nxt_sockaddr.h @@ -38,7 +38,7 @@ struct nxt_sockaddr_s { uint8_t address_length; /* * Textual port representation, e.g. "8000". - * Port length is length - port_start. + * Port length is (start + length) - port_start. */ uint8_t port_start; /* @@ -106,7 +106,8 @@ NXT_EXPORT nxt_int_t nxt_inet6_addr(struct in6_addr *in6_addr, u_char *buf, #define nxt_sockaddr_start(sa) nxt_pointer_to(sa, (sa)->start) #define nxt_sockaddr_address(sa) nxt_pointer_to(sa, (sa)->address_start) #define nxt_sockaddr_port(sa) nxt_pointer_to(sa, (sa)->port_start) -#define nxt_sockaddr_length(sa) ((sa)->length - (sa)->port_start) +#define nxt_sockaddr_port_length(sa) \ + (((sa)->start + (sa)->length) - (sa)->port_start) #endif /* _NXT_SOCKADDR_H_INCLUDED_ */ |