Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 63397
b: refs/heads/master
c: 8e036fc
h: refs/heads/master
i:
  63395: 2b97daf
v: v3
  • Loading branch information
Al Viro authored and David S. Miller committed Jul 31, 2007
1 parent c22228b commit bf1ed5c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6dc0c2082b8acf30c9239fbbcc051eebdaf7ecff
refs/heads/master: 8e036fc3143646dc304356fa50314681d654363f
50 changes: 25 additions & 25 deletions trunk/include/net/bluetooth/l2cap.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/* L2CAP socket address */
struct sockaddr_l2 {
sa_family_t l2_family;
unsigned short l2_psm;
__le16 l2_psm;
bdaddr_t l2_bdaddr;
};

Expand Down Expand Up @@ -76,32 +76,32 @@ struct l2cap_conninfo {

/* L2CAP structures */
struct l2cap_hdr {
__u16 len;
__u16 cid;
__le16 len;
__le16 cid;
} __attribute__ ((packed));
#define L2CAP_HDR_SIZE 4

struct l2cap_cmd_hdr {
__u8 code;
__u8 ident;
__u16 len;
__le16 len;
} __attribute__ ((packed));
#define L2CAP_CMD_HDR_SIZE 4

struct l2cap_cmd_rej {
__u16 reason;
__le16 reason;
} __attribute__ ((packed));

struct l2cap_conn_req {
__u16 psm;
__u16 scid;
__le16 psm;
__le16 scid;
} __attribute__ ((packed));

struct l2cap_conn_rsp {
__u16 dcid;
__u16 scid;
__u16 result;
__u16 status;
__le16 dcid;
__le16 scid;
__le16 result;
__le16 status;
} __attribute__ ((packed));

/* connect result */
Expand All @@ -117,15 +117,15 @@ struct l2cap_conn_rsp {
#define L2CAP_CS_AUTHOR_PEND 0x0002

struct l2cap_conf_req {
__u16 dcid;
__u16 flags;
__le16 dcid;
__le16 flags;
__u8 data[0];
} __attribute__ ((packed));

struct l2cap_conf_rsp {
__u16 scid;
__u16 flags;
__u16 result;
__le16 scid;
__le16 flags;
__le16 result;
__u8 data[0];
} __attribute__ ((packed));

Expand All @@ -149,23 +149,23 @@ struct l2cap_conf_opt {
#define L2CAP_CONF_MAX_SIZE 22

struct l2cap_disconn_req {
__u16 dcid;
__u16 scid;
__le16 dcid;
__le16 scid;
} __attribute__ ((packed));

struct l2cap_disconn_rsp {
__u16 dcid;
__u16 scid;
__le16 dcid;
__le16 scid;
} __attribute__ ((packed));

struct l2cap_info_req {
__u16 type;
__le16 type;
__u8 data[0];
} __attribute__ ((packed));

struct l2cap_info_rsp {
__u16 type;
__u16 result;
__le16 type;
__le16 result;
__u8 data[0];
} __attribute__ ((packed));

Expand Down Expand Up @@ -207,7 +207,7 @@ struct l2cap_conn {

struct l2cap_pinfo {
struct bt_sock bt;
__u16 psm;
__le16 psm;
__u16 dcid;
__u16 scid;

Expand All @@ -225,7 +225,7 @@ struct l2cap_pinfo {

__u8 ident;

__u16 sport;
__le16 sport;

struct l2cap_conn *conn;
struct sock *next_c;
Expand Down
27 changes: 14 additions & 13 deletions trunk/net/bluetooth/l2cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static inline int l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16
}

/* ---- Socket interface ---- */
static struct sock *__l2cap_get_sock_by_addr(u16 psm, bdaddr_t *src)
static struct sock *__l2cap_get_sock_by_addr(__le16 psm, bdaddr_t *src)
{
struct sock *sk;
struct hlist_node *node;
Expand All @@ -368,7 +368,7 @@ static struct sock *__l2cap_get_sock_by_addr(u16 psm, bdaddr_t *src)
/* Find socket with psm and source bdaddr.
* Returns closest match.
*/
static struct sock *__l2cap_get_sock_by_psm(int state, u16 psm, bdaddr_t *src)
static struct sock *__l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t *src)
{
struct sock *sk = NULL, *sk1 = NULL;
struct hlist_node *node;
Expand All @@ -392,7 +392,7 @@ static struct sock *__l2cap_get_sock_by_psm(int state, u16 psm, bdaddr_t *src)

/* Find socket with given address (psm, src).
* Returns locked socket */
static inline struct sock *l2cap_get_sock_by_psm(int state, u16 psm, bdaddr_t *src)
static inline struct sock *l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t *src)
{
struct sock *s;
read_lock(&l2cap_sk_list.lock);
Expand Down Expand Up @@ -586,7 +586,7 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_
goto done;
}

if (la->l2_psm > 0 && btohs(la->l2_psm) < 0x1001 &&
if (la->l2_psm && btohs(la->l2_psm) < 0x1001 &&
!capable(CAP_NET_BIND_SERVICE)) {
err = -EACCES;
goto done;
Expand Down Expand Up @@ -873,7 +873,7 @@ static inline int l2cap_do_send(struct sock *sk, struct msghdr *msg, int len)
lh->len = cpu_to_le16(len + (hlen - L2CAP_HDR_SIZE));

if (sk->sk_type == SOCK_DGRAM)
put_unaligned(l2cap_pi(sk)->psm, (u16 *) skb_put(skb, 2));
put_unaligned(l2cap_pi(sk)->psm, (__le16 *) skb_put(skb, 2));

if (memcpy_fromiovec(skb_put(skb, count), msg->msg_iov, count)) {
err = -EFAULT;
Expand Down Expand Up @@ -1256,11 +1256,11 @@ static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, unsigned
break;

case 2:
*val = __le16_to_cpu(*((u16 *)opt->val));
*val = __le16_to_cpu(*((__le16 *)opt->val));
break;

case 4:
*val = __le32_to_cpu(*((u32 *)opt->val));
*val = __le32_to_cpu(*((__le32 *)opt->val));
break;

default:
Expand All @@ -1287,11 +1287,11 @@ static void l2cap_add_conf_opt(void **ptr, u8 type, u8 len, unsigned long val)
break;

case 2:
*((u16 *) opt->val) = cpu_to_le16(val);
*((__le16 *) opt->val) = cpu_to_le16(val);
break;

case 4:
*((u32 *) opt->val) = cpu_to_le32(val);
*((__le32 *) opt->val) = cpu_to_le32(val);
break;

default:
Expand Down Expand Up @@ -1406,7 +1406,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
int result = 0, status = 0;

u16 dcid = 0, scid = __le16_to_cpu(req->scid);
u16 psm = req->psm;
__le16 psm = req->psm;

BT_DBG("psm 0x%2.2x scid 0x%4.4x", psm, scid);

Expand Down Expand Up @@ -1863,7 +1863,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk
return 0;
}

static inline int l2cap_conless_channel(struct l2cap_conn *conn, u16 psm, struct sk_buff *skb)
static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, struct sk_buff *skb)
{
struct sock *sk;

Expand Down Expand Up @@ -1893,7 +1893,8 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, u16 psm, struct
static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb)
{
struct l2cap_hdr *lh = (void *) skb->data;
u16 cid, psm, len;
u16 cid, len;
__le16 psm;

skb_pull(skb, L2CAP_HDR_SIZE);
cid = __le16_to_cpu(lh->cid);
Expand All @@ -1907,7 +1908,7 @@ static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb)
break;

case 0x0002:
psm = get_unaligned((u16 *) skb->data);
psm = get_unaligned((__le16 *) skb->data);
skb_pull(skb, 2);
l2cap_conless_channel(conn, psm, skb);
break;
Expand Down

0 comments on commit bf1ed5c

Please sign in to comment.