[haiku-commits] r36026 - haiku/trunk/src/add-ons/kernel/network/protocols/l2cap

Author: oruizdorantes
Date: 2010-04-02 13:42:00 +0200 (Fri, 02 Apr 2010)
New Revision: 36026
Changeset: http://dev.haiku-os.org/changeset/36026/haiku

Modified:
   haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap_lower.cpp
Log:
- Prepending l2cap header in a separate function to not play with c++ contexts



Modified: haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap_lower.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap_lower.cpp      
2010-04-02 11:31:39 UTC (rev 36025)
+++ haiku/trunk/src/add-ons/kernel/network/protocols/l2cap/l2cap_lower.cpp      
2010-04-02 11:42:00 UTC (rev 36026)
@@ -101,6 +101,33 @@
 static thread_id sConnectionThread;
 
 
+static void
+AddL2capHeader(L2capFrame* frame)
+{
+       NetBufferPrepend<l2cap_hdr_t> bufferHeader(frame->buffer);
+       status_t status = bufferHeader.Status();
+
+       if (status < B_OK) {
+               debugf("header could not be prepended! code=%d\n", frame->code);
+               return;
+       }
+
+       // fill
+       bufferHeader->length = htole16(frame->buffer->size - 
sizeof(l2cap_hdr_t));
+       switch (frame->type) {
+               case L2CAP_C_FRAME:
+                       bufferHeader->dcid = L2CAP_SIGNAL_CID;
+               break;
+               case L2CAP_G_FRAME:
+                       bufferHeader->dcid = L2CAP_CLT_CID;
+               break;
+               default:
+                       bufferHeader->dcid = frame->channel->dcid;
+               break;
+       }
+}
+
+
 void
 purge_connection(HciConnection* conn)
 {
@@ -130,31 +157,8 @@
                if (frame->buffer == NULL)
                        panic("Malformed frame in ongoing queue");
 
-               {
-                       NetBufferPrepend<l2cap_hdr_t> 
bufferHeader(frame->buffer);
-                       status_t status = bufferHeader.Status();
-                       if (status < B_OK) {
-                               debugf("header could not be prepended! 
code=%d\n", frame->code);
-                               return;
+               AddL2capHeader(frame);
 
-                       }
-
-                       // fill
-                       bufferHeader->length = htole16(frame->buffer->size - 
sizeof(l2cap_hdr_t));
-                       switch (frame->type) {
-                               case L2CAP_C_FRAME:
-                                       bufferHeader->dcid = L2CAP_SIGNAL_CID;
-                               break;
-                               case L2CAP_G_FRAME:
-                                       bufferHeader->dcid = L2CAP_CLT_CID;
-                               break;
-                               default:
-                                       bufferHeader->dcid = 
frame->channel->dcid;
-                               break;
-
-                       }
-               }
-
                if (btDevices == NULL)
                if (get_module(BT_HCI_MODULE_NAME, (module_info**)&btDevices) 
!= B_OK) {
                        panic("l2cap: cannot get dev module");


Other related posts:

  • » [haiku-commits] r36026 - haiku/trunk/src/add-ons/kernel/network/protocols/l2cap - oliver . ruiz . dorantes