• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This header was generated from the Linux kernel headers by update_headers.py,
3  * to provide necessary information from kernel to userspace, such as constants,
4  * structures, and macros, and thus, contains no copyrightable information.
5  */
6 #ifndef _LINUX_TIPC_CONFIG_H_
7 #define _LINUX_TIPC_CONFIG_H_
8 #include <linux/types.h>
9 #include <linux/string.h>
10 #include <linux/tipc.h>
11 #include <asm/byteorder.h>
12 #ifndef __KERNEL__
13 #include <arpa/inet.h>
14 #endif
15 #define  TIPC_CMD_NOOP              0x0000
16 #define  TIPC_CMD_GET_NODES         0x0001
17 #define  TIPC_CMD_GET_MEDIA_NAMES   0x0002
18 #define  TIPC_CMD_GET_BEARER_NAMES  0x0003
19 #define  TIPC_CMD_GET_LINKS         0x0004
20 #define  TIPC_CMD_SHOW_NAME_TABLE   0x0005
21 #define  TIPC_CMD_SHOW_PORTS        0x0006
22 #define  TIPC_CMD_SHOW_LINK_STATS   0x000B
23 #define  TIPC_CMD_SHOW_STATS        0x000F
24 #define  TIPC_CMD_GET_REMOTE_MNG    0x4003
25 #define  TIPC_CMD_GET_MAX_PORTS     0x4004
26 #define  TIPC_CMD_GET_MAX_PUBL      0x4005
27 #define  TIPC_CMD_GET_MAX_SUBSCR    0x4006
28 #define  TIPC_CMD_GET_MAX_ZONES     0x4007
29 #define  TIPC_CMD_GET_MAX_CLUSTERS  0x4008
30 #define  TIPC_CMD_GET_MAX_NODES     0x4009
31 #define  TIPC_CMD_GET_MAX_SLAVES    0x400A
32 #define  TIPC_CMD_GET_NETID         0x400B
33 #define  TIPC_CMD_ENABLE_BEARER     0x4101
34 #define  TIPC_CMD_DISABLE_BEARER    0x4102
35 #define  TIPC_CMD_SET_LINK_TOL      0x4107
36 #define  TIPC_CMD_SET_LINK_PRI      0x4108
37 #define  TIPC_CMD_SET_LINK_WINDOW   0x4109
38 #define  TIPC_CMD_SET_LOG_SIZE      0x410A
39 #define  TIPC_CMD_DUMP_LOG          0x410B
40 #define  TIPC_CMD_RESET_LINK_STATS  0x410C
41 #define  TIPC_CMD_SET_NODE_ADDR     0x8001
42 #define  TIPC_CMD_SET_REMOTE_MNG    0x8003
43 #define  TIPC_CMD_SET_MAX_PORTS     0x8004
44 #define  TIPC_CMD_SET_MAX_PUBL      0x8005
45 #define  TIPC_CMD_SET_MAX_SUBSCR    0x8006
46 #define  TIPC_CMD_SET_MAX_ZONES     0x8007
47 #define  TIPC_CMD_SET_MAX_CLUSTERS  0x8008
48 #define  TIPC_CMD_SET_MAX_NODES     0x8009
49 #define  TIPC_CMD_SET_MAX_SLAVES    0x800A
50 #define  TIPC_CMD_SET_NETID         0x800B
51 #define  TIPC_CMD_NOT_NET_ADMIN     0xC001
52 #define TIPC_TLV_NONE		0
53 #define TIPC_TLV_VOID		1
54 #define TIPC_TLV_UNSIGNED	2
55 #define TIPC_TLV_STRING		3
56 #define TIPC_TLV_LARGE_STRING	4
57 #define TIPC_TLV_ULTRA_STRING	5
58 #define TIPC_TLV_ERROR_STRING	16
59 #define TIPC_TLV_NET_ADDR	17
60 #define TIPC_TLV_MEDIA_NAME	18
61 #define TIPC_TLV_BEARER_NAME	19
62 #define TIPC_TLV_LINK_NAME	20
63 #define TIPC_TLV_NODE_INFO	21
64 #define TIPC_TLV_LINK_INFO	22
65 #define TIPC_TLV_BEARER_CONFIG	23
66 #define TIPC_TLV_LINK_CONFIG	24
67 #define TIPC_TLV_NAME_TBL_QUERY	25
68 #define TIPC_TLV_PORT_REF	26
69 #define TIPC_MIN_LINK_PRI	0
70 #define TIPC_DEF_LINK_PRI	10
71 #define TIPC_MAX_LINK_PRI	31
72 #define TIPC_MEDIA_LINK_PRI	(TIPC_MAX_LINK_PRI + 1)
73 #define TIPC_MIN_LINK_TOL 50
74 #define TIPC_DEF_LINK_TOL 1500
75 #define TIPC_MAX_LINK_TOL 30000
76 #if (TIPC_MIN_LINK_TOL < 16)
77 #error "TIPC_MIN_LINK_TOL is too small (abort limit may be NaN)"
78 #endif
79 #define TIPC_MIN_LINK_WIN 16
80 #define TIPC_DEF_LINK_WIN 50
81 #define TIPC_MAX_LINK_WIN 8191
82 #define TIPC_DEF_LINK_UDP_MTU 14000
83 struct tipc_node_info {
84 	__be32 addr;
85 	__be32 up;
86 };
87 struct tipc_link_info {
88 	__be32 dest;
89 	__be32 up;
90 	char str[TIPC_MAX_LINK_NAME];
91 };
92 struct tipc_bearer_config {
93 	__be32 priority;
94 	__be32 disc_domain;
95 	char name[TIPC_MAX_BEARER_NAME];
96 };
97 struct tipc_link_config {
98 	__be32 value;
99 	char name[TIPC_MAX_LINK_NAME];
100 };
101 #define TIPC_NTQ_ALLTYPES 0x80000000
102 struct tipc_name_table_query {
103 	__be32 depth;
104 	__be32 type;
105 	__be32 lowbound;
106 	__be32 upbound;
107 };
108 #define TIPC_CFG_TLV_ERROR      "\x80"
109 #define TIPC_CFG_NOT_NET_ADMIN  "\x81"
110 #define TIPC_CFG_NOT_ZONE_MSTR	"\x82"
111 #define TIPC_CFG_NO_REMOTE	"\x83"
112 #define TIPC_CFG_NOT_SUPPORTED  "\x84"
113 #define TIPC_CFG_INVALID_VALUE  "\x85"
114 struct tlv_desc {
115 	__be16 tlv_len;
116 	__be16 tlv_type;
117 };
118 #define TLV_ALIGNTO 4
119 #define TLV_ALIGN(datalen) (((datalen)+(TLV_ALIGNTO-1)) & ~(TLV_ALIGNTO-1))
120 #define TLV_LENGTH(datalen) (sizeof(struct tlv_desc) + (datalen))
121 #define TLV_SPACE(datalen) (TLV_ALIGN(TLV_LENGTH(datalen)))
122 #define TLV_DATA(tlv) ((void *)((char *)(tlv) + TLV_LENGTH(0)))
TLV_OK(const void * tlv,__u16 space)123 static inline int TLV_OK(const void *tlv, __u16 space)
124 {
125 
126 	return (space >= TLV_SPACE(0)) &&
127 		(ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space);
128 }
TLV_CHECK(const void * tlv,__u16 space,__u16 exp_type)129 static inline int TLV_CHECK(const void *tlv, __u16 space, __u16 exp_type)
130 {
131 	return TLV_OK(tlv, space) &&
132 		(ntohs(((struct tlv_desc *)tlv)->tlv_type) == exp_type);
133 }
TLV_GET_LEN(struct tlv_desc * tlv)134 static inline int TLV_GET_LEN(struct tlv_desc *tlv)
135 {
136 	return ntohs(tlv->tlv_len);
137 }
TLV_SET_LEN(struct tlv_desc * tlv,__u16 len)138 static inline void TLV_SET_LEN(struct tlv_desc *tlv, __u16 len)
139 {
140 	tlv->tlv_len = htons(len);
141 }
TLV_CHECK_TYPE(struct tlv_desc * tlv,__u16 type)142 static inline int TLV_CHECK_TYPE(struct tlv_desc *tlv,  __u16 type)
143 {
144 	return (ntohs(tlv->tlv_type) == type);
145 }
TLV_SET_TYPE(struct tlv_desc * tlv,__u16 type)146 static inline void TLV_SET_TYPE(struct tlv_desc *tlv, __u16 type)
147 {
148 	tlv->tlv_type = htons(type);
149 }
TLV_SET(void * tlv,__u16 type,void * data,__u16 len)150 static inline int TLV_SET(void *tlv, __u16 type, void *data, __u16 len)
151 {
152 	struct tlv_desc *tlv_ptr;
153 	int tlv_len;
154 	tlv_len = TLV_LENGTH(len);
155 	tlv_ptr = (struct tlv_desc *)tlv;
156 	tlv_ptr->tlv_type = htons(type);
157 	tlv_ptr->tlv_len  = htons(tlv_len);
158 	if (len && data) {
159 		memcpy(TLV_DATA(tlv_ptr), data, len);
160 		memset(TLV_DATA(tlv_ptr) + len, 0, TLV_SPACE(len) - tlv_len);
161 	}
162 	return TLV_SPACE(len);
163 }
164 struct tlv_list_desc {
165 	struct tlv_desc *tlv_ptr;
166 	__u32 tlv_space;
167 };
TLV_LIST_INIT(struct tlv_list_desc * list,void * data,__u32 space)168 static inline void TLV_LIST_INIT(struct tlv_list_desc *list,
169 				 void *data, __u32 space)
170 {
171 	list->tlv_ptr = (struct tlv_desc *)data;
172 	list->tlv_space = space;
173 }
TLV_LIST_EMPTY(struct tlv_list_desc * list)174 static inline int TLV_LIST_EMPTY(struct tlv_list_desc *list)
175 {
176 	return (list->tlv_space == 0);
177 }
TLV_LIST_CHECK(struct tlv_list_desc * list,__u16 exp_type)178 static inline int TLV_LIST_CHECK(struct tlv_list_desc *list, __u16 exp_type)
179 {
180 	return TLV_CHECK(list->tlv_ptr, list->tlv_space, exp_type);
181 }
TLV_LIST_DATA(struct tlv_list_desc * list)182 static inline void *TLV_LIST_DATA(struct tlv_list_desc *list)
183 {
184 	return TLV_DATA(list->tlv_ptr);
185 }
TLV_LIST_STEP(struct tlv_list_desc * list)186 static inline void TLV_LIST_STEP(struct tlv_list_desc *list)
187 {
188 	__u16 tlv_space = TLV_ALIGN(ntohs(list->tlv_ptr->tlv_len));
189 	list->tlv_ptr = (struct tlv_desc *)((char *)list->tlv_ptr + tlv_space);
190 	list->tlv_space -= tlv_space;
191 }
192 #define TIPC_GENL_NAME		"TIPC"
193 #define TIPC_GENL_VERSION	0x1
194 #define TIPC_GENL_CMD		0x1
195 struct tipc_genlmsghdr {
196 	__u32 dest;
197 	__u16 cmd;
198 	__u16 reserved;
199 };
200 #define TIPC_GENL_HDRLEN	NLMSG_ALIGN(sizeof(struct tipc_genlmsghdr))
201 struct tipc_cfg_msg_hdr {
202 	__be32 tcm_len;
203 	__be16 tcm_type;
204 	__be16 tcm_flags;
205 	char  tcm_reserved[8];
206 };
207 #define TCM_F_REQUEST	0x1
208 #define TCM_F_MORE	0x2
209 #define TCM_ALIGN(datalen)  (((datalen)+3) & ~3)
210 #define TCM_LENGTH(datalen) (sizeof(struct tipc_cfg_msg_hdr) + datalen)
211 #define TCM_SPACE(datalen)  (TCM_ALIGN(TCM_LENGTH(datalen)))
212 #define TCM_DATA(tcm_hdr)   ((void *)((char *)(tcm_hdr) + TCM_LENGTH(0)))
TCM_SET(void * msg,__u16 cmd,__u16 flags,void * data,__u16 data_len)213 static inline int TCM_SET(void *msg, __u16 cmd, __u16 flags,
214 			  void *data, __u16 data_len)
215 {
216 	struct tipc_cfg_msg_hdr *tcm_hdr;
217 	int msg_len;
218 	msg_len = TCM_LENGTH(data_len);
219 	tcm_hdr = (struct tipc_cfg_msg_hdr *)msg;
220 	tcm_hdr->tcm_len   = htonl(msg_len);
221 	tcm_hdr->tcm_type  = htons(cmd);
222 	tcm_hdr->tcm_flags = htons(flags);
223 	if (data_len && data) {
224 		memcpy(TCM_DATA(msg), data, data_len);
225 		memset(TCM_DATA(msg) + data_len, 0, TCM_SPACE(data_len) - msg_len);
226 	}
227 	return TCM_SPACE(data_len);
228 }
229 #endif
230