diff options
| author | Rémi Denis-Courmont <remi.denis-courmont@nokia.com> | 2011-02-24 18:14:58 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2011-02-25 14:19:35 -0500 |
| commit | 14ba8faebcc241e4d60a4ef4a7d3fdef1c2e846f (patch) | |
| tree | 2edbe7e3de2ee732cc252b9107a76298249a9098 | |
| parent | a8059512b120362b15424f152b2548fe8b11bd0c (diff) | |
Phonet: use socket destination in pipe protocol
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | include/net/phonet/pep.h | 1 | ||||
| -rw-r--r-- | net/phonet/pep.c | 41 |
2 files changed, 16 insertions, 26 deletions
diff --git a/include/net/phonet/pep.h b/include/net/phonet/pep.h index b60b28c99e87..788ccf353582 100644 --- a/include/net/phonet/pep.h +++ b/include/net/phonet/pep.h | |||
| @@ -47,7 +47,6 @@ struct pep_sock { | |||
| 47 | u8 aligned; | 47 | u8 aligned; |
| 48 | #ifdef CONFIG_PHONET_PIPECTRLR | 48 | #ifdef CONFIG_PHONET_PIPECTRLR |
| 49 | u8 pipe_state; | 49 | u8 pipe_state; |
| 50 | struct sockaddr_pn remote_pep; | ||
| 51 | #endif | 50 | #endif |
| 52 | }; | 51 | }; |
| 53 | 52 | ||
diff --git a/net/phonet/pep.c b/net/phonet/pep.c index 3e60f2e4e6c2..4fce882d001a 100644 --- a/net/phonet/pep.c +++ b/net/phonet/pep.c | |||
| @@ -50,11 +50,6 @@ | |||
| 50 | #define CREDITS_MAX 10 | 50 | #define CREDITS_MAX 10 |
| 51 | #define CREDITS_THR 7 | 51 | #define CREDITS_THR 7 |
| 52 | 52 | ||
| 53 | static const struct sockaddr_pn pipe_srv = { | ||
| 54 | .spn_family = AF_PHONET, | ||
| 55 | .spn_resource = 0xD9, /* pipe service */ | ||
| 56 | }; | ||
| 57 | |||
| 58 | #define pep_sb_size(s) (((s) + 5) & ~3) /* 2-bytes head, 32-bits aligned */ | 53 | #define pep_sb_size(s) (((s) + 5) & ~3) /* 2-bytes head, 32-bits aligned */ |
| 59 | 54 | ||
| 60 | /* Get the next TLV sub-block. */ | 55 | /* Get the next TLV sub-block. */ |
| @@ -88,6 +83,7 @@ static int pep_reply(struct sock *sk, struct sk_buff *oskb, | |||
| 88 | const struct pnpipehdr *oph = pnp_hdr(oskb); | 83 | const struct pnpipehdr *oph = pnp_hdr(oskb); |
| 89 | struct pnpipehdr *ph; | 84 | struct pnpipehdr *ph; |
| 90 | struct sk_buff *skb; | 85 | struct sk_buff *skb; |
| 86 | struct sockaddr_pn peer; | ||
| 91 | 87 | ||
| 92 | skb = alloc_skb(MAX_PNPIPE_HEADER + len, priority); | 88 | skb = alloc_skb(MAX_PNPIPE_HEADER + len, priority); |
| 93 | if (!skb) | 89 | if (!skb) |
| @@ -105,7 +101,8 @@ static int pep_reply(struct sock *sk, struct sk_buff *oskb, | |||
| 105 | ph->pipe_handle = oph->pipe_handle; | 101 | ph->pipe_handle = oph->pipe_handle; |
| 106 | ph->error_code = code; | 102 | ph->error_code = code; |
| 107 | 103 | ||
| 108 | return pn_skb_send(sk, skb, &pipe_srv); | 104 | pn_skb_get_src_sockaddr(oskb, &peer); |
| 105 | return pn_skb_send(sk, skb, &peer); | ||
| 109 | } | 106 | } |
| 110 | 107 | ||
| 111 | #define PAD 0x00 | 108 | #define PAD 0x00 |
| @@ -220,7 +217,7 @@ static int pipe_handler_send_req(struct sock *sk, u8 utid, | |||
| 220 | ph->pipe_handle = pn->pipe_handle; | 217 | ph->pipe_handle = pn->pipe_handle; |
| 221 | ph->error_code = PN_PIPE_NO_ERROR; | 218 | ph->error_code = PN_PIPE_NO_ERROR; |
| 222 | 219 | ||
| 223 | return pn_skb_send(sk, skb, &pn->remote_pep); | 220 | return pn_skb_send(sk, skb, NULL); |
| 224 | } | 221 | } |
| 225 | 222 | ||
| 226 | static int pipe_handler_send_created_ind(struct sock *sk, | 223 | static int pipe_handler_send_created_ind(struct sock *sk, |
| @@ -262,7 +259,7 @@ static int pipe_handler_send_created_ind(struct sock *sk, | |||
| 262 | ph->pipe_handle = pn->pipe_handle; | 259 | ph->pipe_handle = pn->pipe_handle; |
| 263 | ph->error_code = err_code; | 260 | ph->error_code = err_code; |
| 264 | 261 | ||
| 265 | return pn_skb_send(sk, skb, &pn->remote_pep); | 262 | return pn_skb_send(sk, skb, NULL); |
| 266 | } | 263 | } |
| 267 | 264 | ||
| 268 | static int pipe_handler_send_ind(struct sock *sk, u8 utid, u8 msg_id) | 265 | static int pipe_handler_send_ind(struct sock *sk, u8 utid, u8 msg_id) |
| @@ -295,7 +292,7 @@ static int pipe_handler_send_ind(struct sock *sk, u8 utid, u8 msg_id) | |||
| 295 | ph->pipe_handle = pn->pipe_handle; | 292 | ph->pipe_handle = pn->pipe_handle; |
| 296 | ph->error_code = err_code; | 293 | ph->error_code = err_code; |
| 297 | 294 | ||
| 298 | return pn_skb_send(sk, skb, &pn->remote_pep); | 295 | return pn_skb_send(sk, skb, NULL); |
| 299 | } | 296 | } |
| 300 | 297 | ||
| 301 | static int pipe_handler_enable_pipe(struct sock *sk, int enable) | 298 | static int pipe_handler_enable_pipe(struct sock *sk, int enable) |
| @@ -396,11 +393,7 @@ static int pipe_snd_status(struct sock *sk, u8 type, u8 status, gfp_t priority) | |||
| 396 | ph->data[3] = PAD; | 393 | ph->data[3] = PAD; |
| 397 | ph->data[4] = status; | 394 | ph->data[4] = status; |
| 398 | 395 | ||
| 399 | #ifdef CONFIG_PHONET_PIPECTRLR | 396 | return pn_skb_send(sk, skb, NULL); |
| 400 | return pn_skb_send(sk, skb, &pn->remote_pep); | ||
| 401 | #else | ||
| 402 | return pn_skb_send(sk, skb, &pipe_srv); | ||
| 403 | #endif | ||
| 404 | } | 397 | } |
| 405 | 398 | ||
| 406 | /* Send our RX flow control information to the sender. | 399 | /* Send our RX flow control information to the sender. |
| @@ -722,7 +715,7 @@ static int pep_connreq_rcv(struct sock *sk, struct sk_buff *skb) | |||
| 722 | struct sock *newsk; | 715 | struct sock *newsk; |
| 723 | struct pep_sock *newpn, *pn = pep_sk(sk); | 716 | struct pep_sock *newpn, *pn = pep_sk(sk); |
| 724 | struct pnpipehdr *hdr; | 717 | struct pnpipehdr *hdr; |
| 725 | struct sockaddr_pn dst; | 718 | struct sockaddr_pn dst, src; |
| 726 | u16 peer_type; | 719 | u16 peer_type; |
| 727 | u8 pipe_handle, enabled, n_sb; | 720 | u8 pipe_handle, enabled, n_sb; |
| 728 | u8 aligned = 0; | 721 | u8 aligned = 0; |
| @@ -789,8 +782,10 @@ static int pep_connreq_rcv(struct sock *sk, struct sk_buff *skb) | |||
| 789 | 782 | ||
| 790 | newpn = pep_sk(newsk); | 783 | newpn = pep_sk(newsk); |
| 791 | pn_skb_get_dst_sockaddr(skb, &dst); | 784 | pn_skb_get_dst_sockaddr(skb, &dst); |
| 785 | pn_skb_get_src_sockaddr(skb, &src); | ||
| 792 | newpn->pn_sk.sobject = pn_sockaddr_get_object(&dst); | 786 | newpn->pn_sk.sobject = pn_sockaddr_get_object(&dst); |
| 793 | newpn->pn_sk.resource = pn->pn_sk.resource; | 787 | newpn->pn_sk.dobject = pn_sockaddr_get_object(&src); |
| 788 | newpn->pn_sk.resource = pn_sockaddr_get_resource(&dst); | ||
| 794 | skb_queue_head_init(&newpn->ctrlreq_queue); | 789 | skb_queue_head_init(&newpn->ctrlreq_queue); |
| 795 | newpn->pipe_handle = pipe_handle; | 790 | newpn->pipe_handle = pipe_handle; |
| 796 | atomic_set(&newpn->tx_credits, 0); | 791 | atomic_set(&newpn->tx_credits, 0); |
| @@ -925,7 +920,7 @@ static int pipe_do_remove(struct sock *sk) | |||
| 925 | ph->pipe_handle = pn->pipe_handle; | 920 | ph->pipe_handle = pn->pipe_handle; |
| 926 | ph->data[0] = PAD; | 921 | ph->data[0] = PAD; |
| 927 | 922 | ||
| 928 | return pn_skb_send(sk, skb, &pipe_srv); | 923 | return pn_skb_send(sk, skb, NULL); |
| 929 | } | 924 | } |
| 930 | 925 | ||
| 931 | /* associated socket ceases to exist */ | 926 | /* associated socket ceases to exist */ |
| @@ -1042,10 +1037,10 @@ out: | |||
| 1042 | static int pep_sock_connect(struct sock *sk, struct sockaddr *addr, int len) | 1037 | static int pep_sock_connect(struct sock *sk, struct sockaddr *addr, int len) |
| 1043 | { | 1038 | { |
| 1044 | struct pep_sock *pn = pep_sk(sk); | 1039 | struct pep_sock *pn = pep_sk(sk); |
| 1045 | struct sockaddr_pn *spn = (struct sockaddr_pn *)addr; | 1040 | const struct sockaddr_pn *spn = (struct sockaddr_pn *)addr; |
| 1046 | |||
| 1047 | memcpy(&pn->remote_pep, spn, sizeof(struct sockaddr_pn)); | ||
| 1048 | 1041 | ||
| 1042 | pn->pn_sk.dobject = pn_sockaddr_get_object(spn); | ||
| 1043 | pn->pn_sk.resource = pn_sockaddr_get_resource(spn); | ||
| 1049 | return pipe_handler_send_req(sk, | 1044 | return pipe_handler_send_req(sk, |
| 1050 | PNS_PEP_CONNECT_UTID, PNS_PEP_CONNECT_REQ, | 1045 | PNS_PEP_CONNECT_UTID, PNS_PEP_CONNECT_REQ, |
| 1051 | GFP_ATOMIC); | 1046 | GFP_ATOMIC); |
| @@ -1222,11 +1217,7 @@ static int pipe_skb_send(struct sock *sk, struct sk_buff *skb) | |||
| 1222 | } else | 1217 | } else |
| 1223 | ph->message_id = PNS_PIPE_DATA; | 1218 | ph->message_id = PNS_PIPE_DATA; |
| 1224 | ph->pipe_handle = pn->pipe_handle; | 1219 | ph->pipe_handle = pn->pipe_handle; |
| 1225 | #ifdef CONFIG_PHONET_PIPECTRLR | 1220 | err = pn_skb_send(sk, skb, NULL); |
| 1226 | err = pn_skb_send(sk, skb, &pn->remote_pep); | ||
| 1227 | #else | ||
| 1228 | err = pn_skb_send(sk, skb, &pipe_srv); | ||
| 1229 | #endif | ||
| 1230 | 1221 | ||
| 1231 | if (err && pn_flow_safe(pn->tx_fc)) | 1222 | if (err && pn_flow_safe(pn->tx_fc)) |
| 1232 | atomic_inc(&pn->tx_credits); | 1223 | atomic_inc(&pn->tx_credits); |
