Index: asp3_tinet_ecnl_rx/trunk/btstack/src/bnep.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/btstack/src/bnep.c	(revision 337)
+++ asp3_tinet_ecnl_rx/trunk/btstack/src/bnep.c	(revision 374)
@@ -84,8 +84,8 @@
     event[1] = sizeof(event) - 2;
     event[2] = status;
-    bt_store_16(event, 3, channel->l2cap_cid);
-    bt_store_16(event, 5, channel->uuid_source);
-    bt_store_16(event, 7, channel->uuid_dest);
-    bt_store_16(event, 9, channel->max_frame_size);
+    little_endian_store_16(event, 3, channel->l2cap_cid);
+    little_endian_store_16(event, 5, channel->uuid_source);
+    little_endian_store_16(event, 7, channel->uuid_dest);
+    little_endian_store_16(event, 9, channel->max_frame_size);
     BD_ADDR_COPY(&event[11], channel->remote_addr);
     hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
@@ -101,7 +101,7 @@
     event[0] = BNEP_EVENT_CHANNEL_TIMEOUT;
     event[1] = sizeof(event) - 2;
-    bt_store_16(event, 2, channel->l2cap_cid);
-    bt_store_16(event, 4, channel->uuid_source);
-    bt_store_16(event, 6, channel->uuid_dest);
+    little_endian_store_16(event, 2, channel->l2cap_cid);
+    little_endian_store_16(event, 4, channel->uuid_source);
+    little_endian_store_16(event, 6, channel->uuid_dest);
     BD_ADDR_COPY(&event[8], channel->remote_addr);
     event[14] = channel->state;
@@ -118,7 +118,7 @@
     event[0] = BNEP_EVENT_CHANNEL_CLOSED;
     event[1] = sizeof(event) - 2;
-    bt_store_16(event, 2, channel->l2cap_cid);
-    bt_store_16(event, 4, channel->uuid_source);
-    bt_store_16(event, 6, channel->uuid_dest);
+    little_endian_store_16(event, 2, channel->l2cap_cid);
+    little_endian_store_16(event, 4, channel->uuid_source);
+    little_endian_store_16(event, 6, channel->uuid_dest);
     BD_ADDR_COPY(&event[8], channel->remote_addr);
     hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
@@ -133,5 +133,5 @@
     event[0] = BNEP_EVENT_READY_TO_SEND;
     event[1] = sizeof(event) - 2;
-    bt_store_16(event, 2, channel->l2cap_cid);
+    little_endian_store_16(event, 2, channel->l2cap_cid);
     hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
 	(*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event));
@@ -464,5 +464,5 @@
     BD_ADDR_COPY(addr_source, &packet[pos]);
     pos += sizeof(bd_addr_t);
-    network_protocol_type = READ_NET_16(packet, pos);
+    network_protocol_type = big_endian_read_16(packet, pos);
     pos += sizeof(uint16_t);
 
@@ -475,5 +475,5 @@
         }
         /* The "real" network protocol type is 4 bytes ahead in a VLAN packet */
-		network_protocol_type = READ_NET_16(packet, pos + 2);
+		network_protocol_type = big_endian_read_16(packet, pos + 2);
 	}
 
@@ -808,16 +808,16 @@
     /* Check source and destination UUIDs for valid combinations */
     if (response_code == BNEP_RESP_SETUP_SUCCESS) {
-        channel->uuid_dest = READ_NET_16(packet, 2 + uuid_offset);
-        channel->uuid_source = READ_NET_16(packet, 2 + uuid_offset + uuid_size);
-
-        if ((channel->uuid_dest != BNEP_UUID_PANU) &&
-            (channel->uuid_dest != BNEP_UUID_NAP) &&
-            (channel->uuid_dest != BNEP_UUID_GN)) {
+        channel->uuid_dest = big_endian_read_16(packet, 2 + uuid_offset);
+        channel->uuid_source = big_endian_read_16(packet, 2 + uuid_offset + uuid_size);
+
+        if ((channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_PANU) &&
+            (channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_NAP) &&
+            (channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_GN)) {
             log_error("BNEP_CONNECTION_REQUEST: Invalid destination service UUID: %04x", channel->uuid_dest);
             channel->uuid_dest = 0;
         }
-        if ((channel->uuid_source != BNEP_UUID_PANU) &&
-            (channel->uuid_source != BNEP_UUID_NAP) &&
-            (channel->uuid_source != BNEP_UUID_GN)) {
+        if ((channel->uuid_source != BLUETOOTH_SERVICE_CLASS_PANU) &&
+            (channel->uuid_source != BLUETOOTH_SERVICE_CLASS_NAP) &&
+            (channel->uuid_source != BLUETOOTH_SERVICE_CLASS_GN)) {
             log_error("BNEP_CONNECTION_REQUEST: Invalid source service UUID: %04x", channel->uuid_source);
             channel->uuid_source = 0;
@@ -829,5 +829,5 @@
             response_code = BNEP_RESP_SETUP_INVALID_DEST_UUID;
         } else
-        if ((channel->uuid_source != BNEP_UUID_PANU) && (channel->uuid_dest != BNEP_UUID_PANU)) {
+        if ((channel->uuid_source != BLUETOOTH_SERVICE_CLASS_PANU) && (channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_PANU)) {
             response_code = BNEP_RESP_SETUP_INVALID_SOURCE_UUID;
         }
@@ -857,5 +857,5 @@
     }
 
-    response_code = READ_NET_16(packet, 1);
+    response_code = big_endian_read_16(packet, 1);
 
     if (response_code == BNEP_RESP_SETUP_SUCCESS) {
@@ -882,5 +882,5 @@
     }
 
-    list_length = READ_NET_16(packet, 1);
+    list_length = big_endian_read_16(packet, 1);
     /* Sanity check packet size again with known package size */
     if (size < 3 + list_length) {
@@ -903,6 +903,6 @@
         /* There is still enough space, copy the filters to our filter list */
         for (i = 0; i < list_length / (2 * 2); i ++) {
-            channel->net_filter[channel->net_filter_count].range_start = READ_NET_16(packet, 1 + 2 + i * 4);
-            channel->net_filter[channel->net_filter_count].range_end = READ_NET_16(packet, 1 + 2 + i * 4 + 2);
+            channel->net_filter[channel->net_filter_count].range_start = big_endian_read_16(packet, 1 + 2 + i * 4);
+            channel->net_filter[channel->net_filter_count].range_end = big_endian_read_16(packet, 1 + 2 + i * 4 + 2);
             if (channel->net_filter[channel->net_filter_count].range_start > channel->net_filter[channel->net_filter_count].range_end) {
                 /* Invalid filter range, ignore this filter rule */
@@ -945,5 +945,5 @@
     }
 
-    response_code = READ_NET_16(packet, 1);
+    response_code = big_endian_read_16(packet, 1);
 
     if (response_code == BNEP_RESP_FILTER_SUCCESS) {
@@ -966,5 +966,5 @@
     }
 
-    list_length = READ_NET_16(packet, 1);
+    list_length = big_endian_read_16(packet, 1);
     /* Sanity check packet size again with known package size */
     if (size < 3 + list_length) {
@@ -1032,5 +1032,5 @@
     }
 
-    response_code = READ_NET_16(packet, 1);
+    response_code = big_endian_read_16(packet, 1);
 
     if (response_code == BNEP_RESP_FILTER_SUCCESS) {
@@ -1169,8 +1169,8 @@
         case L2CAP_EVENT_INCOMING_CONNECTION:
             /* L2CAP event data: event(8), len(8), address(48), handle (16),  psm (16), source cid(16) dest cid(16) */
-            bt_flip_addr(event_addr, &packet[2]);
-            con_handle = READ_BT_16(packet,  8);
-            psm        = READ_BT_16(packet, 10);
-            l2cap_cid  = READ_BT_16(packet, 12);
+            reverse_bd_addr(&packet[2], event_addr);
+            con_handle = little_endian_read_16(packet,  8);
+            psm        = little_endian_read_16(packet, 10);
+            l2cap_cid  = little_endian_read_16(packet, 12);
 
             if (psm != PSM_BNEP) break;
@@ -1211,5 +1211,5 @@
         case L2CAP_EVENT_CHANNEL_OPENED:
             /* Check if the l2cap channel has been opened for PSM_BNEP */
-            if (READ_BT_16(packet, 11) != PSM_BNEP) {
+            if (little_endian_read_16(packet, 11) != PSM_BNEP) {
                 break;
             }
@@ -1219,7 +1219,7 @@
 
             /* Get the bnep channel fpr remote address */
-            con_handle = READ_BT_16(packet, 9);
-            l2cap_cid  = READ_BT_16(packet, 13);
-            bt_flip_addr(event_addr, &packet[3]);
+            con_handle = little_endian_read_16(packet, 9);
+            l2cap_cid  = little_endian_read_16(packet, 13);
+            reverse_bd_addr(&packet[3], event_addr);
             channel = bnep_channel_for_addr(&event_addr);
             if (!channel) {
@@ -1252,10 +1252,10 @@
                     channel->state = BNEP_CHANNEL_STATE_WAIT_FOR_CONNECTION_RESPONSE;
                     bnep_channel_state_add(channel, BNEP_CHANNEL_STATE_VAR_SND_CONNECTION_REQUEST);
-                    channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(READ_BT_16(packet, 17));
+                    channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(little_endian_read_16(packet, 17));
                     bnep_run();
                     break;
                 case BNEP_CHANNEL_STATE_WAIT_FOR_CONNECTION_REQUEST:
                     /* New information: channel mtu */
-                    channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(READ_BT_16(packet, 17));
+                    channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(little_endian_read_16(packet, 17));
                     break;
                 default:
@@ -1272,5 +1272,5 @@
         case L2CAP_EVENT_CHANNEL_CLOSED:
             // data: event (8), len(8), channel (16)
-            l2cap_cid   = READ_BT_16(packet, 2);
+            l2cap_cid   = little_endian_read_16(packet, 2);
             channel = bnep_channel_for_l2cap_cid(l2cap_cid);
             log_info("L2CAP_EVENT_CHANNEL_CLOSED cid 0x%0x, channel %p", l2cap_cid, channel);
@@ -1331,5 +1331,5 @@
             BD_ADDR_COPY(addr_source, &packet[pos]);
             pos += sizeof(bd_addr_t);
-            network_protocol_type = READ_NET_16(packet, pos);
+            network_protocol_type = big_endian_read_16(packet, pos);
             pos += 2;
             break;
@@ -1337,5 +1337,5 @@
             BD_ADDR_COPY(addr_dest, channel->local_addr);
             BD_ADDR_COPY(addr_source, channel->remote_addr);
-            network_protocol_type = READ_NET_16(packet, pos);
+            network_protocol_type = big_endian_read_16(packet, pos);
             pos += 2;
             break;
@@ -1344,5 +1344,5 @@
             BD_ADDR_COPY(addr_source, &packet[pos]);
             pos += sizeof(bd_addr_t);
-            network_protocol_type = READ_NET_16(packet, pos);
+            network_protocol_type = big_endian_read_16(packet, pos);
             pos += 2;
             break;
@@ -1351,5 +1351,5 @@
             pos += sizeof(bd_addr_t);
             BD_ADDR_COPY(addr_source, channel->remote_addr);
-            network_protocol_type = READ_NET_16(packet, pos);
+            network_protocol_type = big_endian_read_16(packet, pos);
             pos += 2;
             break;
@@ -1563,5 +1563,5 @@
     }
 
-    channel->uuid_source = BNEP_UUID_PANU;
+    channel->uuid_source = BLUETOOTH_SERVICE_CLASS_PANU;
     channel->uuid_dest   = uuid_dest;
 
@@ -1597,7 +1597,7 @@
 
     /* Only alow one the three service types: PANU, NAP, GN */
-    if ((service_uuid != BNEP_UUID_PANU) &&
-        (service_uuid != BNEP_UUID_NAP) &&
-        (service_uuid != BNEP_UUID_GN)) {
+    if ((service_uuid != BLUETOOTH_SERVICE_CLASS_PANU) &&
+        (service_uuid != BLUETOOTH_SERVICE_CLASS_NAP) &&
+        (service_uuid != BLUETOOTH_SERVICE_CLASS_GN)) {
         log_info("BNEP_REGISTER_SERVICE: Invalid service UUID: %04x", service_uuid);
         return BNEP_CHANNEL_NOT_CONNECTED;
