diff options
| author | Remi Denis-Courmont <remi.denis-courmont@nokia.com> | 2008-09-22 23:02:10 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2008-09-22 23:02:10 -0400 |
| commit | 4b07b3f69a8471cdc142c51461a331226fef248a (patch) | |
| tree | 661b8c841ad2e3922f22f585f8628083baa03546 /include/net/phonet | |
| parent | bce7b15426cac3000bf6a9cf59d9356ef0be2dec (diff) | |
Phonet: PF_PHONET protocol family support
This is the basis for the Phonet protocol families, and introduces
the ETH_P_PHONET packet type and the PF_PHONET socket family.
Signed-off-by: Remi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/phonet')
| -rw-r--r-- | include/net/phonet/phonet.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/include/net/phonet/phonet.h b/include/net/phonet/phonet.h new file mode 100644 index 000000000000..c53f2abc0595 --- /dev/null +++ b/include/net/phonet/phonet.h | |||
| @@ -0,0 +1,74 @@ | |||
| 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 | static inline struct phonethdr *pn_hdr(struct sk_buff *skb) | ||
| 33 | { | ||
| 34 | return (struct phonethdr *)skb_network_header(skb); | ||
| 35 | } | ||
| 36 | |||
| 37 | /* | ||
| 38 | * Get the other party's sockaddr from received skb. The skb begins | ||
| 39 | * with a Phonet header. | ||
| 40 | */ | ||
| 41 | static inline | ||
| 42 | void pn_skb_get_src_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa) | ||
| 43 | { | ||
| 44 | struct phonethdr *ph = pn_hdr(skb); | ||
| 45 | u16 obj = pn_object(ph->pn_sdev, ph->pn_sobj); | ||
| 46 | |||
| 47 | sa->spn_family = AF_PHONET; | ||
| 48 | pn_sockaddr_set_object(sa, obj); | ||
| 49 | pn_sockaddr_set_resource(sa, ph->pn_res); | ||
| 50 | memset(sa->spn_zero, 0, sizeof(sa->spn_zero)); | ||
| 51 | } | ||
| 52 | |||
| 53 | static inline | ||
| 54 | void pn_skb_get_dst_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa) | ||
| 55 | { | ||
| 56 | struct phonethdr *ph = pn_hdr(skb); | ||
| 57 | u16 obj = pn_object(ph->pn_rdev, ph->pn_robj); | ||
| 58 | |||
| 59 | sa->spn_family = AF_PHONET; | ||
| 60 | pn_sockaddr_set_object(sa, obj); | ||
| 61 | pn_sockaddr_set_resource(sa, ph->pn_res); | ||
| 62 | memset(sa->spn_zero, 0, sizeof(sa->spn_zero)); | ||
| 63 | } | ||
| 64 | |||
| 65 | /* Protocols in Phonet protocol family. */ | ||
| 66 | struct phonet_protocol { | ||
| 67 | struct proto *prot; | ||
| 68 | int sock_type; | ||
| 69 | }; | ||
| 70 | |||
| 71 | int phonet_proto_register(int protocol, struct phonet_protocol *pp); | ||
| 72 | void phonet_proto_unregister(int protocol, struct phonet_protocol *pp); | ||
| 73 | |||
| 74 | #endif | ||
