Changeset 374 for asp3_tinet_ecnl_rx/trunk/btstack/src/bnep.c
- Timestamp:
- Apr 5, 2019, 9:26:53 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_rx/trunk/btstack/src/bnep.c
r337 r374 84 84 event[1] = sizeof(event) - 2; 85 85 event[2] = status; 86 bt_store_16(event, 3, channel->l2cap_cid);87 bt_store_16(event, 5, channel->uuid_source);88 bt_store_16(event, 7, channel->uuid_dest);89 bt_store_16(event, 9, channel->max_frame_size);86 little_endian_store_16(event, 3, channel->l2cap_cid); 87 little_endian_store_16(event, 5, channel->uuid_source); 88 little_endian_store_16(event, 7, channel->uuid_dest); 89 little_endian_store_16(event, 9, channel->max_frame_size); 90 90 BD_ADDR_COPY(&event[11], channel->remote_addr); 91 91 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); … … 101 101 event[0] = BNEP_EVENT_CHANNEL_TIMEOUT; 102 102 event[1] = sizeof(event) - 2; 103 bt_store_16(event, 2, channel->l2cap_cid);104 bt_store_16(event, 4, channel->uuid_source);105 bt_store_16(event, 6, channel->uuid_dest);103 little_endian_store_16(event, 2, channel->l2cap_cid); 104 little_endian_store_16(event, 4, channel->uuid_source); 105 little_endian_store_16(event, 6, channel->uuid_dest); 106 106 BD_ADDR_COPY(&event[8], channel->remote_addr); 107 107 event[14] = channel->state; … … 118 118 event[0] = BNEP_EVENT_CHANNEL_CLOSED; 119 119 event[1] = sizeof(event) - 2; 120 bt_store_16(event, 2, channel->l2cap_cid);121 bt_store_16(event, 4, channel->uuid_source);122 bt_store_16(event, 6, channel->uuid_dest);120 little_endian_store_16(event, 2, channel->l2cap_cid); 121 little_endian_store_16(event, 4, channel->uuid_source); 122 little_endian_store_16(event, 6, channel->uuid_dest); 123 123 BD_ADDR_COPY(&event[8], channel->remote_addr); 124 124 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); … … 133 133 event[0] = BNEP_EVENT_READY_TO_SEND; 134 134 event[1] = sizeof(event) - 2; 135 bt_store_16(event, 2, channel->l2cap_cid);135 little_endian_store_16(event, 2, channel->l2cap_cid); 136 136 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); 137 137 (*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event)); … … 464 464 BD_ADDR_COPY(addr_source, &packet[pos]); 465 465 pos += sizeof(bd_addr_t); 466 network_protocol_type = READ_NET_16(packet, pos);466 network_protocol_type = big_endian_read_16(packet, pos); 467 467 pos += sizeof(uint16_t); 468 468 … … 475 475 } 476 476 /* The "real" network protocol type is 4 bytes ahead in a VLAN packet */ 477 network_protocol_type = READ_NET_16(packet, pos + 2);477 network_protocol_type = big_endian_read_16(packet, pos + 2); 478 478 } 479 479 … … 808 808 /* Check source and destination UUIDs for valid combinations */ 809 809 if (response_code == BNEP_RESP_SETUP_SUCCESS) { 810 channel->uuid_dest = READ_NET_16(packet, 2 + uuid_offset);811 channel->uuid_source = READ_NET_16(packet, 2 + uuid_offset + uuid_size);812 813 if ((channel->uuid_dest != B NEP_UUID_PANU) &&814 (channel->uuid_dest != B NEP_UUID_NAP) &&815 (channel->uuid_dest != B NEP_UUID_GN)) {810 channel->uuid_dest = big_endian_read_16(packet, 2 + uuid_offset); 811 channel->uuid_source = big_endian_read_16(packet, 2 + uuid_offset + uuid_size); 812 813 if ((channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_PANU) && 814 (channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_NAP) && 815 (channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_GN)) { 816 816 log_error("BNEP_CONNECTION_REQUEST: Invalid destination service UUID: %04x", channel->uuid_dest); 817 817 channel->uuid_dest = 0; 818 818 } 819 if ((channel->uuid_source != B NEP_UUID_PANU) &&820 (channel->uuid_source != B NEP_UUID_NAP) &&821 (channel->uuid_source != B NEP_UUID_GN)) {819 if ((channel->uuid_source != BLUETOOTH_SERVICE_CLASS_PANU) && 820 (channel->uuid_source != BLUETOOTH_SERVICE_CLASS_NAP) && 821 (channel->uuid_source != BLUETOOTH_SERVICE_CLASS_GN)) { 822 822 log_error("BNEP_CONNECTION_REQUEST: Invalid source service UUID: %04x", channel->uuid_source); 823 823 channel->uuid_source = 0; … … 829 829 response_code = BNEP_RESP_SETUP_INVALID_DEST_UUID; 830 830 } else 831 if ((channel->uuid_source != B NEP_UUID_PANU) && (channel->uuid_dest != BNEP_UUID_PANU)) {831 if ((channel->uuid_source != BLUETOOTH_SERVICE_CLASS_PANU) && (channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_PANU)) { 832 832 response_code = BNEP_RESP_SETUP_INVALID_SOURCE_UUID; 833 833 } … … 857 857 } 858 858 859 response_code = READ_NET_16(packet, 1);859 response_code = big_endian_read_16(packet, 1); 860 860 861 861 if (response_code == BNEP_RESP_SETUP_SUCCESS) { … … 882 882 } 883 883 884 list_length = READ_NET_16(packet, 1);884 list_length = big_endian_read_16(packet, 1); 885 885 /* Sanity check packet size again with known package size */ 886 886 if (size < 3 + list_length) { … … 903 903 /* There is still enough space, copy the filters to our filter list */ 904 904 for (i = 0; i < list_length / (2 * 2); i ++) { 905 channel->net_filter[channel->net_filter_count].range_start = READ_NET_16(packet, 1 + 2 + i * 4);906 channel->net_filter[channel->net_filter_count].range_end = READ_NET_16(packet, 1 + 2 + i * 4 + 2);905 channel->net_filter[channel->net_filter_count].range_start = big_endian_read_16(packet, 1 + 2 + i * 4); 906 channel->net_filter[channel->net_filter_count].range_end = big_endian_read_16(packet, 1 + 2 + i * 4 + 2); 907 907 if (channel->net_filter[channel->net_filter_count].range_start > channel->net_filter[channel->net_filter_count].range_end) { 908 908 /* Invalid filter range, ignore this filter rule */ … … 945 945 } 946 946 947 response_code = READ_NET_16(packet, 1);947 response_code = big_endian_read_16(packet, 1); 948 948 949 949 if (response_code == BNEP_RESP_FILTER_SUCCESS) { … … 966 966 } 967 967 968 list_length = READ_NET_16(packet, 1);968 list_length = big_endian_read_16(packet, 1); 969 969 /* Sanity check packet size again with known package size */ 970 970 if (size < 3 + list_length) { … … 1032 1032 } 1033 1033 1034 response_code = READ_NET_16(packet, 1);1034 response_code = big_endian_read_16(packet, 1); 1035 1035 1036 1036 if (response_code == BNEP_RESP_FILTER_SUCCESS) { … … 1169 1169 case L2CAP_EVENT_INCOMING_CONNECTION: 1170 1170 /* L2CAP event data: event(8), len(8), address(48), handle (16), psm (16), source cid(16) dest cid(16) */ 1171 bt_flip_addr(event_addr, &packet[2]);1172 con_handle = READ_BT_16(packet, 8);1173 psm = READ_BT_16(packet, 10);1174 l2cap_cid = READ_BT_16(packet, 12);1171 reverse_bd_addr(&packet[2], event_addr); 1172 con_handle = little_endian_read_16(packet, 8); 1173 psm = little_endian_read_16(packet, 10); 1174 l2cap_cid = little_endian_read_16(packet, 12); 1175 1175 1176 1176 if (psm != PSM_BNEP) break; … … 1211 1211 case L2CAP_EVENT_CHANNEL_OPENED: 1212 1212 /* Check if the l2cap channel has been opened for PSM_BNEP */ 1213 if ( READ_BT_16(packet, 11) != PSM_BNEP) {1213 if (little_endian_read_16(packet, 11) != PSM_BNEP) { 1214 1214 break; 1215 1215 } … … 1219 1219 1220 1220 /* Get the bnep channel fpr remote address */ 1221 con_handle = READ_BT_16(packet, 9);1222 l2cap_cid = READ_BT_16(packet, 13);1223 bt_flip_addr(event_addr, &packet[3]);1221 con_handle = little_endian_read_16(packet, 9); 1222 l2cap_cid = little_endian_read_16(packet, 13); 1223 reverse_bd_addr(&packet[3], event_addr); 1224 1224 channel = bnep_channel_for_addr(&event_addr); 1225 1225 if (!channel) { … … 1252 1252 channel->state = BNEP_CHANNEL_STATE_WAIT_FOR_CONNECTION_RESPONSE; 1253 1253 bnep_channel_state_add(channel, BNEP_CHANNEL_STATE_VAR_SND_CONNECTION_REQUEST); 1254 channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu( READ_BT_16(packet, 17));1254 channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(little_endian_read_16(packet, 17)); 1255 1255 bnep_run(); 1256 1256 break; 1257 1257 case BNEP_CHANNEL_STATE_WAIT_FOR_CONNECTION_REQUEST: 1258 1258 /* New information: channel mtu */ 1259 channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu( READ_BT_16(packet, 17));1259 channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(little_endian_read_16(packet, 17)); 1260 1260 break; 1261 1261 default: … … 1272 1272 case L2CAP_EVENT_CHANNEL_CLOSED: 1273 1273 // data: event (8), len(8), channel (16) 1274 l2cap_cid = READ_BT_16(packet, 2);1274 l2cap_cid = little_endian_read_16(packet, 2); 1275 1275 channel = bnep_channel_for_l2cap_cid(l2cap_cid); 1276 1276 log_info("L2CAP_EVENT_CHANNEL_CLOSED cid 0x%0x, channel %p", l2cap_cid, channel); … … 1331 1331 BD_ADDR_COPY(addr_source, &packet[pos]); 1332 1332 pos += sizeof(bd_addr_t); 1333 network_protocol_type = READ_NET_16(packet, pos);1333 network_protocol_type = big_endian_read_16(packet, pos); 1334 1334 pos += 2; 1335 1335 break; … … 1337 1337 BD_ADDR_COPY(addr_dest, channel->local_addr); 1338 1338 BD_ADDR_COPY(addr_source, channel->remote_addr); 1339 network_protocol_type = READ_NET_16(packet, pos);1339 network_protocol_type = big_endian_read_16(packet, pos); 1340 1340 pos += 2; 1341 1341 break; … … 1344 1344 BD_ADDR_COPY(addr_source, &packet[pos]); 1345 1345 pos += sizeof(bd_addr_t); 1346 network_protocol_type = READ_NET_16(packet, pos);1346 network_protocol_type = big_endian_read_16(packet, pos); 1347 1347 pos += 2; 1348 1348 break; … … 1351 1351 pos += sizeof(bd_addr_t); 1352 1352 BD_ADDR_COPY(addr_source, channel->remote_addr); 1353 network_protocol_type = READ_NET_16(packet, pos);1353 network_protocol_type = big_endian_read_16(packet, pos); 1354 1354 pos += 2; 1355 1355 break; … … 1563 1563 } 1564 1564 1565 channel->uuid_source = B NEP_UUID_PANU;1565 channel->uuid_source = BLUETOOTH_SERVICE_CLASS_PANU; 1566 1566 channel->uuid_dest = uuid_dest; 1567 1567 … … 1597 1597 1598 1598 /* Only alow one the three service types: PANU, NAP, GN */ 1599 if ((service_uuid != B NEP_UUID_PANU) &&1600 (service_uuid != B NEP_UUID_NAP) &&1601 (service_uuid != B NEP_UUID_GN)) {1599 if ((service_uuid != BLUETOOTH_SERVICE_CLASS_PANU) && 1600 (service_uuid != BLUETOOTH_SERVICE_CLASS_NAP) && 1601 (service_uuid != BLUETOOTH_SERVICE_CLASS_GN)) { 1602 1602 log_info("BNEP_REGISTER_SERVICE: Invalid service UUID: %04x", service_uuid); 1603 1603 return BNEP_CHANNEL_NOT_CONNECTED;
Note:
See TracChangeset
for help on using the changeset viewer.