Lines Matching refs:sa
80 if (get_name(fd, &lsa.u.sa, &lsa.len) != 0) in get_lsa()
86 get_name(fd, &lsa_ptr->u.sa, &lsa_ptr->len); in get_lsa()
139 int FAST_FUNC get_nport(const struct sockaddr *sa) in get_nport() argument
142 if (sa->sa_family == AF_INET6) { in get_nport()
143 return ((struct sockaddr_in6*)sa)->sin6_port; in get_nport()
146 if (sa->sa_family == AF_INET) { in get_nport()
147 return ((struct sockaddr_in*)sa)->sin_port; in get_nport()
153 void FAST_FUNC set_nport(struct sockaddr *sa, unsigned port) in set_nport() argument
156 if (sa->sa_family == AF_INET6) { in set_nport()
157 struct sockaddr_in6 *sin6 = (void*) sa; in set_nport()
162 if (sa->sa_family == AF_INET) { in set_nport()
163 struct sockaddr_in *sin = (void*) sa; in set_nport()
195 r->u.sa.sa_family = AF_UNIX;
196 sun = (struct sockaddr_un *)&r->u.sa;
254 r->u.sa.sa_family = AF_INET;
267 r->u.sa.sa_family = AF_INET6;
301 memcpy(&r->u.sa, used_res->ai_addr, used_res->ai_addrlen);
304 set_nport(&r->u.sa, htons(port));
371 lsa->u.sa.sa_family = family; in xsocket_type()
389 fd = xsocket(lsa->u.sa.sa_family, sock_type, 0); in create_and_bind_or_die()
392 set_nport(&lsa->u.sa, htons(port)); in create_and_bind_or_die()
395 xbind(fd, &lsa->u.sa, lsa->len); in create_and_bind_or_die()
414 struct sockaddr_nl sa; in create_and_bind_to_netlink() local
436 memset(&sa, 0, sizeof(sa)); in create_and_bind_to_netlink()
437 sa.nl_family = AF_NETLINK; in create_and_bind_to_netlink()
438 sa.nl_pid = getpid(); in create_and_bind_to_netlink()
439 sa.nl_groups = grp; in create_and_bind_to_netlink()
440 xbind(fd, (struct sockaddr *) &sa, sizeof(sa)); in create_and_bind_to_netlink()
453 fd = xsocket(lsa->u.sa.sa_family, SOCK_STREAM, 0); in create_and_connect_stream_or_die()
455 xconnect(fd, &lsa->u.sa, lsa->len); in create_and_connect_stream_or_die()
462 int fd = xsocket(lsa->u.sa.sa_family, SOCK_STREAM, 0); in xconnect_stream()
463 xconnect(fd, &lsa->u.sa, lsa->len); in xconnect_stream()
470 static char* FAST_FUNC sockaddr2str(const struct sockaddr *sa, int flags) in sockaddr2str() argument
477 if (ENABLE_FEATURE_UNIX_LOCAL && sa->sa_family == AF_UNIX) { in sockaddr2str()
478 struct sockaddr_un *sun = (struct sockaddr_un *)sa; in sockaddr2str()
486 if (sa->sa_family == AF_INET) in sockaddr2str()
488 if (sa->sa_family == AF_INET6) in sockaddr2str()
491 rc = getnameinfo(sa, salen, in sockaddr2str()
503 if (sa->sa_family == AF_INET6) { in sockaddr2str()
516 char* FAST_FUNC xmalloc_sockaddr2host(const struct sockaddr *sa) in xmalloc_sockaddr2host() argument
518 return sockaddr2str(sa, 0); in xmalloc_sockaddr2host()
521 char* FAST_FUNC xmalloc_sockaddr2host_noport(const struct sockaddr *sa) in xmalloc_sockaddr2host_noport() argument
523 return sockaddr2str(sa, IGNORE_PORT); in xmalloc_sockaddr2host_noport()
526 char* FAST_FUNC xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa) in xmalloc_sockaddr2hostonly_noport() argument
528 return sockaddr2str(sa, NI_NAMEREQD | IGNORE_PORT); in xmalloc_sockaddr2hostonly_noport()
533 char* FAST_FUNC xmalloc_sockaddr2dotted(const struct sockaddr *sa) in xmalloc_sockaddr2dotted() argument
535 return sockaddr2str(sa, NI_NUMERICHOST | NI_NUMERICSCOPE); in xmalloc_sockaddr2dotted()
538 char* FAST_FUNC xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa) in xmalloc_sockaddr2dotted_noport() argument
540 return sockaddr2str(sa, NI_NUMERICHOST | NI_NUMERICSCOPE | IGNORE_PORT); in xmalloc_sockaddr2dotted_noport()