|
@@ -5294,6 +5294,20 @@ static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static __le16 l2cap_err_to_reason(int err)
|
|
|
+{
|
|
|
+ switch (err) {
|
|
|
+ case -EBADSLT:
|
|
|
+ return __constant_cpu_to_le16(L2CAP_REJ_INVALID_CID);
|
|
|
+ case -EMSGSIZE:
|
|
|
+ return __constant_cpu_to_le16(L2CAP_REJ_MTU_EXCEEDED);
|
|
|
+ case -EINVAL:
|
|
|
+ case -EPROTO:
|
|
|
+ default:
|
|
|
+ return __constant_cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
static inline void l2cap_le_sig_channel(struct l2cap_conn *conn,
|
|
|
struct sk_buff *skb)
|
|
|
{
|
|
@@ -5326,8 +5340,7 @@ static inline void l2cap_le_sig_channel(struct l2cap_conn *conn,
|
|
|
|
|
|
BT_ERR("Wrong link type (%d)", err);
|
|
|
|
|
|
- /* FIXME: Map err to a valid reason */
|
|
|
- rej.reason = __constant_cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD);
|
|
|
+ rej.reason = l2cap_err_to_reason(err);
|
|
|
l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ,
|
|
|
sizeof(rej), &rej);
|
|
|
}
|
|
@@ -5371,8 +5384,7 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
|
|
|
|
|
|
BT_ERR("Wrong link type (%d)", err);
|
|
|
|
|
|
- /* FIXME: Map err to a valid reason */
|
|
|
- rej.reason = __constant_cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD);
|
|
|
+ rej.reason = l2cap_err_to_reason(err);
|
|
|
l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ,
|
|
|
sizeof(rej), &rej);
|
|
|
}
|