Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
0002 /*
0003  * include/uapi/linux/tipc.h: Header for TIPC socket interface
0004  *
0005  * Copyright (c) 2003-2006, 2015-2016 Ericsson AB
0006  * Copyright (c) 2005, 2010-2011, Wind River Systems
0007  * All rights reserved.
0008  *
0009  * Redistribution and use in source and binary forms, with or without
0010  * modification, are permitted provided that the following conditions are met:
0011  *
0012  * 1. Redistributions of source code must retain the above copyright
0013  *    notice, this list of conditions and the following disclaimer.
0014  * 2. Redistributions in binary form must reproduce the above copyright
0015  *    notice, this list of conditions and the following disclaimer in the
0016  *    documentation and/or other materials provided with the distribution.
0017  * 3. Neither the names of the copyright holders nor the names of its
0018  *    contributors may be used to endorse or promote products derived from
0019  *    this software without specific prior written permission.
0020  *
0021  * Alternatively, this software may be distributed under the terms of the
0022  * GNU General Public License ("GPL") version 2 as published by the Free
0023  * Software Foundation.
0024  *
0025  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0026  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0027  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0028  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0029  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0030  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0031  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0032  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0033  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0034  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0035  * POSSIBILITY OF SUCH DAMAGE.
0036  */
0037 
0038 #ifndef _LINUX_TIPC_H_
0039 #define _LINUX_TIPC_H_
0040 
0041 #include <linux/types.h>
0042 #include <linux/sockios.h>
0043 
0044 /*
0045  * TIPC addressing primitives
0046  */
0047 
0048 struct tipc_socket_addr {
0049     __u32 ref;
0050     __u32 node;
0051 };
0052 
0053 struct tipc_service_addr {
0054     __u32 type;
0055     __u32 instance;
0056 };
0057 
0058 struct tipc_service_range {
0059     __u32 type;
0060     __u32 lower;
0061     __u32 upper;
0062 };
0063 
0064 /*
0065  * Application-accessible service types
0066  */
0067 
0068 #define TIPC_NODE_STATE     0   /* node state service type */
0069 #define TIPC_TOP_SRV        1   /* topology server service type */
0070 #define TIPC_LINK_STATE     2   /* link state service type */
0071 #define TIPC_RESERVED_TYPES 64  /* lowest user-allowed service type */
0072 
0073 /*
0074  * Publication scopes when binding service / service range
0075  */
0076 enum tipc_scope {
0077     TIPC_CLUSTER_SCOPE = 2, /* 0 can also be used */
0078     TIPC_NODE_SCOPE    = 3
0079 };
0080 
0081 /*
0082  * Limiting values for messages
0083  */
0084 
0085 #define TIPC_MAX_USER_MSG_SIZE  66000U
0086 
0087 /*
0088  * Message importance levels
0089  */
0090 
0091 #define TIPC_LOW_IMPORTANCE     0
0092 #define TIPC_MEDIUM_IMPORTANCE      1
0093 #define TIPC_HIGH_IMPORTANCE        2
0094 #define TIPC_CRITICAL_IMPORTANCE    3
0095 
0096 /*
0097  * Msg rejection/connection shutdown reasons
0098  */
0099 
0100 #define TIPC_OK         0
0101 #define TIPC_ERR_NO_NAME    1
0102 #define TIPC_ERR_NO_PORT    2
0103 #define TIPC_ERR_NO_NODE    3
0104 #define TIPC_ERR_OVERLOAD   4
0105 #define TIPC_CONN_SHUTDOWN  5
0106 
0107 /*
0108  * TIPC topology subscription service definitions
0109  */
0110 
0111 #define TIPC_SUB_PORTS          0x01    /* filter: evt at each match */
0112 #define TIPC_SUB_SERVICE        0x02    /* filter: evt at first up/last down */
0113 #define TIPC_SUB_CANCEL         0x04    /* filter: cancel a subscription */
0114 
0115 #define TIPC_WAIT_FOREVER   (~0)    /* timeout for permanent subscription */
0116 
0117 struct tipc_subscr {
0118     struct tipc_service_range seq;  /* range of interest */
0119     __u32 timeout;          /* subscription duration (in ms) */
0120     __u32 filter;           /* bitmask of filter options */
0121     char usr_handle[8];     /* available for subscriber use */
0122 };
0123 
0124 #define TIPC_PUBLISHED      1   /* publication event */
0125 #define TIPC_WITHDRAWN      2   /* withdrawal event */
0126 #define TIPC_SUBSCR_TIMEOUT 3   /* subscription timeout event */
0127 
0128 struct tipc_event {
0129     __u32 event;            /* event type */
0130     __u32 found_lower;      /* matching range */
0131     __u32 found_upper;      /*    "      "    */
0132     struct tipc_socket_addr port;   /* associated socket */
0133     struct tipc_subscr s;       /* associated subscription */
0134 };
0135 
0136 /*
0137  * Socket API
0138  */
0139 
0140 #ifndef AF_TIPC
0141 #define AF_TIPC     30
0142 #endif
0143 
0144 #ifndef PF_TIPC
0145 #define PF_TIPC     AF_TIPC
0146 #endif
0147 
0148 #ifndef SOL_TIPC
0149 #define SOL_TIPC    271
0150 #endif
0151 
0152 #define TIPC_ADDR_MCAST         1
0153 #define TIPC_SERVICE_RANGE      1
0154 #define TIPC_SERVICE_ADDR       2
0155 #define TIPC_SOCKET_ADDR        3
0156 
0157 struct sockaddr_tipc {
0158     unsigned short family;
0159     unsigned char  addrtype;
0160     signed   char  scope;
0161     union {
0162         struct tipc_socket_addr id;
0163         struct tipc_service_range nameseq;
0164         struct {
0165             struct tipc_service_addr name;
0166             __u32 domain;
0167         } name;
0168     } addr;
0169 };
0170 
0171 /*
0172  * Ancillary data objects supported by recvmsg()
0173  */
0174 
0175 #define TIPC_ERRINFO    1   /* error info */
0176 #define TIPC_RETDATA    2   /* returned data */
0177 #define TIPC_DESTNAME   3   /* destination name */
0178 
0179 /*
0180  * TIPC-specific socket option names
0181  */
0182 
0183 #define TIPC_IMPORTANCE     127 /* Default: TIPC_LOW_IMPORTANCE */
0184 #define TIPC_SRC_DROPPABLE  128 /* Default: based on socket type */
0185 #define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */
0186 #define TIPC_CONN_TIMEOUT   130 /* Default: 8000 (ms)  */
0187 #define TIPC_NODE_RECVQ_DEPTH   131 /* Default: none (read only) */
0188 #define TIPC_SOCK_RECVQ_DEPTH   132 /* Default: none (read only) */
0189 #define TIPC_MCAST_BROADCAST    133     /* Default: TIPC selects. No arg */
0190 #define TIPC_MCAST_REPLICAST    134     /* Default: TIPC selects. No arg */
0191 #define TIPC_GROUP_JOIN         135     /* Takes struct tipc_group_req* */
0192 #define TIPC_GROUP_LEAVE        136     /* No argument */
0193 #define TIPC_SOCK_RECVQ_USED    137     /* Default: none (read only) */
0194 #define TIPC_NODELAY            138     /* Default: false */
0195 
0196 /*
0197  * Flag values
0198  */
0199 #define TIPC_GROUP_LOOPBACK     0x1  /* Receive copy of sent msg when match */
0200 #define TIPC_GROUP_MEMBER_EVTS  0x2  /* Receive membership events in socket */
0201 
0202 struct tipc_group_req {
0203     __u32 type;      /* group id */
0204     __u32 instance;  /* member id */
0205     __u32 scope;     /* cluster/node */
0206     __u32 flags;
0207 };
0208 
0209 /*
0210  * Maximum sizes of TIPC bearer-related names (including terminating NULL)
0211  * The string formatting for each name element is:
0212  * media: media
0213  * interface: media:interface name
0214  * link: node:interface-node:interface
0215  */
0216 #define TIPC_NODEID_LEN         16
0217 #define TIPC_MAX_MEDIA_NAME 16
0218 #define TIPC_MAX_IF_NAME    16
0219 #define TIPC_MAX_BEARER_NAME    32
0220 #define TIPC_MAX_LINK_NAME  68
0221 
0222 #define SIOCGETLINKNAME        SIOCPROTOPRIVATE
0223 #define SIOCGETNODEID          (SIOCPROTOPRIVATE + 1)
0224 
0225 struct tipc_sioc_ln_req {
0226     __u32 peer;
0227     __u32 bearer_id;
0228     char linkname[TIPC_MAX_LINK_NAME];
0229 };
0230 
0231 struct tipc_sioc_nodeid_req {
0232     __u32 peer;
0233     char node_id[TIPC_NODEID_LEN];
0234 };
0235 
0236 /*
0237  * TIPC Crypto, AEAD
0238  */
0239 #define TIPC_AEAD_ALG_NAME      (32)
0240 
0241 struct tipc_aead_key {
0242     char alg_name[TIPC_AEAD_ALG_NAME];
0243     unsigned int keylen;    /* in bytes */
0244     char key[];
0245 };
0246 
0247 #define TIPC_AEAD_KEYLEN_MIN        (16 + 4)
0248 #define TIPC_AEAD_KEYLEN_MAX        (32 + 4)
0249 #define TIPC_AEAD_KEY_SIZE_MAX      (sizeof(struct tipc_aead_key) + \
0250                             TIPC_AEAD_KEYLEN_MAX)
0251 
0252 static inline int tipc_aead_key_size(struct tipc_aead_key *key)
0253 {
0254     return sizeof(*key) + key->keylen;
0255 }
0256 
0257 #define TIPC_REKEYING_NOW       (~0U)
0258 
0259 /* The macros and functions below are deprecated:
0260  */
0261 
0262 #define TIPC_CFG_SRV        0
0263 #define TIPC_ZONE_SCOPE         1
0264 
0265 #define TIPC_ADDR_NAMESEQ   1
0266 #define TIPC_ADDR_NAME      2
0267 #define TIPC_ADDR_ID        3
0268 
0269 #define TIPC_NODE_BITS          12
0270 #define TIPC_CLUSTER_BITS       12
0271 #define TIPC_ZONE_BITS          8
0272 
0273 #define TIPC_NODE_OFFSET        0
0274 #define TIPC_CLUSTER_OFFSET     TIPC_NODE_BITS
0275 #define TIPC_ZONE_OFFSET        (TIPC_CLUSTER_OFFSET + TIPC_CLUSTER_BITS)
0276 
0277 #define TIPC_NODE_SIZE          ((1UL << TIPC_NODE_BITS) - 1)
0278 #define TIPC_CLUSTER_SIZE       ((1UL << TIPC_CLUSTER_BITS) - 1)
0279 #define TIPC_ZONE_SIZE          ((1UL << TIPC_ZONE_BITS) - 1)
0280 
0281 #define TIPC_NODE_MASK      (TIPC_NODE_SIZE << TIPC_NODE_OFFSET)
0282 #define TIPC_CLUSTER_MASK   (TIPC_CLUSTER_SIZE << TIPC_CLUSTER_OFFSET)
0283 #define TIPC_ZONE_MASK      (TIPC_ZONE_SIZE << TIPC_ZONE_OFFSET)
0284 
0285 #define TIPC_ZONE_CLUSTER_MASK (TIPC_ZONE_MASK | TIPC_CLUSTER_MASK)
0286 
0287 #define tipc_portid tipc_socket_addr
0288 #define tipc_name tipc_service_addr
0289 #define tipc_name_seq tipc_service_range
0290 
0291 static inline __u32 tipc_addr(unsigned int zone,
0292                   unsigned int cluster,
0293                   unsigned int node)
0294 {
0295     return (zone << TIPC_ZONE_OFFSET) |
0296         (cluster << TIPC_CLUSTER_OFFSET) |
0297         node;
0298 }
0299 
0300 static inline unsigned int tipc_zone(__u32 addr)
0301 {
0302     return addr >> TIPC_ZONE_OFFSET;
0303 }
0304 
0305 static inline unsigned int tipc_cluster(__u32 addr)
0306 {
0307     return (addr & TIPC_CLUSTER_MASK) >> TIPC_CLUSTER_OFFSET;
0308 }
0309 
0310 static inline unsigned int tipc_node(__u32 addr)
0311 {
0312     return addr & TIPC_NODE_MASK;
0313 }
0314 
0315 #endif