2 * Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
3 * All rights reserved. Distributed under the terms of the MIT License.
6 #include "FrameInterface.h"
14 SignalByIdent(HciConnection
* conn
, uint8 ident
)
18 mutex_lock(&conn
->fLockExpected
);
19 DoublyLinkedList
<L2capFrame
>::Iterator iterator
20 = conn
->ExpectedResponses
.GetIterator();
22 while (iterator
.HasNext()) {
24 frame
= iterator
.Next();
25 if (frame
->type
== L2CAP_C_FRAME
&& frame
->ident
== ident
) {
26 mutex_unlock(&frame
->conn
->fLockExpected
);
31 mutex_unlock(&conn
->fLockExpected
);
38 TimeoutSignal(L2capFrame
* frame
, uint32 timeo
)
48 unTimeoutSignal(L2capFrame
* frame
)
58 SpawmFrame(HciConnection
* conn
, L2capChannel
* channel
, net_buffer
* buffer
,
62 panic("Null Buffer to outgoing queue");
64 L2capFrame
* frame
= new (std::nothrow
) L2capFrame
;
67 frame
->channel
= channel
; // TODO: maybe only scid needed
69 frame
->buffer
= buffer
;
72 mutex_lock(&conn
->fLock
);
74 conn
->OutGoingFrames
.Add(frame
, true);
76 mutex_unlock(&conn
->fLock
);
83 SpawmSignal(HciConnection
* conn
, L2capChannel
* channel
, net_buffer
* buffer
,
84 uint8 ident
, uint8 code
)
87 panic("Null Buffer to outgoing queue");
89 L2capFrame
* frame
= new (std::nothrow
) L2capFrame
;
92 frame
->channel
= channel
; // TODO: not specific descriptor should be required
94 frame
->buffer
= buffer
;
95 frame
->type
= L2CAP_C_FRAME
;
99 mutex_lock(&conn
->fLock
);
101 conn
->OutGoingFrames
.Add(frame
, true);
103 mutex_unlock(&conn
->fLock
);
110 AcknowledgeSignal(L2capFrame
* frame
)
115 if (frame
->type
== L2CAP_C_FRAME
) {
116 HciConnection
* connection
= frame
->conn
;
118 unTimeoutSignal(frame
);
119 mutex_lock(&connection
->fLockExpected
);
120 connection
->ExpectedResponses
.Remove(frame
);
121 mutex_unlock(&connection
->fLockExpected
);
124 // NO! This will be deleted by lower layers while being sent!
125 // gBufferModule->free(frame->buffer);
136 QueueSignal(L2capFrame
* frame
)
140 if (frame
->type
== L2CAP_C_FRAME
) {
141 mutex_lock(&frame
->conn
->fLockExpected
);
142 frame
->conn
->ExpectedResponses
.Add(frame
);
143 mutex_unlock(&frame
->conn
->fLockExpected
);