Lines Matching refs:sa

24     nxt_sockaddr_t  *sa;  in nxt_sockaddr_cache_alloc()  local
29 sa = nxt_event_engine_mem_alloc(engine, &hint, size); in nxt_sockaddr_cache_alloc()
31 if (nxt_fast_path(sa != NULL)) { in nxt_sockaddr_cache_alloc()
33 nxt_memzero(sa, offsetof(nxt_sockaddr_t, u.sockaddr.sa_data[1])); in nxt_sockaddr_cache_alloc()
35 sa->cache_hint = hint; in nxt_sockaddr_cache_alloc()
36 sa->socklen = ls->socklen; in nxt_sockaddr_cache_alloc()
37 sa->length = ls->address_length; in nxt_sockaddr_cache_alloc()
39 sa->type = ls->sockaddr->type; in nxt_sockaddr_cache_alloc()
45 sa->u.sockaddr.sa_family = ls->sockaddr->u.sockaddr.sa_family; in nxt_sockaddr_cache_alloc()
48 return sa; in nxt_sockaddr_cache_alloc()
55 nxt_sockaddr_t *sa; in nxt_sockaddr_cache_free() local
57 sa = c->remote; in nxt_sockaddr_cache_free()
59 nxt_event_engine_mem_free(engine, sa->cache_hint, sa, 0); in nxt_sockaddr_cache_free()
67 nxt_sockaddr_t *sa; in nxt_sockaddr_alloc() local
79 sa = nxt_mp_zalloc(mp, size); in nxt_sockaddr_alloc()
81 if (nxt_fast_path(sa != NULL)) { in nxt_sockaddr_alloc()
82 sa->socklen = socklen; in nxt_sockaddr_alloc()
83 sa->length = address_length; in nxt_sockaddr_alloc()
86 return sa; in nxt_sockaddr_alloc()
95 nxt_sockaddr_t *sa; in nxt_sockaddr_create() local
147 sa = nxt_sockaddr_alloc(mp, size, address_length); in nxt_sockaddr_create()
149 if (nxt_fast_path(sa != NULL)) { in nxt_sockaddr_create()
150 nxt_memcpy(&sa->u.sockaddr, sockaddr, copy); in nxt_sockaddr_create()
155 sa->u.sockaddr.sa_family = AF_UNIX; in nxt_sockaddr_create()
161 return sa; in nxt_sockaddr_create()
229 nxt_sockaddr_text(nxt_sockaddr_t *sa) in nxt_sockaddr_text() argument
235 offset = offsetof(nxt_sockaddr_t, u) + sa->socklen; in nxt_sockaddr_text()
236 sa->start = offset; in nxt_sockaddr_text()
237 sa->port_start = offset; in nxt_sockaddr_text()
239 start = nxt_pointer_to(sa, offset); in nxt_sockaddr_text()
240 end = start + sa->length; in nxt_sockaddr_text()
242 switch (sa->u.sockaddr.sa_family) { in nxt_sockaddr_text()
245 sa->address_start = offset; in nxt_sockaddr_text()
247 octet = (u_char *) &sa->u.sockaddr_in.sin_addr; in nxt_sockaddr_text()
252 sa->address_length = p - start; in nxt_sockaddr_text()
253 sa->port_start += sa->address_length + 1; in nxt_sockaddr_text()
255 port = sa->u.sockaddr_in.sin_port; in nxt_sockaddr_text()
262 sa->address_start = offset + 1; in nxt_sockaddr_text()
267 p = nxt_inet6_ntop(sa->u.sockaddr_in6.sin6_addr.s6_addr, p, end); in nxt_sockaddr_text()
269 sa->address_length = p - (start + 1); in nxt_sockaddr_text()
270 sa->port_start += sa->address_length + 3; in nxt_sockaddr_text()
274 port = sa->u.sockaddr_in6.sin6_port; in nxt_sockaddr_text()
283 sa->address_start = offset; in nxt_sockaddr_text()
285 p = (u_char *) sa->u.sockaddr_un.sun_path; in nxt_sockaddr_text()
293 length = sa->socklen - offsetof(struct sockaddr_un, sun_path); in nxt_sockaddr_text()
307 sa->address_length = p - start; in nxt_sockaddr_text()
308 sa->port_start += sa->address_length; in nxt_sockaddr_text()
309 sa->length = p - start; in nxt_sockaddr_text()
321 sa->length = p - start; in nxt_sockaddr_text()
326 nxt_sockaddr_port_number(nxt_sockaddr_t *sa) in nxt_sockaddr_port_number() argument
330 switch (sa->u.sockaddr.sa_family) { in nxt_sockaddr_port_number()
335 port = sa->u.sockaddr_in6.sin6_port; in nxt_sockaddr_port_number()
348 port = sa->u.sockaddr_in.sin_port; in nxt_sockaddr_port_number()
526 nxt_sockaddr_t *sa; in nxt_sockaddr_parse() local
528 sa = nxt_sockaddr_parse_optport(mp, addr); in nxt_sockaddr_parse()
530 if (sa != NULL in nxt_sockaddr_parse()
531 && sa->u.sockaddr.sa_family != AF_UNIX in nxt_sockaddr_parse()
532 && nxt_sockaddr_port_number(sa) == 0) in nxt_sockaddr_parse()
539 return sa; in nxt_sockaddr_parse()
546 nxt_sockaddr_t *sa; in nxt_sockaddr_parse_optport() local
554 sa = nxt_sockaddr_unix_parse(mp, addr); in nxt_sockaddr_parse_optport()
557 sa = nxt_sockaddr_inet6_parse(mp, addr); in nxt_sockaddr_parse_optport()
560 sa = nxt_sockaddr_inet_parse(mp, addr); in nxt_sockaddr_parse_optport()
563 if (nxt_fast_path(sa != NULL)) { in nxt_sockaddr_parse_optport()
564 nxt_sockaddr_text(sa); in nxt_sockaddr_parse_optport()
567 return sa; in nxt_sockaddr_parse_optport()
577 nxt_sockaddr_t *sa; in nxt_sockaddr_unix_parse() local
622 sa = nxt_sockaddr_alloc(mp, socklen, addr->length); in nxt_sockaddr_unix_parse()
624 if (nxt_fast_path(sa != NULL)) { in nxt_sockaddr_unix_parse()
625 sa->u.sockaddr_un.sun_family = AF_UNIX; in nxt_sockaddr_unix_parse()
626 nxt_memcpy(sa->u.sockaddr_un.sun_path, path, length); in nxt_sockaddr_unix_parse()
629 return sa; in nxt_sockaddr_unix_parse()
649 nxt_sockaddr_t *sa; in nxt_sockaddr_inet6_parse() local
688 sa = nxt_sockaddr_alloc(mp, sizeof(struct sockaddr_in6), in nxt_sockaddr_inet6_parse()
690 if (nxt_slow_path(sa == NULL)) { in nxt_sockaddr_inet6_parse()
694 ret = nxt_inet6_addr(&sa->u.sockaddr_in6.sin6_addr, start, end - start); in nxt_sockaddr_inet6_parse()
701 sa->u.sockaddr_in6.sin6_family = AF_INET6; in nxt_sockaddr_inet6_parse()
702 sa->u.sockaddr_in6.sin6_port = htons((in_port_t) port); in nxt_sockaddr_inet6_parse()
704 return sa; in nxt_sockaddr_inet6_parse()
723 nxt_sockaddr_t *sa; in nxt_sockaddr_inet_parse() local
758 sa = nxt_sockaddr_alloc(mp, sizeof(struct sockaddr_in), in nxt_sockaddr_inet_parse()
760 if (nxt_slow_path(sa == NULL)) { in nxt_sockaddr_inet_parse()
764 sa->u.sockaddr_in.sin_family = AF_INET; in nxt_sockaddr_inet_parse()
765 sa->u.sockaddr_in.sin_addr.s_addr = inaddr; in nxt_sockaddr_inet_parse()
766 sa->u.sockaddr_in.sin_port = htons((in_port_t) port); in nxt_sockaddr_inet_parse()
768 return sa; in nxt_sockaddr_inet_parse()