diff options
author | Remi Denis-Courmont <remi.denis-courmont@nokia.com> | 2008-09-22 22:51:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-09-22 22:51:15 -0400 |
commit | bce7b15426cac3000bf6a9cf59d9356ef0be2dec (patch) | |
tree | ddee913be01db33130fa4a02a27c7a82c5d6ab26 /include | |
parent | 5c1824587f0797373c95719a196f6098f7c6d20c (diff) |
Phonet: global definitions
Signed-off-by: Remi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/if_ether.h | 1 | ||||
-rw-r--r-- | include/linux/if_phonet.h | 14 | ||||
-rw-r--r-- | include/linux/phonet.h | 125 | ||||
-rw-r--r-- | include/linux/rtnetlink.h | 4 | ||||
-rw-r--r-- | include/linux/socket.h | 4 |
5 files changed, 147 insertions, 1 deletions
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h index 5028e0b6082..723a1c5fbc6 100644 --- a/include/linux/if_ether.h +++ b/include/linux/if_ether.h | |||
@@ -100,6 +100,7 @@ | |||
100 | #define ETH_P_ECONET 0x0018 /* Acorn Econet */ | 100 | #define ETH_P_ECONET 0x0018 /* Acorn Econet */ |
101 | #define ETH_P_HDLC 0x0019 /* HDLC frames */ | 101 | #define ETH_P_HDLC 0x0019 /* HDLC frames */ |
102 | #define ETH_P_ARCNET 0x001A /* 1A for ArcNet :-) */ | 102 | #define ETH_P_ARCNET 0x001A /* 1A for ArcNet :-) */ |
103 | #define ETH_P_PHONET 0x00F5 /* Nokia Phonet frames */ | ||
103 | 104 | ||
104 | /* | 105 | /* |
105 | * This is an Ethernet frame header. | 106 | * This is an Ethernet frame header. |
diff --git a/include/linux/if_phonet.h b/include/linux/if_phonet.h new file mode 100644 index 00000000000..22df25fbc4e --- /dev/null +++ b/include/linux/if_phonet.h | |||
@@ -0,0 +1,14 @@ | |||
1 | /* | ||
2 | * File: if_phonet.h | ||
3 | * | ||
4 | * Phonet interface kernel definitions | ||
5 | * | ||
6 | * Copyright (C) 2008 Nokia Corporation. All rights reserved. | ||
7 | */ | ||
8 | |||
9 | #define PHONET_HEADER_LEN 8 /* Phonet header length */ | ||
10 | |||
11 | #define PHONET_MIN_MTU 6 | ||
12 | /* 6 bytes header + 65535 bytes payload */ | ||
13 | #define PHONET_MAX_MTU 65541 | ||
14 | #define PHONET_DEV_MTU PHONET_MAX_MTU | ||
diff --git a/include/linux/phonet.h b/include/linux/phonet.h new file mode 100644 index 00000000000..6a764f8584a --- /dev/null +++ b/include/linux/phonet.h | |||
@@ -0,0 +1,125 @@ | |||
1 | /** | ||
2 | * file phonet.h | ||
3 | * | ||
4 | * Phonet sockets kernel interface | ||
5 | * | ||
6 | * Copyright (C) 2008 Nokia Corporation. All rights reserved. | ||
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 LINUX_PHONET_H | ||
24 | #define LINUX_PHONET_H | ||
25 | |||
26 | /* Automatic protocol selection */ | ||
27 | #define PN_PROTO_TRANSPORT 0 | ||
28 | /* Phonet datagram socket */ | ||
29 | #define PN_PROTO_PHONET 1 | ||
30 | #define PHONET_NPROTO 2 | ||
31 | |||
32 | #define PNADDR_ANY 0 | ||
33 | #define PNPORT_RESOURCE_ROUTING 0 | ||
34 | |||
35 | /* Phonet protocol header */ | ||
36 | struct phonethdr { | ||
37 | __u8 pn_rdev; | ||
38 | __u8 pn_sdev; | ||
39 | __u8 pn_res; | ||
40 | __be16 pn_length; | ||
41 | __u8 pn_robj; | ||
42 | __u8 pn_sobj; | ||
43 | } __attribute__((packed)); | ||
44 | |||
45 | /* Phonet socket address structure */ | ||
46 | struct sockaddr_pn { | ||
47 | sa_family_t spn_family; | ||
48 | __u8 spn_obj; | ||
49 | __u8 spn_dev; | ||
50 | __u8 spn_resource; | ||
51 | __u8 spn_zero[sizeof(struct sockaddr) - sizeof(sa_family_t) - 3]; | ||
52 | } __attribute__ ((packed)); | ||
53 | |||
54 | static inline __u16 pn_object(__u8 addr, __u16 port) | ||
55 | { | ||
56 | return (addr << 8) | (port & 0x3ff); | ||
57 | } | ||
58 | |||
59 | static inline __u8 pn_obj(__u16 handle) | ||
60 | { | ||
61 | return handle & 0xff; | ||
62 | } | ||
63 | |||
64 | static inline __u8 pn_dev(__u16 handle) | ||
65 | { | ||
66 | return handle >> 8; | ||
67 | } | ||
68 | |||
69 | static inline __u16 pn_port(__u16 handle) | ||
70 | { | ||
71 | return handle & 0x3ff; | ||
72 | } | ||
73 | |||
74 | static inline __u8 pn_addr(__u16 handle) | ||
75 | { | ||
76 | return (handle >> 8) & 0xfc; | ||
77 | } | ||
78 | |||
79 | static inline void pn_sockaddr_set_addr(struct sockaddr_pn *spn, __u8 addr) | ||
80 | { | ||
81 | spn->spn_dev &= 0x03; | ||
82 | spn->spn_dev |= addr & 0xfc; | ||
83 | } | ||
84 | |||
85 | static inline void pn_sockaddr_set_port(struct sockaddr_pn *spn, __u16 port) | ||
86 | { | ||
87 | spn->spn_dev &= 0xfc; | ||
88 | spn->spn_dev |= (port >> 8) & 0x03; | ||
89 | spn->spn_obj = port & 0xff; | ||
90 | } | ||
91 | |||
92 | static inline void pn_sockaddr_set_object(struct sockaddr_pn *spn, | ||
93 | __u16 handle) | ||
94 | { | ||
95 | spn->spn_dev = pn_dev(handle); | ||
96 | spn->spn_obj = pn_obj(handle); | ||
97 | } | ||
98 | |||
99 | static inline void pn_sockaddr_set_resource(struct sockaddr_pn *spn, | ||
100 | __u8 resource) | ||
101 | { | ||
102 | spn->spn_resource = resource; | ||
103 | } | ||
104 | |||
105 | static inline __u8 pn_sockaddr_get_addr(const struct sockaddr_pn *spn) | ||
106 | { | ||
107 | return spn->spn_dev & 0xfc; | ||
108 | } | ||
109 | |||
110 | static inline __u16 pn_sockaddr_get_port(const struct sockaddr_pn *spn) | ||
111 | { | ||
112 | return ((spn->spn_dev & 0x03) << 8) | spn->spn_obj; | ||
113 | } | ||
114 | |||
115 | static inline __u16 pn_sockaddr_get_object(const struct sockaddr_pn *spn) | ||
116 | { | ||
117 | return pn_object(spn->spn_dev, spn->spn_obj); | ||
118 | } | ||
119 | |||
120 | static inline __u8 pn_sockaddr_get_resource(const struct sockaddr_pn *spn) | ||
121 | { | ||
122 | return spn->spn_resource; | ||
123 | } | ||
124 | |||
125 | #endif | ||
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index ca643b13b02..2b3d51c6ec9 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h | |||
@@ -582,6 +582,10 @@ enum rtnetlink_groups { | |||
582 | #define RTNLGRP_IPV6_RULE RTNLGRP_IPV6_RULE | 582 | #define RTNLGRP_IPV6_RULE RTNLGRP_IPV6_RULE |
583 | RTNLGRP_ND_USEROPT, | 583 | RTNLGRP_ND_USEROPT, |
584 | #define RTNLGRP_ND_USEROPT RTNLGRP_ND_USEROPT | 584 | #define RTNLGRP_ND_USEROPT RTNLGRP_ND_USEROPT |
585 | RTNLGRP_PHONET_IFADDR, | ||
586 | #define RTNLGRP_PHONET_IFADDR RTNLGRP_PHONET_IFADDR | ||
587 | RTNLGRP_PHONET_ROUTE, | ||
588 | #define RTNLGRP_PHONET_ROUTE RTNLGRP_PHONET_ROUTE | ||
585 | __RTNLGRP_MAX | 589 | __RTNLGRP_MAX |
586 | }; | 590 | }; |
587 | #define RTNLGRP_MAX (__RTNLGRP_MAX - 1) | 591 | #define RTNLGRP_MAX (__RTNLGRP_MAX - 1) |
diff --git a/include/linux/socket.h b/include/linux/socket.h index dc5086fe773..818ca33bf79 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h | |||
@@ -190,7 +190,8 @@ struct ucred { | |||
190 | #define AF_IUCV 32 /* IUCV sockets */ | 190 | #define AF_IUCV 32 /* IUCV sockets */ |
191 | #define AF_RXRPC 33 /* RxRPC sockets */ | 191 | #define AF_RXRPC 33 /* RxRPC sockets */ |
192 | #define AF_ISDN 34 /* mISDN sockets */ | 192 | #define AF_ISDN 34 /* mISDN sockets */ |
193 | #define AF_MAX 35 /* For now.. */ | 193 | #define AF_PHONET 35 /* Phonet sockets */ |
194 | #define AF_MAX 36 /* For now.. */ | ||
194 | 195 | ||
195 | /* Protocol families, same as address families. */ | 196 | /* Protocol families, same as address families. */ |
196 | #define PF_UNSPEC AF_UNSPEC | 197 | #define PF_UNSPEC AF_UNSPEC |
@@ -227,6 +228,7 @@ struct ucred { | |||
227 | #define PF_IUCV AF_IUCV | 228 | #define PF_IUCV AF_IUCV |
228 | #define PF_RXRPC AF_RXRPC | 229 | #define PF_RXRPC AF_RXRPC |
229 | #define PF_ISDN AF_ISDN | 230 | #define PF_ISDN AF_ISDN |
231 | #define PF_PHONET AF_PHONET | ||
230 | #define PF_MAX AF_MAX | 232 | #define PF_MAX AF_MAX |
231 | 233 | ||
232 | /* Maximum queue length specifiable by listen. */ | 234 | /* Maximum queue length specifiable by listen. */ |