mirror of
https://github.com/ntop/n2n.git
synced 2024-09-19 16:41:11 +02:00
Use the defined access method for structure.
Not all struct sockaddr are going to have the sa_family as their first field. Since there is a named structure member, we can simply use that and let the compiler sort it out. This fixes a bug with at least FreeBSD and allows us to remove the special case for Apple.
This commit is contained in:
parent
169d3a8cc7
commit
89125ec423
|
@ -687,11 +687,8 @@ int fill_sockaddr (struct sockaddr * addr,
|
||||||
// fills struct sockaddr's data into n2n_sock
|
// fills struct sockaddr's data into n2n_sock
|
||||||
int fill_n2nsock (n2n_sock_t* sock, const struct sockaddr* sa) {
|
int fill_n2nsock (n2n_sock_t* sock, const struct sockaddr* sa) {
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
sock->family = sa->sa_family;
|
sock->family = sa->sa_family;
|
||||||
#else
|
|
||||||
sock->family = *(sa_family_t*)sa;
|
|
||||||
#endif
|
|
||||||
switch(sock->family) {
|
switch(sock->family) {
|
||||||
case AF_INET: {
|
case AF_INET: {
|
||||||
sock->port = ntohs(((struct sockaddr_in*)sa)->sin_port);
|
sock->port = ntohs(((struct sockaddr_in*)sa)->sin_port);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user