diff options
author | Håkon Nessjøen <haakon.nessjoen@gmail.com> | 2011-02-27 13:38:03 +0100 |
---|---|---|
committer | Håkon Nessjøen <haakon.nessjoen@gmail.com> | 2011-02-27 13:38:03 +0100 |
commit | e149992b6487bb41308a1893500e35bbe6d195c0 (patch) | |
tree | d94af56288af8d7d63101ed36336920623ef3366 /udp.c | |
parent | abd75d40f31787f289de8e34854c00672af49b2c (diff) | |
download | MAC-Telnet-e149992b6487bb41308a1893500e35bbe6d195c0.tar.gz MAC-Telnet-e149992b6487bb41308a1893500e35bbe6d195c0.zip |
Missing two endianness checks/handling. Tested successfully with MIPS Malta 4Kc qemu emulator (big endianed)
Diffstat (limited to 'udp.c')
-rw-r--r-- | udp.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -72,7 +72,7 @@ unsigned short udp_sum_calc(unsigned char *src_addr,unsigned char *dst_addr, uns sum = ~sum; - if ((unsigned short)sum == 0) + if (sum == 0) sum = 0xFFFF; return (unsigned short) sum; @@ -109,11 +109,11 @@ int send_custom_udp(const int socket, const int ifindex, const unsigned char *so /* Init ethernet header */ memcpy(eh->h_source, sourcemac, ETH_ALEN); memcpy(eh->h_dest, destmac, ETH_ALEN); - eh->h_proto = 8; + eh->h_proto = htons(ETH_P_IP); /* Init SendTo struct */ - socket_address.sll_family = PF_PACKET; - socket_address.sll_protocol = htons(ETH_P_IP); + socket_address.sll_family = PF_PACKET; + socket_address.sll_protocol = htons(ETH_P_IP); socket_address.sll_ifindex = ifindex; socket_address.sll_hatype = ARPHRD_ETHER; socket_address.sll_pkttype = PACKET_OTHERHOST; |