This source file includes following definitions.
- pn_sk
- pn_hdr
- pn_msg
- pn_skb_get_src_sockaddr
- pn_skb_get_dst_sockaddr
1
2
3
4
5
6
7
8
9
10 #ifndef AF_PHONET_H
11 #define AF_PHONET_H
12
13
14
15
16
17 #define MAX_PHONET_HEADER (8 + MAX_HEADER)
18
19
20
21
22
23 struct pn_sock {
24 struct sock sk;
25 u16 sobject;
26 u16 dobject;
27 u8 resource;
28 };
29
30 static inline struct pn_sock *pn_sk(struct sock *sk)
31 {
32 return (struct pn_sock *)sk;
33 }
34
35 extern const struct proto_ops phonet_dgram_ops;
36
37 void pn_sock_init(void);
38 struct sock *pn_find_sock_by_sa(struct net *net, const struct sockaddr_pn *sa);
39 void pn_deliver_sock_broadcast(struct net *net, struct sk_buff *skb);
40 void phonet_get_local_port_range(int *min, int *max);
41 int pn_sock_hash(struct sock *sk);
42 void pn_sock_unhash(struct sock *sk);
43 int pn_sock_get_port(struct sock *sk, unsigned short sport);
44
45 struct sock *pn_find_sock_by_res(struct net *net, u8 res);
46 int pn_sock_bind_res(struct sock *sock, u8 res);
47 int pn_sock_unbind_res(struct sock *sk, u8 res);
48 void pn_sock_unbind_all_res(struct sock *sk);
49
50 int pn_skb_send(struct sock *sk, struct sk_buff *skb,
51 const struct sockaddr_pn *target);
52
53 static inline struct phonethdr *pn_hdr(struct sk_buff *skb)
54 {
55 return (struct phonethdr *)skb_network_header(skb);
56 }
57
58 static inline struct phonetmsg *pn_msg(struct sk_buff *skb)
59 {
60 return (struct phonetmsg *)skb_transport_header(skb);
61 }
62
63
64
65
66
67 static inline
68 void pn_skb_get_src_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
69 {
70 struct phonethdr *ph = pn_hdr(skb);
71 u16 obj = pn_object(ph->pn_sdev, ph->pn_sobj);
72
73 sa->spn_family = AF_PHONET;
74 pn_sockaddr_set_object(sa, obj);
75 pn_sockaddr_set_resource(sa, ph->pn_res);
76 memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
77 }
78
79 static inline
80 void pn_skb_get_dst_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
81 {
82 struct phonethdr *ph = pn_hdr(skb);
83 u16 obj = pn_object(ph->pn_rdev, ph->pn_robj);
84
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));
89 }
90
91
92 struct phonet_protocol {
93 const struct proto_ops *ops;
94 struct proto *prot;
95 int sock_type;
96 };
97
98 int phonet_proto_register(unsigned int protocol,
99 const struct phonet_protocol *pp);
100 void phonet_proto_unregister(unsigned int protocol,
101 const struct phonet_protocol *pp);
102
103 int phonet_sysctl_init(void);
104 void phonet_sysctl_exit(void);
105 int isi_register(void);
106 void isi_unregister(void);
107
108 #endif