diff options
-rw-r--r-- | include/net/bluetooth/l2cap.h | 50 | ||||
-rw-r--r-- | net/bluetooth/l2cap.c | 27 |
2 files changed, 39 insertions, 38 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 87df4e87622d..70e70f5d3dd6 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -34,7 +34,7 @@ | |||
34 | /* L2CAP socket address */ | 34 | /* L2CAP socket address */ |
35 | struct sockaddr_l2 { | 35 | struct sockaddr_l2 { |
36 | sa_family_t l2_family; | 36 | sa_family_t l2_family; |
37 | unsigned short l2_psm; | 37 | __le16 l2_psm; |
38 | bdaddr_t l2_bdaddr; | 38 | bdaddr_t l2_bdaddr; |
39 | }; | 39 | }; |
40 | 40 | ||
@@ -76,32 +76,32 @@ struct l2cap_conninfo { | |||
76 | 76 | ||
77 | /* L2CAP structures */ | 77 | /* L2CAP structures */ |
78 | struct l2cap_hdr { | 78 | struct l2cap_hdr { |
79 | __u16 len; | 79 | __le16 len; |
80 | __u16 cid; | 80 | __le16 cid; |
81 | } __attribute__ ((packed)); | 81 | } __attribute__ ((packed)); |
82 | #define L2CAP_HDR_SIZE 4 | 82 | #define L2CAP_HDR_SIZE 4 |
83 | 83 | ||
84 | struct l2cap_cmd_hdr { | 84 | struct l2cap_cmd_hdr { |
85 | __u8 code; | 85 | __u8 code; |
86 | __u8 ident; | 86 | __u8 ident; |
87 | __u16 len; | 87 | __le16 len; |
88 | } __attribute__ ((packed)); | 88 | } __attribute__ ((packed)); |
89 | #define L2CAP_CMD_HDR_SIZE 4 | 89 | #define L2CAP_CMD_HDR_SIZE 4 |
90 | 90 | ||
91 | struct l2cap_cmd_rej { | 91 | struct l2cap_cmd_rej { |
92 | __u16 reason; | 92 | __le16 reason; |
93 | } __attribute__ ((packed)); | 93 | } __attribute__ ((packed)); |
94 | 94 | ||
95 | struct l2cap_conn_req { | 95 | struct l2cap_conn_req { |
96 | __u16 psm; | 96 | __le16 psm; |
97 | __u16 scid; | 97 | __le16 scid; |
98 | } __attribute__ ((packed)); | 98 | } __attribute__ ((packed)); |
99 | 99 | ||
100 | struct l2cap_conn_rsp { | 100 | struct l2cap_conn_rsp { |
101 | __u16 dcid; | 101 | __le16 dcid; |
102 | __u16 scid; | 102 | __le16 scid; |
103 | __u16 result; | 103 | __le16 result; |
104 | __u16 status; | 104 | __le16 status; |
105 | } __attribute__ ((packed)); | 105 | } __attribute__ ((packed)); |
106 | 106 | ||
107 | /* connect result */ | 107 | /* connect result */ |
@@ -117,15 +117,15 @@ struct l2cap_conn_rsp { | |||
117 | #define L2CAP_CS_AUTHOR_PEND 0x0002 | 117 | #define L2CAP_CS_AUTHOR_PEND 0x0002 |
118 | 118 | ||
119 | struct l2cap_conf_req { | 119 | struct l2cap_conf_req { |
120 | __u16 dcid; | 120 | __le16 dcid; |
121 | __u16 flags; | 121 | __le16 flags; |
122 | __u8 data[0]; | 122 | __u8 data[0]; |
123 | } __attribute__ ((packed)); | 123 | } __attribute__ ((packed)); |
124 | 124 | ||
125 | struct l2cap_conf_rsp { | 125 | struct l2cap_conf_rsp { |
126 | __u16 scid; | 126 | __le16 scid; |
127 | __u16 flags; | 127 | __le16 flags; |
128 | __u16 result; | 128 | __le16 result; |
129 | __u8 data[0]; | 129 | __u8 data[0]; |
130 | } __attribute__ ((packed)); | 130 | } __attribute__ ((packed)); |
131 | 131 | ||
@@ -149,23 +149,23 @@ struct l2cap_conf_opt { | |||
149 | #define L2CAP_CONF_MAX_SIZE 22 | 149 | #define L2CAP_CONF_MAX_SIZE 22 |
150 | 150 | ||
151 | struct l2cap_disconn_req { | 151 | struct l2cap_disconn_req { |
152 | __u16 dcid; | 152 | __le16 dcid; |
153 | __u16 scid; | 153 | __le16 scid; |
154 | } __attribute__ ((packed)); | 154 | } __attribute__ ((packed)); |
155 | 155 | ||
156 | struct l2cap_disconn_rsp { | 156 | struct l2cap_disconn_rsp { |
157 | __u16 dcid; | 157 | __le16 dcid; |
158 | __u16 scid; | 158 | __le16 scid; |
159 | } __attribute__ ((packed)); | 159 | } __attribute__ ((packed)); |
160 | 160 | ||
161 | struct l2cap_info_req { | 161 | struct l2cap_info_req { |
162 | __u16 type; | 162 | __le16 type; |
163 | __u8 data[0]; | 163 | __u8 data[0]; |
164 | } __attribute__ ((packed)); | 164 | } __attribute__ ((packed)); |
165 | 165 | ||
166 | struct l2cap_info_rsp { | 166 | struct l2cap_info_rsp { |
167 | __u16 type; | 167 | __le16 type; |
168 | __u16 result; | 168 | __le16 result; |
169 | __u8 data[0]; | 169 | __u8 data[0]; |
170 | } __attribute__ ((packed)); | 170 | } __attribute__ ((packed)); |
171 | 171 | ||
@@ -207,7 +207,7 @@ struct l2cap_conn { | |||
207 | 207 | ||
208 | struct l2cap_pinfo { | 208 | struct l2cap_pinfo { |
209 | struct bt_sock bt; | 209 | struct bt_sock bt; |
210 | __u16 psm; | 210 | __le16 psm; |
211 | __u16 dcid; | 211 | __u16 dcid; |
212 | __u16 scid; | 212 | __u16 scid; |
213 | 213 | ||
@@ -225,7 +225,7 @@ struct l2cap_pinfo { | |||
225 | 225 | ||
226 | __u8 ident; | 226 | __u8 ident; |
227 | 227 | ||
228 | __u16 sport; | 228 | __le16 sport; |
229 | 229 | ||
230 | struct l2cap_conn *conn; | 230 | struct l2cap_conn *conn; |
231 | struct sock *next_c; | 231 | struct sock *next_c; |
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index b82cbdd1fcb1..09126bf06840 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
@@ -353,7 +353,7 @@ static inline int l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 | |||
353 | } | 353 | } |
354 | 354 | ||
355 | /* ---- Socket interface ---- */ | 355 | /* ---- Socket interface ---- */ |
356 | static struct sock *__l2cap_get_sock_by_addr(u16 psm, bdaddr_t *src) | 356 | static struct sock *__l2cap_get_sock_by_addr(__le16 psm, bdaddr_t *src) |
357 | { | 357 | { |
358 | struct sock *sk; | 358 | struct sock *sk; |
359 | struct hlist_node *node; | 359 | struct hlist_node *node; |
@@ -368,7 +368,7 @@ found: | |||
368 | /* Find socket with psm and source bdaddr. | 368 | /* Find socket with psm and source bdaddr. |
369 | * Returns closest match. | 369 | * Returns closest match. |
370 | */ | 370 | */ |
371 | static struct sock *__l2cap_get_sock_by_psm(int state, u16 psm, bdaddr_t *src) | 371 | static struct sock *__l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t *src) |
372 | { | 372 | { |
373 | struct sock *sk = NULL, *sk1 = NULL; | 373 | struct sock *sk = NULL, *sk1 = NULL; |
374 | struct hlist_node *node; | 374 | struct hlist_node *node; |
@@ -392,7 +392,7 @@ static struct sock *__l2cap_get_sock_by_psm(int state, u16 psm, bdaddr_t *src) | |||
392 | 392 | ||
393 | /* Find socket with given address (psm, src). | 393 | /* Find socket with given address (psm, src). |
394 | * Returns locked socket */ | 394 | * Returns locked socket */ |
395 | static inline struct sock *l2cap_get_sock_by_psm(int state, u16 psm, bdaddr_t *src) | 395 | static inline struct sock *l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t *src) |
396 | { | 396 | { |
397 | struct sock *s; | 397 | struct sock *s; |
398 | read_lock(&l2cap_sk_list.lock); | 398 | read_lock(&l2cap_sk_list.lock); |
@@ -586,7 +586,7 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_ | |||
586 | goto done; | 586 | goto done; |
587 | } | 587 | } |
588 | 588 | ||
589 | if (la->l2_psm > 0 && btohs(la->l2_psm) < 0x1001 && | 589 | if (la->l2_psm && btohs(la->l2_psm) < 0x1001 && |
590 | !capable(CAP_NET_BIND_SERVICE)) { | 590 | !capable(CAP_NET_BIND_SERVICE)) { |
591 | err = -EACCES; | 591 | err = -EACCES; |
592 | goto done; | 592 | goto done; |
@@ -873,7 +873,7 @@ static inline int l2cap_do_send(struct sock *sk, struct msghdr *msg, int len) | |||
873 | lh->len = cpu_to_le16(len + (hlen - L2CAP_HDR_SIZE)); | 873 | lh->len = cpu_to_le16(len + (hlen - L2CAP_HDR_SIZE)); |
874 | 874 | ||
875 | if (sk->sk_type == SOCK_DGRAM) | 875 | if (sk->sk_type == SOCK_DGRAM) |
876 | put_unaligned(l2cap_pi(sk)->psm, (u16 *) skb_put(skb, 2)); | 876 | put_unaligned(l2cap_pi(sk)->psm, (__le16 *) skb_put(skb, 2)); |
877 | 877 | ||
878 | if (memcpy_fromiovec(skb_put(skb, count), msg->msg_iov, count)) { | 878 | if (memcpy_fromiovec(skb_put(skb, count), msg->msg_iov, count)) { |
879 | err = -EFAULT; | 879 | err = -EFAULT; |
@@ -1256,11 +1256,11 @@ static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, unsigned | |||
1256 | break; | 1256 | break; |
1257 | 1257 | ||
1258 | case 2: | 1258 | case 2: |
1259 | *val = __le16_to_cpu(*((u16 *)opt->val)); | 1259 | *val = __le16_to_cpu(*((__le16 *)opt->val)); |
1260 | break; | 1260 | break; |
1261 | 1261 | ||
1262 | case 4: | 1262 | case 4: |
1263 | *val = __le32_to_cpu(*((u32 *)opt->val)); | 1263 | *val = __le32_to_cpu(*((__le32 *)opt->val)); |
1264 | break; | 1264 | break; |
1265 | 1265 | ||
1266 | default: | 1266 | default: |
@@ -1287,11 +1287,11 @@ static void l2cap_add_conf_opt(void **ptr, u8 type, u8 len, unsigned long val) | |||
1287 | break; | 1287 | break; |
1288 | 1288 | ||
1289 | case 2: | 1289 | case 2: |
1290 | *((u16 *) opt->val) = cpu_to_le16(val); | 1290 | *((__le16 *) opt->val) = cpu_to_le16(val); |
1291 | break; | 1291 | break; |
1292 | 1292 | ||
1293 | case 4: | 1293 | case 4: |
1294 | *((u32 *) opt->val) = cpu_to_le32(val); | 1294 | *((__le32 *) opt->val) = cpu_to_le32(val); |
1295 | break; | 1295 | break; |
1296 | 1296 | ||
1297 | default: | 1297 | default: |
@@ -1406,7 +1406,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
1406 | int result = 0, status = 0; | 1406 | int result = 0, status = 0; |
1407 | 1407 | ||
1408 | u16 dcid = 0, scid = __le16_to_cpu(req->scid); | 1408 | u16 dcid = 0, scid = __le16_to_cpu(req->scid); |
1409 | u16 psm = req->psm; | 1409 | __le16 psm = req->psm; |
1410 | 1410 | ||
1411 | BT_DBG("psm 0x%2.2x scid 0x%4.4x", psm, scid); | 1411 | BT_DBG("psm 0x%2.2x scid 0x%4.4x", psm, scid); |
1412 | 1412 | ||
@@ -1863,7 +1863,7 @@ done: | |||
1863 | return 0; | 1863 | return 0; |
1864 | } | 1864 | } |
1865 | 1865 | ||
1866 | static inline int l2cap_conless_channel(struct l2cap_conn *conn, u16 psm, struct sk_buff *skb) | 1866 | static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, struct sk_buff *skb) |
1867 | { | 1867 | { |
1868 | struct sock *sk; | 1868 | struct sock *sk; |
1869 | 1869 | ||
@@ -1893,7 +1893,8 @@ done: | |||
1893 | static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb) | 1893 | static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb) |
1894 | { | 1894 | { |
1895 | struct l2cap_hdr *lh = (void *) skb->data; | 1895 | struct l2cap_hdr *lh = (void *) skb->data; |
1896 | u16 cid, psm, len; | 1896 | u16 cid, len; |
1897 | __le16 psm; | ||
1897 | 1898 | ||
1898 | skb_pull(skb, L2CAP_HDR_SIZE); | 1899 | skb_pull(skb, L2CAP_HDR_SIZE); |
1899 | cid = __le16_to_cpu(lh->cid); | 1900 | cid = __le16_to_cpu(lh->cid); |
@@ -1907,7 +1908,7 @@ static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb) | |||
1907 | break; | 1908 | break; |
1908 | 1909 | ||
1909 | case 0x0002: | 1910 | case 0x0002: |
1910 | psm = get_unaligned((u16 *) skb->data); | 1911 | psm = get_unaligned((__le16 *) skb->data); |
1911 | skb_pull(skb, 2); | 1912 | skb_pull(skb, 2); |
1912 | l2cap_conless_channel(conn, psm, skb); | 1913 | l2cap_conless_channel(conn, psm, skb); |
1913 | break; | 1914 | break; |