aboutsummaryrefslogtreecommitdiffstats
path: root/net/phonet
diff options
context:
space:
mode:
authorRémi Denis-Courmont <remi.denis-courmont@nokia.com>2011-02-24 18:14:57 -0500
committerDavid S. Miller <davem@davemloft.net>2011-02-25 14:19:35 -0500
commita8059512b120362b15424f152b2548fe8b11bd0c (patch)
tree11ad07ca3fa5b0ad03e1f8f6d8bac804612d0530 /net/phonet
parent96241544ca34721d601925850868188d6304cc0f (diff)
Phonet: implement per-socket destination/peer address
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/phonet')
-rw-r--r--net/phonet/af_phonet.c19
-rw-r--r--net/phonet/socket.c4
2 files changed, 16 insertions, 7 deletions
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
index 1072b2c19d31..30cc676c35fd 100644
--- a/net/phonet/af_phonet.c
+++ b/net/phonet/af_phonet.c
@@ -110,6 +110,7 @@ static int pn_socket_create(struct net *net, struct socket *sock, int protocol,
110 sk->sk_protocol = protocol; 110 sk->sk_protocol = protocol;
111 pn = pn_sk(sk); 111 pn = pn_sk(sk);
112 pn->sobject = 0; 112 pn->sobject = 0;
113 pn->dobject = 0;
113 pn->resource = 0; 114 pn->resource = 0;
114 sk->sk_prot->init(sk); 115 sk->sk_prot->init(sk);
115 err = 0; 116 err = 0;
@@ -242,8 +243,18 @@ int pn_skb_send(struct sock *sk, struct sk_buff *skb,
242 struct net_device *dev; 243 struct net_device *dev;
243 struct pn_sock *pn = pn_sk(sk); 244 struct pn_sock *pn = pn_sk(sk);
244 int err; 245 int err;
245 u16 src; 246 u16 src, dst;
246 u8 daddr = pn_sockaddr_get_addr(target), saddr = PN_NO_ADDR; 247 u8 daddr, saddr, res;
248
249 src = pn->sobject;
250 if (target != NULL) {
251 dst = pn_sockaddr_get_object(target);
252 res = pn_sockaddr_get_resource(target);
253 } else {
254 dst = pn->dobject;
255 res = pn->resource;
256 }
257 daddr = pn_addr(dst);
247 258
248 err = -EHOSTUNREACH; 259 err = -EHOSTUNREACH;
249 if (sk->sk_bound_dev_if) 260 if (sk->sk_bound_dev_if)
@@ -271,12 +282,10 @@ int pn_skb_send(struct sock *sk, struct sk_buff *skb,
271 if (saddr == PN_NO_ADDR) 282 if (saddr == PN_NO_ADDR)
272 goto drop; 283 goto drop;
273 284
274 src = pn->sobject;
275 if (!pn_addr(src)) 285 if (!pn_addr(src))
276 src = pn_object(saddr, pn_obj(src)); 286 src = pn_object(saddr, pn_obj(src));
277 287
278 err = pn_send(skb, dev, pn_sockaddr_get_object(target), 288 err = pn_send(skb, dev, dst, src, res, 0);
279 src, pn_sockaddr_get_resource(target), 0);
280 dev_put(dev); 289 dev_put(dev);
281 return err; 290 return err;
282 291
diff --git a/net/phonet/socket.c b/net/phonet/socket.c
index ceb5143f5ef9..65a03338769e 100644
--- a/net/phonet/socket.c
+++ b/net/phonet/socket.c
@@ -633,8 +633,8 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
633 633
634 seq_printf(seq, "%2d %04X:%04X:%02X %02X %08X:%08X %5d %lu " 634 seq_printf(seq, "%2d %04X:%04X:%02X %02X %08X:%08X %5d %lu "
635 "%d %p %d%n", 635 "%d %p %d%n",
636 sk->sk_protocol, pn->sobject, 0, pn->resource, 636 sk->sk_protocol, pn->sobject, pn->dobject,
637 sk->sk_state, 637 pn->resource, sk->sk_state,
638 sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk), 638 sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk),
639 sock_i_uid(sk), sock_i_ino(sk), 639 sock_i_uid(sk), sock_i_ino(sk),
640 atomic_read(&sk->sk_refcnt), sk, 640 atomic_read(&sk->sk_refcnt), sk,