{
case AF_INET:
{
- struct sockaddr_in *sin = (struct sockaddr_in *) sa;
+ DECLARE_POINTER_ALIAS (sin, struct sockaddr_in, sa);
len = sizeof (sin->sin_addr) + 1;
address = Fmake_vector (make_number (len), Qnil);
p = XVECTOR (address);
#ifdef AF_INET6
case AF_INET6:
{
- struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa;
- uint16_t *ip6 = (uint16_t *) &sin6->sin6_addr;
+ DECLARE_POINTER_ALIAS (sin6, struct sockaddr_in6, sa);
+ DECLARE_POINTER_ALIAS (ip6, uint16_t, &sin6->sin6_addr);
len = sizeof (sin6->sin6_addr) / 2 + 1;
address = Fmake_vector (make_number (len), Qnil);
p = XVECTOR (address);
#ifdef HAVE_LOCAL_SOCKETS
case AF_LOCAL:
{
- struct sockaddr_un *sockun = (struct sockaddr_un *) sa;
+ DECLARE_POINTER_ALIAS (sockun, struct sockaddr_un, sa);
ptrdiff_t name_length = len - offsetof (struct sockaddr_un, sun_path);
/* If the first byte is NUL, the name is a Linux abstract
socket name, and the name can contain embedded NULs. If
p = XVECTOR (address);
if (family == AF_INET)
{
- struct sockaddr_in *sin = (struct sockaddr_in *) sa;
+ DECLARE_POINTER_ALIAS (sin, struct sockaddr_in, sa);
len = sizeof (sin->sin_addr) + 1;
hostport = XINT (p->contents[--len]);
sin->sin_port = htons (hostport);
#ifdef AF_INET6
else if (family == AF_INET6)
{
- struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa;
- uint16_t *ip6 = (uint16_t *)&sin6->sin6_addr;
+ DECLARE_POINTER_ALIAS (sin6, struct sockaddr_in6, sa);
+ DECLARE_POINTER_ALIAS (ip6, uint16_t, &sin6->sin6_addr);
len = sizeof (sin6->sin6_addr) / 2 + 1;
hostport = XINT (p->contents[--len]);
sin6->sin6_port = htons (hostport);
#ifdef HAVE_LOCAL_SOCKETS
if (family == AF_LOCAL)
{
- struct sockaddr_un *sockun = (struct sockaddr_un *) sa;
+ DECLARE_POINTER_ALIAS (sockun, struct sockaddr_un, sa);
cp = SDATA (address);
for (i = 0; i < sizeof (sockun->sun_path) && *cp; i++)
sockun->sun_path[i] = *cp++;
== offsetof (struct sockaddr_in6, sin6_port))
&& sizeof (sa1.sin_port) == sizeof (sa6.sin6_port));
#endif
- if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0)
+ DECLARE_POINTER_ALIAS (psa1, struct sockaddr, &sa1);
+ if (getsockname (s, psa1, &len1) == 0)
{
Lisp_Object service = make_number (ntohs (sa1.sin_port));
contact = Fplist_put (contact, QCservice, service);
/* Save the port number so that we can stash it in
the process object later. */
- ((struct sockaddr_in *) sa)->sin_port = sa1.sin_port;
+ DECLARE_POINTER_ALIAS (psa, struct sockaddr_in, sa);
+ psa->sin_port = sa1.sin_port;
}
}
#endif
{
struct sockaddr_storage sa1;
socklen_t len1 = sizeof (sa1);
- if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0)
+ DECLARE_POINTER_ALIAS (psa1, struct sockaddr, &sa1);
+ if (getsockname (s, psa1, &len1) == 0)
contact = Fplist_put (contact, QClocal,
- conv_sockaddr_to_lisp ((struct sockaddr *)&sa1, len1));
+ conv_sockaddr_to_lisp (psa1, len1));
}
#endif
}
for (it = ifap; it != NULL; it = it->ifa_next)
{
- struct sockaddr_dl *sdl = (struct sockaddr_dl *) it->ifa_addr;
+ DECLARE_POINTER_ALIAS (sdl, struct sockaddr_dl, it->ifa_addr);
unsigned char linkaddr[6];
int n;
{
args[nargs++] = procname_format_in6;
nargs++;
- uint16_t *ip6 = (uint16_t *)&saddr.in6.sin6_addr;
+ DECLARE_POINTER_ALIAS (ip6, uint16_t, &saddr.in6.sin6_addr);
service = make_number (ntohs (saddr.in.sin_port));
for (int i = 0; i < 8; i++)
args[nargs++] = make_number (ip6[i]);