Eu estou tentando comprar o C UNION definido por:
#ifdef AF_INET6
#define SOCKADDR union { \
struct sockaddr_in him4; \
struct sockaddr_in6 him6; \
}
#define SOCKADDR_LEN (ipv6_available() ? sizeof(SOCKADDR) : \
sizeof(struct sockaddr_in))
#else
#define SOCKADDR union { struct sockaddr_in him4; }
#define SOCKADDR_LEN sizeof(SOCKADDR)
#endif
Vamos assumir que eu tenho o SOCKADDR sa
no stack:
void *buf = (void *)jlong_to_ptr(address);
SOCKADDR sa;
socklen_t sa_len = SOCKADDR_LEN;
jint n = recvfrom(fd, buf, len, 0, (struct sockaddr *)&sa, &sa_len);
Posso copiar assim? SOCKADDR newSA = sa;
Isso seria um deep copy ou shallow copy?
E para comparar equivalencia lógica? Posso fazer assim if (newSA == sa)
?