Fix port endian order

This commit is contained in:
Jeremy Lakeman 2012-09-07 13:36:02 +09:30
parent cd67868d2a
commit 3dba4633b7
2 changed files with 3 additions and 3 deletions

View File

@ -194,10 +194,10 @@ int reachable_unicast(struct subscriber *subscriber, overlay_interface *interfac
subscriber->reachable = REACHABLE_DIRECT;
subscriber->address.sin_family = AF_INET;
subscriber->address.sin_addr = addr;
subscriber->address.sin_port = port;
subscriber->address.sin_port = htons(port);
// may be used in tests
DEBUGF("ADD DIRECT ROUTE TO %s via %s", alloca_tohex_sid(subscriber->sid), inet_ntoa(addr));
DEBUGF("ADD DIRECT ROUTE TO %s via %s:%d", alloca_tohex_sid(subscriber->sid), inet_ntoa(addr), port);
/* Pre-emptively check if we have their sas in memory, or send a request */
keyring_find_sas_public(keyring, subscriber->sid);

View File

@ -278,7 +278,7 @@ int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, s
struct sockaddr_in *addr=(struct sockaddr_in *)recvaddr;
// mark this subscriber as reachable directly via unicast.
reachable_unicast(f.source, interface, addr->sin_addr, addr->sin_port);
reachable_unicast(f.source, interface, addr->sin_addr, ntohs(addr->sin_port));
}