aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/phonet/phonet.h
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2008-10-17 12:20:26 -0400
committerArjan van de Ven <arjan@linux.intel.com>2008-10-17 12:20:26 -0400
commit651dab4264e4ba0e563f5ff56f748127246e9065 (patch)
tree016630974bdcb00fe529b673f96d389e0fd6dc94 /include/net/phonet/phonet.h
parent40b8606253552109815786e5d4b0de98782d31f5 (diff)
parent2e532d68a2b3e2aa6b19731501222069735c741c (diff)
Merge commit 'linus/master' into merge-linus
Conflicts: arch/x86/kvm/i8254.c
Diffstat (limited to 'include/net/phonet/phonet.h')
-rw-r--r--include/net/phonet/phonet.h112
1 files changed, 112 insertions, 0 deletions
diff --git a/include/net/phonet/phonet.h b/include/net/phonet/phonet.h
new file mode 100644
index 000000000000..d4e72508e145
--- /dev/null
+++ b/include/net/phonet/phonet.h
@@ -0,0 +1,112 @@
1/*
2 * File: af_phonet.h
3 *
4 * Phonet sockets kernel definitions
5 *
6 * Copyright (C) 2008 Nokia Corporation.
7 *
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.
11 *
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.
16 *
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
20 * 02110-1301 USA
21 */
22
23#ifndef AF_PHONET_H
24#define AF_PHONET_H
25
26/*
27 * The lower layers may not require more space, ever. Make sure it's
28 * enough.
29 */
30#define MAX_PHONET_HEADER 8
31
32/*
33 * Every Phonet* socket has this structure first in its
34 * protocol-specific structure under name c.
35 */
36struct pn_sock {
37 struct sock sk;
38 u16 sobject;
39 u8 resource;
40};
41
42static inline struct pn_sock *pn_sk(struct sock *sk)
43{
44 return (struct pn_sock *)sk;
45}
46
47extern const struct proto_ops phonet_dgram_ops;
48
49struct sock *pn_find_sock_by_sa(const struct sockaddr_pn *sa);
50void phonet_get_local_port_range(int *min, int *max);
51void pn_sock_hash(struct sock *sk);
52void pn_sock_unhash(struct sock *sk);
53int pn_sock_get_port(struct sock *sk, unsigned short sport);
54
55int pn_skb_send(struct sock *sk, struct sk_buff *skb,
56 const struct sockaddr_pn *target);
57
58static inline struct phonethdr *pn_hdr(struct sk_buff *skb)
59{
60 return (struct phonethdr *)skb_network_header(skb);
61}
62
63static inline struct phonetmsg *pn_msg(struct sk_buff *skb)
64{
65 return (struct phonetmsg *)skb_transport_header(skb);
66}
67
68/*
69 * Get the other party's sockaddr from received skb. The skb begins
70 * with a Phonet header.
71 */
72static inline
73void pn_skb_get_src_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
74{
75 struct phonethdr *ph = pn_hdr(skb);
76 u16 obj = pn_object(ph->pn_sdev, ph->pn_sobj);
77
78 sa->spn_family = AF_PHONET;
79 pn_sockaddr_set_object(sa, obj);
80 pn_sockaddr_set_resource(sa, ph->pn_res);
81 memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
82}
83
84static inline
85void pn_skb_get_dst_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
86{
87 struct phonethdr *ph = pn_hdr(skb);
88 u16 obj = pn_object(ph->pn_rdev, ph->pn_robj);
89
90 sa->spn_family = AF_PHONET;
91 pn_sockaddr_set_object(sa, obj);
92 pn_sockaddr_set_resource(sa, ph->pn_res);
93 memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
94}
95
96/* Protocols in Phonet protocol family. */
97struct phonet_protocol {
98 const struct proto_ops *ops;
99 struct proto *prot;
100 int sock_type;
101};
102
103int phonet_proto_register(int protocol, struct phonet_protocol *pp);
104void phonet_proto_unregister(int protocol, struct phonet_protocol *pp);
105
106int phonet_sysctl_init(void);
107void phonet_sysctl_exit(void);
108void phonet_netlink_register(void);
109int isi_register(void);
110void isi_unregister(void);
111
112#endif