~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/net/phonet/phonet.h

Version: ~ [ linux-5.8-rc4 ] ~ [ linux-5.7.7 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.50 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.131 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.187 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.229 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.229 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 + MAX_HEADER)
 31 
 32 /*
 33  * Every Phonet* socket has this structure first in its
 34  * protocol-specific structure under name c.
 35  */
 36 struct pn_sock {
 37         struct sock     sk;
 38         u16             sobject;
 39         u16             dobject;
 40         u8              resource;
 41 };
 42 
 43 static inline struct pn_sock *pn_sk(struct sock *sk)
 44 {
 45         return (struct pn_sock *)sk;
 46 }
 47 
 48 extern const struct proto_ops phonet_dgram_ops;
 49 
 50 void pn_sock_init(void);
 51 struct sock *pn_find_sock_by_sa(struct net *net, const struct sockaddr_pn *sa);
 52 void pn_deliver_sock_broadcast(struct net *net, struct sk_buff *skb);
 53 void phonet_get_local_port_range(int *min, int *max);
 54 int pn_sock_hash(struct sock *sk);
 55 void pn_sock_unhash(struct sock *sk);
 56 int pn_sock_get_port(struct sock *sk, unsigned short sport);
 57 
 58 struct sock *pn_find_sock_by_res(struct net *net, u8 res);
 59 int pn_sock_bind_res(struct sock *sock, u8 res);
 60 int pn_sock_unbind_res(struct sock *sk, u8 res);
 61 void pn_sock_unbind_all_res(struct sock *sk);
 62 
 63 int pn_skb_send(struct sock *sk, struct sk_buff *skb,
 64                 const struct sockaddr_pn *target);
 65 
 66 static inline struct phonethdr *pn_hdr(struct sk_buff *skb)
 67 {
 68         return (struct phonethdr *)skb_network_header(skb);
 69 }
 70 
 71 static inline struct phonetmsg *pn_msg(struct sk_buff *skb)
 72 {
 73         return (struct phonetmsg *)skb_transport_header(skb);
 74 }
 75 
 76 /*
 77  * Get the other party's sockaddr from received skb. The skb begins
 78  * with a Phonet header.
 79  */
 80 static inline
 81 void pn_skb_get_src_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
 82 {
 83         struct phonethdr *ph = pn_hdr(skb);
 84         u16 obj = pn_object(ph->pn_sdev, ph->pn_sobj);
 85 
 86         sa->spn_family = AF_PHONET;
 87         pn_sockaddr_set_object(sa, obj);
 88         pn_sockaddr_set_resource(sa, ph->pn_res);
 89         memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
 90 }
 91 
 92 static inline
 93 void pn_skb_get_dst_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
 94 {
 95         struct phonethdr *ph = pn_hdr(skb);
 96         u16 obj = pn_object(ph->pn_rdev, ph->pn_robj);
 97 
 98         sa->spn_family = AF_PHONET;
 99         pn_sockaddr_set_object(sa, obj);
100         pn_sockaddr_set_resource(sa, ph->pn_res);
101         memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
102 }
103 
104 /* Protocols in Phonet protocol family. */
105 struct phonet_protocol {
106         const struct proto_ops  *ops;
107         struct proto            *prot;
108         int                     sock_type;
109 };
110 
111 int phonet_proto_register(unsigned int protocol,
112                 const struct phonet_protocol *pp);
113 void phonet_proto_unregister(unsigned int protocol,
114                 const struct phonet_protocol *pp);
115 
116 int phonet_sysctl_init(void);
117 void phonet_sysctl_exit(void);
118 int isi_register(void);
119 void isi_unregister(void);
120 
121 #endif
122 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp