Staging: hv: hv_mouse: fix build warning
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / net / phonet / phonet.h
blob5395e09187df46f7d7e7e2403a0c6abeab418c4f
1 /*
2 * File: af_phonet.h
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
20 * 02110-1301 USA
23 #ifndef AF_PHONET_H
24 #define AF_PHONET_H
27 * The lower layers may not require more space, ever. Make sure it's
28 * enough.
30 #define MAX_PHONET_HEADER (8 + MAX_HEADER)
33 * Every Phonet* socket has this structure first in its
34 * protocol-specific structure under name c.
36 struct pn_sock {
37 struct sock sk;
38 u16 sobject;
39 u8 resource;
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 void pn_sock_init(void);
50 struct sock *pn_find_sock_by_sa(struct net *net, const struct sockaddr_pn *sa);
51 void pn_deliver_sock_broadcast(struct net *net, struct sk_buff *skb);
52 void phonet_get_local_port_range(int *min, int *max);
53 void pn_sock_hash(struct sock *sk);
54 void pn_sock_unhash(struct sock *sk);
55 int pn_sock_get_port(struct sock *sk, unsigned short sport);
57 struct sock *pn_find_sock_by_res(struct net *net, u8 res);
58 int pn_sock_bind_res(struct sock *sock, u8 res);
59 int pn_sock_unbind_res(struct sock *sk, u8 res);
60 void pn_sock_unbind_all_res(struct sock *sk);
62 int pn_skb_send(struct sock *sk, struct sk_buff *skb,
63 const struct sockaddr_pn *target);
65 static inline struct phonethdr *pn_hdr(struct sk_buff *skb)
67 return (struct phonethdr *)skb_network_header(skb);
70 static inline struct phonetmsg *pn_msg(struct sk_buff *skb)
72 return (struct phonetmsg *)skb_transport_header(skb);
76 * Get the other party's sockaddr from received skb. The skb begins
77 * with a Phonet header.
79 static inline
80 void pn_skb_get_src_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
82 struct phonethdr *ph = pn_hdr(skb);
83 u16 obj = pn_object(ph->pn_sdev, ph->pn_sobj);
85 sa->spn_family = AF_PHONET;
86 pn_sockaddr_set_object(sa, obj);
87 pn_sockaddr_set_resource(sa, ph->pn_res);
88 memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
91 static inline
92 void pn_skb_get_dst_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
94 struct phonethdr *ph = pn_hdr(skb);
95 u16 obj = pn_object(ph->pn_rdev, ph->pn_robj);
97 sa->spn_family = AF_PHONET;
98 pn_sockaddr_set_object(sa, obj);
99 pn_sockaddr_set_resource(sa, ph->pn_res);
100 memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
103 /* Protocols in Phonet protocol family. */
104 struct phonet_protocol {
105 const struct proto_ops *ops;
106 struct proto *prot;
107 int sock_type;
110 int phonet_proto_register(unsigned int protocol, struct phonet_protocol *pp);
111 void phonet_proto_unregister(unsigned int protocol, struct phonet_protocol *pp);
113 int phonet_sysctl_init(void);
114 void phonet_sysctl_exit(void);
115 int isi_register(void);
116 void isi_unregister(void);
118 #endif