Changeset View
Changeset View
Standalone View
Standalone View
sys/netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | "%s: %s - invalid L2CA_Connect request message size, size=%d\n", | ||||
msg->header.arglen); | msg->header.arglen); | ||||
error = EMSGSIZE; | error = EMSGSIZE; | ||||
goto out; | goto out; | ||||
} | } | ||||
ip = (ng_l2cap_l2ca_con_ip *)(msg->data); | ip = (ng_l2cap_l2ca_con_ip *)(msg->data); | ||||
/* Check if we have connection to the remote unit */ | /* Check if we have connection to the remote unit */ | ||||
con = ng_l2cap_con_by_addr(l2cap, &ip->bdaddr); | con = ng_l2cap_con_by_addr(l2cap, &ip->bdaddr, ip->linktype); | ||||
if (con == NULL) { | if (con == NULL) { | ||||
/* Submit LP_ConnectReq to the lower layer */ | /* Submit LP_ConnectReq to the lower layer */ | ||||
error = ng_l2cap_lp_con_req(l2cap, &ip->bdaddr); | error = ng_l2cap_lp_con_req(l2cap, &ip->bdaddr,ip->linktype); | ||||
if (error != 0) { | if (error != 0) { | ||||
NG_L2CAP_ERR( | NG_L2CAP_ERR( | ||||
"%s: %s - unable to send LP_ConnectReq message, error=%d\n", | "%s: %s - unable to send LP_ConnectReq message, error=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), error); | __func__, NG_NODE_NAME(l2cap->node), error); | ||||
goto out; | goto out; | ||||
} | } | ||||
/* This should not fail */ | /* This should not fail */ | ||||
con = ng_l2cap_con_by_addr(l2cap, &ip->bdaddr); | con = ng_l2cap_con_by_addr(l2cap, &ip->bdaddr, ip->linktype); | ||||
KASSERT((con != NULL), | KASSERT((con != NULL), | ||||
("%s: %s - could not find connection!\n", __func__, NG_NODE_NAME(l2cap->node))); | ("%s: %s - could not find connection!\n", __func__, NG_NODE_NAME(l2cap->node))); | ||||
} | } | ||||
/* | /* | ||||
* Create new empty channel descriptor. In case of any failure do | * Create new empty channel descriptor. In case of any failure do | ||||
* not touch connection descriptor. | * not touch connection descriptor. | ||||
*/ | */ | ||||
ch = ng_l2cap_new_chan(l2cap, con, ip->psm); | ch = ng_l2cap_new_chan(l2cap, con, ip->psm, ip->idtype); | ||||
if (ch == NULL) { | if (ch == NULL) { | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto out; | goto out; | ||||
} | } | ||||
/* Now create L2CAP_ConnectReq command */ | /* Now create L2CAP_ConnectReq command */ | ||||
cmd = ng_l2cap_new_cmd(ch->con, ch, ng_l2cap_get_ident(con), | cmd = ng_l2cap_new_cmd(ch->con, ch, ng_l2cap_get_ident(con), | ||||
NG_L2CAP_CON_REQ, msg->header.token); | NG_L2CAP_CON_REQ, msg->header.token); | ||||
if (cmd == NULL) { | if (cmd == NULL) { | ||||
ng_l2cap_free_chan(ch); | ng_l2cap_free_chan(ch); | ||||
error = ENOMEM; | error = ENOMEM; | ||||
goto out; | goto out; | ||||
} | } | ||||
if (cmd->ident == NG_L2CAP_NULL_IDENT) { | if (cmd->ident == NG_L2CAP_NULL_IDENT) { | ||||
ng_l2cap_free_cmd(cmd); | ng_l2cap_free_cmd(cmd); | ||||
ng_l2cap_free_chan(ch); | ng_l2cap_free_chan(ch); | ||||
error = EIO; | error = EIO; | ||||
goto out; | goto out; | ||||
} | } | ||||
/* Create L2CAP command packet */ | /* Create L2CAP command packet */ | ||||
if(ip->idtype == NG_L2CAP_L2CA_IDTYPE_ATT){ | |||||
_ng_l2cap_con_rsp(cmd->aux, cmd->ident, NG_L2CAP_ATT_CID, | |||||
NG_L2CAP_ATT_CID, 0, 0); | |||||
cmd->aux->m_flags |= M_PROTO2; | |||||
emax: i'm confused here. this is request path, but _ng_l2cap_con_rsp (response) is used. can you… | |||||
takawataAuthorUnsubmitted Not Done Inline ActionsSee above. takawata: See above. | |||||
emaxUnsubmitted Not Done Inline Actionsyes. i'm still confused, sorry. is there no other way? is it no possible to adjust state here? emax: yes. i'm still confused, sorry. is there no other way? is it no possible to adjust state here? | |||||
}else{ | |||||
_ng_l2cap_con_req(cmd->aux, cmd->ident, ch->psm, ch->scid); | _ng_l2cap_con_req(cmd->aux, cmd->ident, ch->psm, ch->scid); | ||||
} | |||||
if (cmd->aux == NULL) { | if (cmd->aux == NULL) { | ||||
ng_l2cap_free_cmd(cmd); | ng_l2cap_free_cmd(cmd); | ||||
ng_l2cap_free_chan(ch); | ng_l2cap_free_chan(ch); | ||||
error = ENOBUFS; | error = ENOBUFS; | ||||
goto out; | goto out; | ||||
} | } | ||||
ch->state = NG_L2CAP_W4_L2CAP_CON_RSP; | ch->state = NG_L2CAP_W4_L2CAP_CON_RSP; | ||||
Show All 39 Lines | else { | ||||
op = (ng_l2cap_l2ca_con_op *)(msg->data); | op = (ng_l2cap_l2ca_con_op *)(msg->data); | ||||
/* | /* | ||||
* XXX Spec. says we should only populate LCID when result == 0 | * XXX Spec. says we should only populate LCID when result == 0 | ||||
* What about PENDING? What the heck, for now always populate | * What about PENDING? What the heck, for now always populate | ||||
* LCID :) | * LCID :) | ||||
*/ | */ | ||||
if(ch->scid == NG_L2CAP_ATT_CID){ | |||||
op->idtype = NG_L2CAP_L2CA_IDTYPE_ATT; | |||||
op->lcid = ch->con->con_handle; | |||||
}else{ | |||||
op->idtype = (ch->con->linktype == NG_HCI_LINK_ACL)? | |||||
NG_L2CAP_L2CA_IDTYPE_BREDR : | |||||
NG_L2CAP_L2CA_IDTYPE_LE; | |||||
op->lcid = ch->scid; | op->lcid = ch->scid; | ||||
} | |||||
op->result = result; | op->result = result; | ||||
op->status = status; | op->status = status; | ||||
NG_SEND_MSG_HOOK(error, l2cap->node, msg, l2cap->l2c, 0); | NG_SEND_MSG_HOOK(error, l2cap->node, msg, l2cap->l2c, 0); | ||||
} | } | ||||
return (error); | return (error); | ||||
} /* ng_l2cap_l2ca_con_rsp */ | } /* ng_l2cap_l2ca_con_rsp */ | ||||
Show All 20 Lines | "%s: %s - invalid L2CA_ConnectRsp request message size, size=%d\n", | ||||
msg->header.arglen); | msg->header.arglen); | ||||
error = EMSGSIZE; | error = EMSGSIZE; | ||||
goto out; | goto out; | ||||
} | } | ||||
ip = (ng_l2cap_l2ca_con_rsp_ip *)(msg->data); | ip = (ng_l2cap_l2ca_con_rsp_ip *)(msg->data); | ||||
/* Check if we have this channel */ | /* Check if we have this channel */ | ||||
ch = ng_l2cap_chan_by_scid(l2cap, ip->lcid); | if(ip->lcid != NG_L2CAP_ATT_CID){ | ||||
ch = ng_l2cap_chan_by_scid(l2cap, ip->lcid | |||||
,(ip->linktype == NG_HCI_LINK_ACL)? | |||||
NG_L2CAP_L2CA_IDTYPE_BREDR: | |||||
NG_L2CAP_L2CA_IDTYPE_LE); | |||||
}else{ | |||||
// For now not support on ATT device. | |||||
ch = NULL; | |||||
} | |||||
if (ch == NULL) { | if (ch == NULL) { | ||||
NG_L2CAP_ALERT( | NG_L2CAP_ALERT( | ||||
"%s: %s - unexpected L2CA_ConnectRsp request message. " \ | "%s: %s - unexpected L2CA_ConnectRsp request message. " \ | ||||
"Channel does not exist, lcid=%d\n", | "Channel does not exist, lcid=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), ip->lcid); | __func__, NG_NODE_NAME(l2cap->node), ip->lcid); | ||||
error = ENOENT; | error = ENOENT; | ||||
goto out; | goto out; | ||||
} | } | ||||
Show All 22 Lines | |||||
"%s: %s - channel ident and response ident do not match, scid=%d, ident=%d. " \ | "%s: %s - channel ident and response ident do not match, scid=%d, ident=%d. " \ | ||||
"Will use response ident=%d\n", | "Will use response ident=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), ch->scid, | __func__, NG_NODE_NAME(l2cap->node), ch->scid, | ||||
ch->ident, ip->ident); | ch->ident, ip->ident); | ||||
/* Check result */ | /* Check result */ | ||||
switch (ip->result) { | switch (ip->result) { | ||||
case NG_L2CAP_SUCCESS: | case NG_L2CAP_SUCCESS: | ||||
ch->state = NG_L2CAP_CONFIG; | ch->state = (ch->scid == NG_L2CAP_ATT_CID)? | ||||
NG_L2CAP_OPEN : NG_L2CAP_CONFIG; | |||||
ch->cfg_state = 0; | ch->cfg_state = 0; | ||||
break; | break; | ||||
case NG_L2CAP_PENDING: | case NG_L2CAP_PENDING: | ||||
break; | break; | ||||
default: | default: | ||||
ng_l2cap_free_chan(ch); | ng_l2cap_free_chan(ch); | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | "%s: %s - Invalid L2CA_Config request message size, size=%d\n", | ||||
msg->header.arglen); | msg->header.arglen); | ||||
error = EMSGSIZE; | error = EMSGSIZE; | ||||
goto out; | goto out; | ||||
} | } | ||||
ip = (ng_l2cap_l2ca_cfg_ip *)(msg->data); | ip = (ng_l2cap_l2ca_cfg_ip *)(msg->data); | ||||
/* Check if we have this channel */ | /* Check if we have this channel */ | ||||
ch = ng_l2cap_chan_by_scid(l2cap, ip->lcid); | ch = ng_l2cap_chan_by_scid(l2cap, ip->lcid, NG_L2CAP_L2CA_IDTYPE_BREDR); | ||||
if (ch == NULL) { | if (ch == NULL) { | ||||
NG_L2CAP_ERR( | NG_L2CAP_ERR( | ||||
"%s: %s - unexpected L2CA_Config request message. " \ | "%s: %s - unexpected L2CA_Config request message. " \ | ||||
"Channel does not exist, lcid=%d\n", | "Channel does not exist, lcid=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), ip->lcid); | __func__, NG_NODE_NAME(l2cap->node), ip->lcid); | ||||
error = ENOENT; | error = ENOENT; | ||||
goto out; | goto out; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | "Invalid channel state, state=%d, lcid=%d\n", | ||||
if (cmd->aux == NULL) { | if (cmd->aux == NULL) { | ||||
ng_l2cap_free_cmd(cmd); | ng_l2cap_free_cmd(cmd); | ||||
error = ENOBUFS; | error = ENOBUFS; | ||||
goto out; | goto out; | ||||
} | } | ||||
/* Adjust channel state for re-configuration */ | /* Adjust channel state for re-configuration */ | ||||
if (ch->state == NG_L2CAP_OPEN) { | if (ch->state == NG_L2CAP_OPEN) { | ||||
ch->state = NG_L2CAP_CONFIG; | ch->state = (ch->scid == NG_L2CAP_ATT_CID)? | ||||
NG_L2CAP_OPEN : NG_L2CAP_CONFIG; | |||||
ch->cfg_state = 0; | ch->cfg_state = 0; | ||||
} | } | ||||
/* Link command to the queue */ | /* Link command to the queue */ | ||||
ng_l2cap_link_cmd(ch->con, cmd); | ng_l2cap_link_cmd(ch->con, cmd); | ||||
ng_l2cap_lp_deliver(ch->con); | ng_l2cap_lp_deliver(ch->con); | ||||
out: | out: | ||||
return (error); | return (error); | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | "%s: %s - invalid L2CA_ConfigRsp request message size, size=%d\n", | ||||
msg->header.arglen); | msg->header.arglen); | ||||
error = EMSGSIZE; | error = EMSGSIZE; | ||||
goto out; | goto out; | ||||
} | } | ||||
ip = (ng_l2cap_l2ca_cfg_rsp_ip *)(msg->data); | ip = (ng_l2cap_l2ca_cfg_rsp_ip *)(msg->data); | ||||
/* Check if we have this channel */ | /* Check if we have this channel */ | ||||
ch = ng_l2cap_chan_by_scid(l2cap, ip->lcid); | ch = ng_l2cap_chan_by_scid(l2cap, ip->lcid, | ||||
NG_L2CAP_L2CA_IDTYPE_BREDR); | |||||
if (ch == NULL) { | if (ch == NULL) { | ||||
NG_L2CAP_ERR( | NG_L2CAP_ERR( | ||||
"%s: %s - unexpected L2CA_ConfigRsp request message. " \ | "%s: %s - unexpected L2CA_ConfigRsp request message. " \ | ||||
"Channel does not exist, lcid=%d\n", | "Channel does not exist, lcid=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), ip->lcid); | __func__, NG_NODE_NAME(l2cap->node), ip->lcid); | ||||
error = ENOENT; | error = ENOENT; | ||||
goto out; | goto out; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | |||||
"Payload length does not match, length=%d, len=%d\n", | "Payload length does not match, length=%d, len=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), l2ca_hdr->length, | __func__, NG_NODE_NAME(l2cap->node), l2ca_hdr->length, | ||||
m->m_pkthdr.len); | m->m_pkthdr.len); | ||||
error = EMSGSIZE; | error = EMSGSIZE; | ||||
goto drop; | goto drop; | ||||
} | } | ||||
/* Check channel ID */ | /* Check channel ID */ | ||||
if (l2ca_hdr->idtype == NG_L2CAP_L2CA_IDTYPE_ATT){ | |||||
ch = ng_l2cap_chan_by_conhandle(l2cap, NG_L2CAP_ATT_CID, | |||||
l2ca_hdr->lcid); | |||||
} else{ | |||||
if (l2ca_hdr->lcid < NG_L2CAP_FIRST_CID) { | if (l2ca_hdr->lcid < NG_L2CAP_FIRST_CID) { | ||||
NG_L2CAP_ERR( | NG_L2CAP_ERR( | ||||
"%s: %s - invalid L2CA Data packet. Inavlid channel ID, cid=%d\n", | "%s: %s - invalid L2CA Data packet. Inavlid channel ID, cid=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), l2ca_hdr->lcid); | __func__, NG_NODE_NAME(l2cap->node), | ||||
l2ca_hdr->lcid); | |||||
error = EINVAL; | error = EINVAL; | ||||
goto drop; | goto drop; | ||||
} | } | ||||
/* Verify that we have the channel and make sure it is open */ | /* Verify that we have the channel and make sure it is open */ | ||||
ch = ng_l2cap_chan_by_scid(l2cap, l2ca_hdr->lcid); | ch = ng_l2cap_chan_by_scid(l2cap, l2ca_hdr->lcid, | ||||
l2ca_hdr->idtype); | |||||
} | |||||
if (ch == NULL) { | if (ch == NULL) { | ||||
NG_L2CAP_ERR( | NG_L2CAP_ERR( | ||||
"%s: %s - invalid L2CA Data packet. Channel does not exist, cid=%d\n", | "%s: %s - invalid L2CA Data packet. Channel does not exist, cid=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), l2ca_hdr->lcid); | __func__, NG_NODE_NAME(l2cap->node), l2ca_hdr->lcid); | ||||
error = ENOENT; | error = ENOENT; | ||||
goto drop; | goto drop; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | if (msg == NULL) | ||||
error = ENOMEM; | error = ENOMEM; | ||||
else { | else { | ||||
msg->header.token = token; | msg->header.token = token; | ||||
msg->header.flags |= NGF_RESP; | msg->header.flags |= NGF_RESP; | ||||
op = (ng_l2cap_l2ca_write_op *)(msg->data); | op = (ng_l2cap_l2ca_write_op *)(msg->data); | ||||
op->result = result; | op->result = result; | ||||
op->length = length; | op->length = length; | ||||
if(ch->scid == NG_L2CAP_ATT_CID){ | |||||
op->idtype = NG_L2CAP_L2CA_IDTYPE_ATT; | |||||
op->lcid = ch->con->con_handle; | |||||
}else{ | |||||
op->idtype = (ch->con->linktype == NG_HCI_LINK_ACL)? | |||||
NG_L2CAP_L2CA_IDTYPE_BREDR : | |||||
NG_L2CAP_L2CA_IDTYPE_LE; | |||||
op->lcid = ch->scid; | op->lcid = ch->scid; | ||||
} | |||||
NG_SEND_MSG_HOOK(error, l2cap->node, msg, l2cap->l2c, 0); | NG_SEND_MSG_HOOK(error, l2cap->node, msg, l2cap->l2c, 0); | ||||
} | } | ||||
return (error); | return (error); | ||||
} /* ng_l2cap_l2ca_write_rsp */ | } /* ng_l2cap_l2ca_write_rsp */ | ||||
/* | /* | ||||
* Receive packet from the lower layer protocol and send it to the upper | * Receive packet from the lower layer protocol and send it to the upper | ||||
* layer protocol (L2CAP_Read) | * layer protocol (L2CAP_Read) | ||||
*/ | */ | ||||
int | int | ||||
ng_l2cap_l2ca_receive(ng_l2cap_con_p con) | ng_l2cap_l2ca_receive(ng_l2cap_con_p con) | ||||
{ | { | ||||
ng_l2cap_p l2cap = con->l2cap; | ng_l2cap_p l2cap = con->l2cap; | ||||
ng_l2cap_hdr_t *hdr = NULL; | ng_l2cap_hdr_t *hdr = NULL; | ||||
ng_l2cap_chan_p ch = NULL; | ng_l2cap_chan_p ch = NULL; | ||||
int error = 0; | int error = 0; | ||||
int idtype; | |||||
uint16_t *idp; | |||||
NG_L2CAP_M_PULLUP(con->rx_pkt, sizeof(*hdr)); | NG_L2CAP_M_PULLUP(con->rx_pkt, sizeof(*hdr)); | ||||
if (con->rx_pkt == NULL) | if (con->rx_pkt == NULL) | ||||
return (ENOBUFS); | return (ENOBUFS); | ||||
hdr = mtod(con->rx_pkt, ng_l2cap_hdr_t *); | hdr = mtod(con->rx_pkt, ng_l2cap_hdr_t *); | ||||
/* Check channel */ | /* Check channel */ | ||||
ch = ng_l2cap_chan_by_scid(l2cap, hdr->dcid); | if(hdr->dcid == NG_L2CAP_ATT_CID){ | ||||
idtype = NG_L2CAP_L2CA_IDTYPE_ATT; | |||||
ch = ng_l2cap_chan_by_conhandle(l2cap, NG_L2CAP_ATT_CID, | |||||
con->con_handle); | |||||
/* | |||||
* Here,ATT channel is distinguished by | |||||
* connection handle | |||||
*/ | |||||
hdr->dcid = con->con_handle; | |||||
}else{ | |||||
idtype = (con->linktype==NG_HCI_LINK_ACL)? | |||||
NG_L2CAP_L2CA_IDTYPE_BREDR: | |||||
NG_L2CAP_L2CA_IDTYPE_LE; | |||||
ch = ng_l2cap_chan_by_scid(l2cap, hdr->dcid, idtype); | |||||
} | |||||
if (ch == NULL) { | if (ch == NULL) { | ||||
NG_L2CAP_ERR( | NG_L2CAP_ERR( | ||||
"%s: %s - unexpected L2CAP data packet. Channel does not exist, cid=%d\n", | "%s: %s - unexpected L2CAP data packet. Channel does not exist, cid=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), hdr->dcid); | __func__, NG_NODE_NAME(l2cap->node), hdr->dcid); | ||||
error = ENOENT; | error = ENOENT; | ||||
goto drop; | goto drop; | ||||
} | } | ||||
/* Check channel state */ | /* Check channel state */ | ||||
if (ch->state != NG_L2CAP_OPEN) { | if (ch->state != NG_L2CAP_OPEN) { | ||||
NG_L2CAP_WARN( | NG_L2CAP_WARN( | ||||
"%s: %s - unexpected L2CAP data packet. " \ | "%s: %s - unexpected L2CAP data packet. " \ | ||||
Show All 24 Lines | "Packet too big, length=%d, imtu=%d, cid=%d\n", | ||||
if (l2cap->l2c == NULL || NG_HOOK_NOT_VALID(l2cap->l2c)) { | if (l2cap->l2c == NULL || NG_HOOK_NOT_VALID(l2cap->l2c)) { | ||||
NG_L2CAP_ERR( | NG_L2CAP_ERR( | ||||
"%s: %s - unable to send L2CAP data packet. " \ | "%s: %s - unable to send L2CAP data packet. " \ | ||||
"Hook is not connected or valid, psm=%d\n", | "Hook is not connected or valid, psm=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), ch->psm); | __func__, NG_NODE_NAME(l2cap->node), ch->psm); | ||||
error = ENOTCONN; | error = ENOTCONN; | ||||
goto drop; | goto drop; | ||||
} | } | ||||
M_PREPEND(con->rx_pkt, sizeof(uint16_t), M_NOWAIT); | |||||
if(con->rx_pkt == NULL) | |||||
goto drop; | |||||
idp = mtod(con->rx_pkt, uint16_t *); | |||||
*idp = idtype; | |||||
NG_SEND_DATA_ONLY(error, l2cap->l2c, con->rx_pkt); | NG_SEND_DATA_ONLY(error, l2cap->l2c, con->rx_pkt); | ||||
con->rx_pkt = NULL; | con->rx_pkt = NULL; | ||||
drop: | drop: | ||||
NG_FREE_M(con->rx_pkt); /* checks for != NULL */ | NG_FREE_M(con->rx_pkt); /* checks for != NULL */ | ||||
return (error); | return (error); | ||||
} /* ng_l2cap_receive */ | } /* ng_l2cap_receive */ | ||||
▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | "%s: %s - invalid L2CA_Disconnect request message size, size=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), | __func__, NG_NODE_NAME(l2cap->node), | ||||
msg->header.arglen); | msg->header.arglen); | ||||
error = EMSGSIZE; | error = EMSGSIZE; | ||||
goto out; | goto out; | ||||
} | } | ||||
ip = (ng_l2cap_l2ca_discon_ip *)(msg->data); | ip = (ng_l2cap_l2ca_discon_ip *)(msg->data); | ||||
if(ip->idtype == NG_L2CAP_L2CA_IDTYPE_ATT){ | |||||
/* Don't send Disconnect request on L2CAP Layer*/ | |||||
ch = ng_l2cap_chan_by_conhandle(l2cap, NG_L2CAP_ATT_CID, | |||||
ip->lcid); | |||||
if(ch != NULL){ | |||||
ng_l2cap_free_chan(ch); | |||||
}else{ | |||||
NG_L2CAP_ERR( | |||||
"%s: %s - unexpected L2CA_Disconnect request message. " \ | |||||
"Channel does not exist, conhandle=%d\n", | |||||
__func__, NG_NODE_NAME(l2cap->node), ip->lcid); | |||||
error = EINVAL; | |||||
} | |||||
goto out; | |||||
}else{ | |||||
/* Check if we have this channel */ | /* Check if we have this channel */ | ||||
ch = ng_l2cap_chan_by_scid(l2cap, ip->lcid); | ch = ng_l2cap_chan_by_scid(l2cap, ip->lcid, ip->idtype); | ||||
} | |||||
if (ch == NULL) { | if (ch == NULL) { | ||||
NG_L2CAP_ERR( | NG_L2CAP_ERR( | ||||
"%s: %s - unexpected L2CA_Disconnect request message. " \ | "%s: %s - unexpected L2CA_Disconnect request message. " \ | ||||
"Channel does not exist, lcid=%d\n", | "Channel does not exist, lcid=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), ip->lcid); | __func__, NG_NODE_NAME(l2cap->node), ip->lcid); | ||||
error = ENOENT; | error = ENOENT; | ||||
goto out; | goto out; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | if (ip->echo_size > NG_L2CAP_MAX_ECHO_SIZE) { | ||||
NG_L2CAP_WARN( | NG_L2CAP_WARN( | ||||
"%s: %s - invalid L2CA_Ping request. Echo size is too big, echo_size=%d\n", | "%s: %s - invalid L2CA_Ping request. Echo size is too big, echo_size=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), ip->echo_size); | __func__, NG_NODE_NAME(l2cap->node), ip->echo_size); | ||||
error = EMSGSIZE; | error = EMSGSIZE; | ||||
goto out; | goto out; | ||||
} | } | ||||
/* Check if we have connection to the unit */ | /* Check if we have connection to the unit */ | ||||
con = ng_l2cap_con_by_addr(l2cap, &ip->bdaddr); | con = ng_l2cap_con_by_addr(l2cap, &ip->bdaddr, NG_HCI_LINK_ACL); | ||||
if (con == NULL) { | if (con == NULL) { | ||||
/* Submit LP_ConnectReq to the lower layer */ | /* Submit LP_ConnectReq to the lower layer */ | ||||
error = ng_l2cap_lp_con_req(l2cap, &ip->bdaddr); | error = ng_l2cap_lp_con_req(l2cap, &ip->bdaddr, NG_HCI_LINK_ACL); | ||||
if (error != 0) { | if (error != 0) { | ||||
NG_L2CAP_ERR( | NG_L2CAP_ERR( | ||||
"%s: %s - unable to send LP_ConnectReq message, error=%d\n", | "%s: %s - unable to send LP_ConnectReq message, error=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), error); | __func__, NG_NODE_NAME(l2cap->node), error); | ||||
goto out; | goto out; | ||||
} | } | ||||
/* This should not fail */ | /* This should not fail */ | ||||
con = ng_l2cap_con_by_addr(l2cap, &ip->bdaddr); | con = ng_l2cap_con_by_addr(l2cap, &ip->bdaddr, NG_HCI_LINK_ACL); | ||||
KASSERT((con != NULL), | KASSERT((con != NULL), | ||||
("%s: %s - could not find connection!\n", __func__, NG_NODE_NAME(l2cap->node))); | ("%s: %s - could not find connection!\n", __func__, NG_NODE_NAME(l2cap->node))); | ||||
} | } | ||||
/* Create L2CAP command descriptor */ | /* Create L2CAP command descriptor */ | ||||
cmd = ng_l2cap_new_cmd(con, NULL, ng_l2cap_get_ident(con), | cmd = ng_l2cap_new_cmd(con, NULL, ng_l2cap_get_ident(con), | ||||
NG_L2CAP_ECHO_REQ, msg->header.token); | NG_L2CAP_ECHO_REQ, msg->header.token); | ||||
if (cmd == NULL) { | if (cmd == NULL) { | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | "%s: %s - invalid L2CA_GetInfo request message size, size=%d\n", | ||||
msg->header.arglen); | msg->header.arglen); | ||||
error = EMSGSIZE; | error = EMSGSIZE; | ||||
goto out; | goto out; | ||||
} | } | ||||
ip = (ng_l2cap_l2ca_get_info_ip *)(msg->data); | ip = (ng_l2cap_l2ca_get_info_ip *)(msg->data); | ||||
/* Check if we have connection to the unit */ | /* Check if we have connection to the unit */ | ||||
con = ng_l2cap_con_by_addr(l2cap, &ip->bdaddr); | con = ng_l2cap_con_by_addr(l2cap, &ip->bdaddr,ip->linktype); | ||||
if (con == NULL) { | if (con == NULL) { | ||||
/* Submit LP_ConnectReq to the lower layer */ | /* Submit LP_ConnectReq to the lower layer */ | ||||
error = ng_l2cap_lp_con_req(l2cap, &ip->bdaddr); | error = ng_l2cap_lp_con_req(l2cap, &ip->bdaddr,ip->linktype); | ||||
if (error != 0) { | if (error != 0) { | ||||
NG_L2CAP_ERR( | NG_L2CAP_ERR( | ||||
"%s: %s - unable to send LP_ConnectReq message, error=%d\n", | "%s: %s - unable to send LP_ConnectReq message, error=%d\n", | ||||
__func__, NG_NODE_NAME(l2cap->node), error); | __func__, NG_NODE_NAME(l2cap->node), error); | ||||
goto out; | goto out; | ||||
} | } | ||||
/* This should not fail */ | /* This should not fail */ | ||||
con = ng_l2cap_con_by_addr(l2cap, &ip->bdaddr); | con = ng_l2cap_con_by_addr(l2cap, &ip->bdaddr, ip->linktype); | ||||
KASSERT((con != NULL), | KASSERT((con != NULL), | ||||
("%s: %s - could not find connection!\n", __func__, NG_NODE_NAME(l2cap->node))); | ("%s: %s - could not find connection!\n", __func__, NG_NODE_NAME(l2cap->node))); | ||||
} | } | ||||
/* Create L2CAP command descriptor */ | /* Create L2CAP command descriptor */ | ||||
cmd = ng_l2cap_new_cmd(con, NULL, ng_l2cap_get_ident(con), | cmd = ng_l2cap_new_cmd(con, NULL, ng_l2cap_get_ident(con), | ||||
NG_L2CAP_INFO_REQ, msg->header.token); | NG_L2CAP_INFO_REQ, msg->header.token); | ||||
if (cmd == NULL) { | if (cmd == NULL) { | ||||
▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines |
i'm confused here. this is request path, but _ng_l2cap_con_rsp (response) is used. can you please explain if this something from the spec ?