diff --git a/adafruit_wiznet5k/adafruit_wiznet5k.py b/adafruit_wiznet5k/adafruit_wiznet5k.py index 9668202..da5fd7d 100644 --- a/adafruit_wiznet5k/adafruit_wiznet5k.py +++ b/adafruit_wiznet5k/adafruit_wiznet5k.py @@ -859,7 +859,7 @@ def _get_rx_rcv_size(self, sock): val_1 = self._read_snrx_rsr(sock) if val_1 != 0: val = self._read_snrx_rsr(sock) - return int.from_bytes(val, "b") + return int.from_bytes(val, "big") def _get_tx_free_size(self, sock): """Get free size of sock's tx buffer block.""" @@ -869,7 +869,7 @@ def _get_tx_free_size(self, sock): val_1 = self._read_sntx_fsr(sock) if val_1 != 0: val = self._read_sntx_fsr(sock) - return int.from_bytes(val, "b") + return int.from_bytes(val, "big") def _read_snrx_rd(self, sock): self._pbuff[0] = self._read_socket(sock, REG_SNRX_RD)[0] diff --git a/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py b/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py index edb3e19..f66b502 100644 --- a/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py +++ b/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py @@ -152,7 +152,7 @@ def send_dhcp_message(self, state, time_elapsed, renew=False): # Transaction ID (xid) self._initial_xid = htonl(self._transaction_id) - self._initial_xid = self._initial_xid.to_bytes(4, "l") + self._initial_xid = self._initial_xid.to_bytes(4, "big") _BUFF[4:7] = self._initial_xid # seconds elapsed @@ -161,7 +161,7 @@ def send_dhcp_message(self, state, time_elapsed, renew=False): # flags flags = htons(0x8000) - flags = flags.to_bytes(2, "b") + flags = flags.to_bytes(2, "big") _BUFF[10] = flags[1] _BUFF[11] = flags[0] @@ -259,7 +259,7 @@ def parse_dhcp_response(self): if _BUFF[28:34] == 0: return 0, 0 - if int.from_bytes(_BUFF[235:240], "l") != MAGIC_COOKIE: + if int.from_bytes(_BUFF[235:240], "big") != MAGIC_COOKIE: return 0, 0 # -- Parse Packet, VARIABLE -- # @@ -287,7 +287,7 @@ def parse_dhcp_response(self): ptr += 1 opt_len = _BUFF[ptr] ptr += 1 - self._lease_time = int.from_bytes(_BUFF[ptr : ptr + opt_len], "l") + self._lease_time = int.from_bytes(_BUFF[ptr : ptr + opt_len], "big") ptr += opt_len elif _BUFF[ptr] == ROUTERS_ON_SUBNET: ptr += 1 @@ -305,13 +305,13 @@ def parse_dhcp_response(self): ptr += 1 opt_len = _BUFF[ptr] ptr += 1 - self._t1 = int.from_bytes(_BUFF[ptr : ptr + opt_len], "l") + self._t1 = int.from_bytes(_BUFF[ptr : ptr + opt_len], "big") ptr += opt_len elif _BUFF[ptr] == T2_VAL: ptr += 1 opt_len = _BUFF[ptr] ptr += 1 - self._t2 = int.from_bytes(_BUFF[ptr : ptr + opt_len], "l") + self._t2 = int.from_bytes(_BUFF[ptr : ptr + opt_len], "big") ptr += opt_len elif _BUFF[ptr] == 0: break @@ -399,7 +399,7 @@ def _dhcp_state_machine(self): if msg_type == DHCP_OFFER: # Check if transaction ID matches, otherwise it may be an offer # for another device - if htonl(self._transaction_id) == int.from_bytes(xid, "l"): + if htonl(self._transaction_id) == int.from_bytes(xid, "big"): if self._debug: print( "* DHCP: Send request to {}".format(self.dhcp_server_ip) @@ -423,7 +423,7 @@ def _dhcp_state_machine(self): msg_type, xid = self.parse_dhcp_response() # Check if transaction ID matches, otherwise it may be # for another device - if htonl(self._transaction_id) == int.from_bytes(xid, "l"): + if htonl(self._transaction_id) == int.from_bytes(xid, "big"): if msg_type == DHCP_ACK: if self._debug: print("* DHCP: Successful lease") diff --git a/adafruit_wiznet5k/adafruit_wiznet5k_dns.py b/adafruit_wiznet5k/adafruit_wiznet5k_dns.py index 76ebb6f..abf4ca2 100644 --- a/adafruit_wiznet5k/adafruit_wiznet5k_dns.py +++ b/adafruit_wiznet5k/adafruit_wiznet5k_dns.py @@ -113,7 +113,7 @@ def _parse_dns_response( print("DNS Packet Received: ", self._pkt_buf) # Validate request identifier - xid = int.from_bytes(self._pkt_buf[0:2], "l") + xid = int.from_bytes(self._pkt_buf[0:2], "big") if not xid == self._request_id: if self._debug: print( @@ -124,19 +124,19 @@ def _parse_dns_response( ) return -1 # Validate flags - flags = int.from_bytes(self._pkt_buf[2:4], "l") + flags = int.from_bytes(self._pkt_buf[2:4], "big") if not flags in (0x8180, 0x8580): if self._debug: print("* DNS ERROR: Invalid flags, ", flags) return -1 # Number of questions - qr_count = int.from_bytes(self._pkt_buf[4:6], "l") + qr_count = int.from_bytes(self._pkt_buf[4:6], "big") if not qr_count >= 1: if self._debug: print("* DNS ERROR: Question count >=1, ", qr_count) return -1 # Number of answers - an_count = int.from_bytes(self._pkt_buf[6:8], "l") + an_count = int.from_bytes(self._pkt_buf[6:8], "big") if self._debug: print("* DNS Answer Count: ", an_count) if not an_count >= 1: @@ -156,7 +156,7 @@ def _parse_dns_response( ptr += name_len + 1 # Validate Query is Type A - q_type = int.from_bytes(self._pkt_buf[ptr : ptr + 2], "l") + q_type = int.from_bytes(self._pkt_buf[ptr : ptr + 2], "big") if not q_type == TYPE_A: if self._debug: print("* DNS ERROR: Incorrect Query Type: ", q_type) @@ -164,7 +164,7 @@ def _parse_dns_response( ptr += 2 # Validate Query is Type A - q_class = int.from_bytes(self._pkt_buf[ptr : ptr + 2], "l") + q_class = int.from_bytes(self._pkt_buf[ptr : ptr + 2], "big") if not q_class == TYPE_A: if self._debug: print("* DNS ERROR: Incorrect Query Class: ", q_class) @@ -181,7 +181,7 @@ def _parse_dns_response( ptr += 1 # Validate Answer Type A - ans_type = int.from_bytes(self._pkt_buf[ptr : ptr + 2], "l") + ans_type = int.from_bytes(self._pkt_buf[ptr : ptr + 2], "big") if not ans_type == TYPE_A: if self._debug: print("* DNS ERROR: Incorrect Answer Type: ", ans_type) @@ -189,7 +189,7 @@ def _parse_dns_response( ptr += 2 # Validate Answer Class IN - ans_class = int.from_bytes(self._pkt_buf[ptr : ptr + 2], "l") + ans_class = int.from_bytes(self._pkt_buf[ptr : ptr + 2], "big") if not ans_class == TYPE_A: if self._debug: print("* DNS ERROR: Incorrect Answer Class: ", ans_class) @@ -200,7 +200,7 @@ def _parse_dns_response( ptr += 4 # Validate addr is IPv4 - data_len = int.from_bytes(self._pkt_buf[ptr : ptr + 2], "l") + data_len = int.from_bytes(self._pkt_buf[ptr : ptr + 2], "big") if not data_len == DATA_LEN: if self._debug: print("* DNS ERROR: Unexpected Data Length: ", data_len)