4 * Phonet sockets kernel definitions
6 * Copyright (C) 2008 Nokia Corporation.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27 * The lower layers may not require more space, ever. Make sure it's
30 #define MAX_PHONET_HEADER 8
33 * Every Phonet* socket has this structure first in its
34 * protocol-specific structure under name c.
42 static inline struct pn_sock *pn_sk(struct sock *sk)
44 return (struct pn_sock *)sk;
47 extern const struct proto_ops phonet_dgram_ops;
49 struct sock *pn_find_sock_by_sa(const struct sockaddr_pn *sa);
50 void pn_sock_hash(struct sock *sk);
51 void pn_sock_unhash(struct sock *sk);
52 int pn_sock_get_port(struct sock *sk, unsigned short sport);
54 static inline struct phonethdr *pn_hdr(struct sk_buff *skb)
56 return (struct phonethdr *)skb_network_header(skb);
60 * Get the other party's sockaddr from received skb. The skb begins
61 * with a Phonet header.
64 void pn_skb_get_src_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
66 struct phonethdr *ph = pn_hdr(skb);
67 u16 obj = pn_object(ph->pn_sdev, ph->pn_sobj);
69 sa->spn_family = AF_PHONET;
70 pn_sockaddr_set_object(sa, obj);
71 pn_sockaddr_set_resource(sa, ph->pn_res);
72 memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
76 void pn_skb_get_dst_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
78 struct phonethdr *ph = pn_hdr(skb);
79 u16 obj = pn_object(ph->pn_rdev, ph->pn_robj);
81 sa->spn_family = AF_PHONET;
82 pn_sockaddr_set_object(sa, obj);
83 pn_sockaddr_set_resource(sa, ph->pn_res);
84 memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
87 /* Protocols in Phonet protocol family. */
88 struct phonet_protocol {
89 const struct proto_ops *ops;
94 int phonet_proto_register(int protocol, struct phonet_protocol *pp);
95 void phonet_proto_unregister(int protocol, struct phonet_protocol *pp);
97 void phonet_netlink_register(void);