Lines Matching full:byte
22 static uint16_t modem_ppp_fcs_init(uint8_t byte) in modem_ppp_fcs_init() argument
24 return crc16_ccitt(0xFFFF, &byte, 1); in modem_ppp_fcs_init()
27 static uint16_t modem_ppp_fcs_update(uint16_t fcs, uint8_t byte) in modem_ppp_fcs_update() argument
29 return crc16_ccitt(fcs, &byte, 1); in modem_ppp_fcs_update()
53 uint8_t byte; in modem_ppp_wrap_net_pkt_byte() local
88 byte = (ppp->tx_pkt_protocol >> 8) & 0xFF; in modem_ppp_wrap_net_pkt_byte()
89 ppp->tx_pkt_fcs = modem_ppp_fcs_update(ppp->tx_pkt_fcs, byte); in modem_ppp_wrap_net_pkt_byte()
91 if ((byte == MODEM_PPP_CODE_DELIMITER) || (byte == MODEM_PPP_CODE_ESCAPE) || in modem_ppp_wrap_net_pkt_byte()
92 (byte < MODEM_PPP_VALUE_ESCAPE)) { in modem_ppp_wrap_net_pkt_byte()
93 ppp->tx_pkt_escaped = byte ^ MODEM_PPP_VALUE_ESCAPE; in modem_ppp_wrap_net_pkt_byte()
99 return byte; in modem_ppp_wrap_net_pkt_byte()
106 byte = ppp->tx_pkt_protocol & 0xFF; in modem_ppp_wrap_net_pkt_byte()
107 ppp->tx_pkt_fcs = modem_ppp_fcs_update(ppp->tx_pkt_fcs, byte); in modem_ppp_wrap_net_pkt_byte()
109 if ((byte == MODEM_PPP_CODE_DELIMITER) || (byte == MODEM_PPP_CODE_ESCAPE) || in modem_ppp_wrap_net_pkt_byte()
110 (byte < MODEM_PPP_VALUE_ESCAPE)) { in modem_ppp_wrap_net_pkt_byte()
111 ppp->tx_pkt_escaped = byte ^ MODEM_PPP_VALUE_ESCAPE; in modem_ppp_wrap_net_pkt_byte()
117 return byte; in modem_ppp_wrap_net_pkt_byte()
125 (void)net_pkt_read_u8(ppp->tx_pkt, &byte); in modem_ppp_wrap_net_pkt_byte()
126 ppp->tx_pkt_fcs = modem_ppp_fcs_update(ppp->tx_pkt_fcs, byte); in modem_ppp_wrap_net_pkt_byte()
128 if ((byte == MODEM_PPP_CODE_DELIMITER) || (byte == MODEM_PPP_CODE_ESCAPE) || in modem_ppp_wrap_net_pkt_byte()
129 (byte < MODEM_PPP_VALUE_ESCAPE)) { in modem_ppp_wrap_net_pkt_byte()
130 ppp->tx_pkt_escaped = byte ^ MODEM_PPP_VALUE_ESCAPE; in modem_ppp_wrap_net_pkt_byte()
139 return byte; in modem_ppp_wrap_net_pkt_byte()
153 byte = ppp->tx_pkt_fcs & 0xFF; in modem_ppp_wrap_net_pkt_byte()
155 if ((byte == MODEM_PPP_CODE_DELIMITER) || (byte == MODEM_PPP_CODE_ESCAPE) || in modem_ppp_wrap_net_pkt_byte()
156 (byte < MODEM_PPP_VALUE_ESCAPE)) { in modem_ppp_wrap_net_pkt_byte()
157 ppp->tx_pkt_escaped = byte ^ MODEM_PPP_VALUE_ESCAPE; in modem_ppp_wrap_net_pkt_byte()
163 return byte; in modem_ppp_wrap_net_pkt_byte()
170 byte = (ppp->tx_pkt_fcs >> 8) & 0xFF; in modem_ppp_wrap_net_pkt_byte()
172 if ((byte == MODEM_PPP_CODE_DELIMITER) || (byte == MODEM_PPP_CODE_ESCAPE) || in modem_ppp_wrap_net_pkt_byte()
173 (byte < MODEM_PPP_VALUE_ESCAPE)) { in modem_ppp_wrap_net_pkt_byte()
174 ppp->tx_pkt_escaped = byte ^ MODEM_PPP_VALUE_ESCAPE; in modem_ppp_wrap_net_pkt_byte()
180 return byte; in modem_ppp_wrap_net_pkt_byte()
195 static bool modem_ppp_is_byte_expected(uint8_t byte, uint8_t expected_byte) in modem_ppp_is_byte_expected() argument
197 if (byte == expected_byte) { in modem_ppp_is_byte_expected()
200 LOG_DBG("Dropping byte 0x%02hhx because 0x%02hhx was expected.", byte, expected_byte); in modem_ppp_is_byte_expected()
204 static void modem_ppp_process_received_byte(struct modem_ppp *ppp, uint8_t byte) in modem_ppp_process_received_byte() argument
208 if (modem_ppp_is_byte_expected(byte, MODEM_PPP_CODE_DELIMITER)) { in modem_ppp_process_received_byte()
214 if (byte == MODEM_PPP_CODE_DELIMITER) { in modem_ppp_process_received_byte()
217 if (modem_ppp_is_byte_expected(byte, 0xFF)) { in modem_ppp_process_received_byte()
225 if (modem_ppp_is_byte_expected(byte, MODEM_PPP_CODE_ESCAPE)) { in modem_ppp_process_received_byte()
233 if (modem_ppp_is_byte_expected(byte, 0x23)) { in modem_ppp_process_received_byte()
253 if (byte == MODEM_PPP_CODE_DELIMITER) { in modem_ppp_process_received_byte()
282 if (byte == MODEM_PPP_CODE_ESCAPE) { in modem_ppp_process_received_byte()
287 if (net_pkt_write_u8(ppp->rx_pkt, byte) < 0) { in modem_ppp_process_received_byte()
300 if (net_pkt_write_u8(ppp->rx_pkt, (byte ^ MODEM_PPP_VALUE_ESCAPE)) < 0) { in modem_ppp_process_received_byte()
359 uint8_t byte; in modem_ppp_send_handler() local
376 byte = modem_ppp_wrap_net_pkt_byte(ppp); in modem_ppp_send_handler()
378 ring_buf_put(&ppp->transmit_rb, &byte, 1); in modem_ppp_send_handler()