xref: /nrf52832-nimble/packages/NimBLE-latest/nimble/host/src/ble_l2cap_coc_priv.h (revision 042d53a763ad75cb1465103098bb88c245d95138)
1*042d53a7SEvalZero /*
2*042d53a7SEvalZero  * Licensed to the Apache Software Foundation (ASF) under one
3*042d53a7SEvalZero  * or more contributor license agreements.  See the NOTICE file
4*042d53a7SEvalZero  * distributed with this work for additional information
5*042d53a7SEvalZero  * regarding copyright ownership.  The ASF licenses this file
6*042d53a7SEvalZero  * to you under the Apache License, Version 2.0 (the
7*042d53a7SEvalZero  * "License"); you may not use this file except in compliance
8*042d53a7SEvalZero  * with the License.  You may obtain a copy of the License at
9*042d53a7SEvalZero  *
10*042d53a7SEvalZero  *  http://www.apache.org/licenses/LICENSE-2.0
11*042d53a7SEvalZero  *
12*042d53a7SEvalZero  * Unless required by applicable law or agreed to in writing,
13*042d53a7SEvalZero  * software distributed under the License is distributed on an
14*042d53a7SEvalZero  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15*042d53a7SEvalZero  * KIND, either express or implied.  See the License for the
16*042d53a7SEvalZero  * specific language governing permissions and limitations
17*042d53a7SEvalZero  * under the License.
18*042d53a7SEvalZero  */
19*042d53a7SEvalZero 
20*042d53a7SEvalZero #ifndef H_L2CAP_COC_PRIV_
21*042d53a7SEvalZero #define H_L2CAP_COC_PRIV_
22*042d53a7SEvalZero 
23*042d53a7SEvalZero #include <inttypes.h>
24*042d53a7SEvalZero #include "syscfg/syscfg.h"
25*042d53a7SEvalZero #include "os/queue.h"
26*042d53a7SEvalZero #include "os/os_mbuf.h"
27*042d53a7SEvalZero #include "host/ble_l2cap.h"
28*042d53a7SEvalZero #include "ble_l2cap_sig_priv.h"
29*042d53a7SEvalZero #ifdef __cplusplus
30*042d53a7SEvalZero extern "C" {
31*042d53a7SEvalZero #endif
32*042d53a7SEvalZero 
33*042d53a7SEvalZero #define BLE_L2CAP_COC_MTU                       100
34*042d53a7SEvalZero #define BLE_L2CAP_COC_CID_START                 0x0040
35*042d53a7SEvalZero #define BLE_L2CAP_COC_CID_END                   0x007F
36*042d53a7SEvalZero 
37*042d53a7SEvalZero struct ble_l2cap_chan;
38*042d53a7SEvalZero 
39*042d53a7SEvalZero struct ble_l2cap_coc_endpoint {
40*042d53a7SEvalZero     uint16_t mtu;
41*042d53a7SEvalZero     uint16_t credits;
42*042d53a7SEvalZero     uint16_t data_offset;
43*042d53a7SEvalZero     struct os_mbuf *sdu;
44*042d53a7SEvalZero };
45*042d53a7SEvalZero 
46*042d53a7SEvalZero struct ble_l2cap_coc_srv {
47*042d53a7SEvalZero     STAILQ_ENTRY(ble_l2cap_coc_srv) next;
48*042d53a7SEvalZero     uint16_t psm;
49*042d53a7SEvalZero     uint16_t mtu;
50*042d53a7SEvalZero     ble_l2cap_event_fn *cb;
51*042d53a7SEvalZero     void *cb_arg;
52*042d53a7SEvalZero };
53*042d53a7SEvalZero 
54*042d53a7SEvalZero #if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) != 0
55*042d53a7SEvalZero int ble_l2cap_coc_init(void);
56*042d53a7SEvalZero int ble_l2cap_coc_create_server(uint16_t psm, uint16_t mtu,
57*042d53a7SEvalZero                                 ble_l2cap_event_fn *cb, void *cb_arg);
58*042d53a7SEvalZero int ble_l2cap_coc_create_srv_chan(uint16_t conn_handle, uint16_t psm,
59*042d53a7SEvalZero                                   struct ble_l2cap_chan **chan);
60*042d53a7SEvalZero struct ble_l2cap_chan * ble_l2cap_coc_chan_alloc(uint16_t conn_handle,
61*042d53a7SEvalZero                                                  uint16_t psm, uint16_t mtu,
62*042d53a7SEvalZero                                                  struct os_mbuf *sdu_rx,
63*042d53a7SEvalZero                                                  ble_l2cap_event_fn *cb,
64*042d53a7SEvalZero                                                  void *cb_arg);
65*042d53a7SEvalZero void ble_l2cap_coc_cleanup_chan(struct ble_l2cap_chan *chan);
66*042d53a7SEvalZero void ble_l2cap_coc_le_credits_update(uint16_t conn_handle, uint16_t dcid,
67*042d53a7SEvalZero                                     uint16_t credits);
68*042d53a7SEvalZero void ble_l2cap_coc_recv_ready(struct ble_l2cap_chan *chan,
69*042d53a7SEvalZero                               struct os_mbuf *sdu_rx);
70*042d53a7SEvalZero int ble_l2cap_coc_send(struct ble_l2cap_chan *chan, struct os_mbuf *sdu_tx);
71*042d53a7SEvalZero #else
72*042d53a7SEvalZero #define ble_l2cap_coc_init()                                    0
73*042d53a7SEvalZero #define ble_l2cap_coc_create_server(psm, mtu, cb, cb_arg)       BLE_HS_ENOTSUP
74*042d53a7SEvalZero #define ble_l2cap_coc_recv_ready(chan, sdu_rx)
75*042d53a7SEvalZero #define ble_l2cap_coc_cleanup_chan(chan)
76*042d53a7SEvalZero #define ble_l2cap_coc_send(chan, sdu_tx)                        BLE_HS_ENOTSUP
77*042d53a7SEvalZero #endif
78*042d53a7SEvalZero 
79*042d53a7SEvalZero #ifdef __cplusplus
80*042d53a7SEvalZero }
81*042d53a7SEvalZero #endif
82*042d53a7SEvalZero 
83*042d53a7SEvalZero #endif /* H_L2CAP_COC_PRIV_ */
84