162306a36Sopenharmony_ci/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * include/uapi/linux/tipc.h: Header for TIPC socket interface 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (c) 2003-2006, 2015-2016 Ericsson AB 662306a36Sopenharmony_ci * Copyright (c) 2005, 2010-2011, Wind River Systems 762306a36Sopenharmony_ci * All rights reserved. 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 1062306a36Sopenharmony_ci * modification, are permitted provided that the following conditions are met: 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright 1362306a36Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 1462306a36Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright 1562306a36Sopenharmony_ci * notice, this list of conditions and the following disclaimer in the 1662306a36Sopenharmony_ci * documentation and/or other materials provided with the distribution. 1762306a36Sopenharmony_ci * 3. Neither the names of the copyright holders nor the names of its 1862306a36Sopenharmony_ci * contributors may be used to endorse or promote products derived from 1962306a36Sopenharmony_ci * this software without specific prior written permission. 2062306a36Sopenharmony_ci * 2162306a36Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the 2262306a36Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free 2362306a36Sopenharmony_ci * Software Foundation. 2462306a36Sopenharmony_ci * 2562306a36Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 2662306a36Sopenharmony_ci * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2762306a36Sopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2862306a36Sopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 2962306a36Sopenharmony_ci * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 3062306a36Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 3162306a36Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 3262306a36Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 3362306a36Sopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3462306a36Sopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3562306a36Sopenharmony_ci * POSSIBILITY OF SUCH DAMAGE. 3662306a36Sopenharmony_ci */ 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#ifndef _LINUX_TIPC_H_ 3962306a36Sopenharmony_ci#define _LINUX_TIPC_H_ 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci#include <linux/types.h> 4262306a36Sopenharmony_ci#include <linux/sockios.h> 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci/* 4562306a36Sopenharmony_ci * TIPC addressing primitives 4662306a36Sopenharmony_ci */ 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_cistruct tipc_socket_addr { 4962306a36Sopenharmony_ci __u32 ref; 5062306a36Sopenharmony_ci __u32 node; 5162306a36Sopenharmony_ci}; 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_cistruct tipc_service_addr { 5462306a36Sopenharmony_ci __u32 type; 5562306a36Sopenharmony_ci __u32 instance; 5662306a36Sopenharmony_ci}; 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_cistruct tipc_service_range { 5962306a36Sopenharmony_ci __u32 type; 6062306a36Sopenharmony_ci __u32 lower; 6162306a36Sopenharmony_ci __u32 upper; 6262306a36Sopenharmony_ci}; 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci/* 6562306a36Sopenharmony_ci * Application-accessible service types 6662306a36Sopenharmony_ci */ 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci#define TIPC_NODE_STATE 0 /* node state service type */ 6962306a36Sopenharmony_ci#define TIPC_TOP_SRV 1 /* topology server service type */ 7062306a36Sopenharmony_ci#define TIPC_LINK_STATE 2 /* link state service type */ 7162306a36Sopenharmony_ci#define TIPC_RESERVED_TYPES 64 /* lowest user-allowed service type */ 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci/* 7462306a36Sopenharmony_ci * Publication scopes when binding service / service range 7562306a36Sopenharmony_ci */ 7662306a36Sopenharmony_cienum tipc_scope { 7762306a36Sopenharmony_ci TIPC_CLUSTER_SCOPE = 2, /* 0 can also be used */ 7862306a36Sopenharmony_ci TIPC_NODE_SCOPE = 3 7962306a36Sopenharmony_ci}; 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci/* 8262306a36Sopenharmony_ci * Limiting values for messages 8362306a36Sopenharmony_ci */ 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci#define TIPC_MAX_USER_MSG_SIZE 66000U 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci/* 8862306a36Sopenharmony_ci * Message importance levels 8962306a36Sopenharmony_ci */ 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci#define TIPC_LOW_IMPORTANCE 0 9262306a36Sopenharmony_ci#define TIPC_MEDIUM_IMPORTANCE 1 9362306a36Sopenharmony_ci#define TIPC_HIGH_IMPORTANCE 2 9462306a36Sopenharmony_ci#define TIPC_CRITICAL_IMPORTANCE 3 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci/* 9762306a36Sopenharmony_ci * Msg rejection/connection shutdown reasons 9862306a36Sopenharmony_ci */ 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci#define TIPC_OK 0 10162306a36Sopenharmony_ci#define TIPC_ERR_NO_NAME 1 10262306a36Sopenharmony_ci#define TIPC_ERR_NO_PORT 2 10362306a36Sopenharmony_ci#define TIPC_ERR_NO_NODE 3 10462306a36Sopenharmony_ci#define TIPC_ERR_OVERLOAD 4 10562306a36Sopenharmony_ci#define TIPC_CONN_SHUTDOWN 5 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci/* 10862306a36Sopenharmony_ci * TIPC topology subscription service definitions 10962306a36Sopenharmony_ci */ 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci#define TIPC_SUB_PORTS 0x01 /* filter: evt at each match */ 11262306a36Sopenharmony_ci#define TIPC_SUB_SERVICE 0x02 /* filter: evt at first up/last down */ 11362306a36Sopenharmony_ci#define TIPC_SUB_CANCEL 0x04 /* filter: cancel a subscription */ 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci#define TIPC_WAIT_FOREVER (~0) /* timeout for permanent subscription */ 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_cistruct tipc_subscr { 11862306a36Sopenharmony_ci struct tipc_service_range seq; /* range of interest */ 11962306a36Sopenharmony_ci __u32 timeout; /* subscription duration (in ms) */ 12062306a36Sopenharmony_ci __u32 filter; /* bitmask of filter options */ 12162306a36Sopenharmony_ci char usr_handle[8]; /* available for subscriber use */ 12262306a36Sopenharmony_ci}; 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci#define TIPC_PUBLISHED 1 /* publication event */ 12562306a36Sopenharmony_ci#define TIPC_WITHDRAWN 2 /* withdrawal event */ 12662306a36Sopenharmony_ci#define TIPC_SUBSCR_TIMEOUT 3 /* subscription timeout event */ 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_cistruct tipc_event { 12962306a36Sopenharmony_ci __u32 event; /* event type */ 13062306a36Sopenharmony_ci __u32 found_lower; /* matching range */ 13162306a36Sopenharmony_ci __u32 found_upper; /* " " */ 13262306a36Sopenharmony_ci struct tipc_socket_addr port; /* associated socket */ 13362306a36Sopenharmony_ci struct tipc_subscr s; /* associated subscription */ 13462306a36Sopenharmony_ci}; 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci/* 13762306a36Sopenharmony_ci * Socket API 13862306a36Sopenharmony_ci */ 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ci#ifndef AF_TIPC 14162306a36Sopenharmony_ci#define AF_TIPC 30 14262306a36Sopenharmony_ci#endif 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci#ifndef PF_TIPC 14562306a36Sopenharmony_ci#define PF_TIPC AF_TIPC 14662306a36Sopenharmony_ci#endif 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci#ifndef SOL_TIPC 14962306a36Sopenharmony_ci#define SOL_TIPC 271 15062306a36Sopenharmony_ci#endif 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci#define TIPC_ADDR_MCAST 1 15362306a36Sopenharmony_ci#define TIPC_SERVICE_RANGE 1 15462306a36Sopenharmony_ci#define TIPC_SERVICE_ADDR 2 15562306a36Sopenharmony_ci#define TIPC_SOCKET_ADDR 3 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_cistruct sockaddr_tipc { 15862306a36Sopenharmony_ci unsigned short family; 15962306a36Sopenharmony_ci unsigned char addrtype; 16062306a36Sopenharmony_ci signed char scope; 16162306a36Sopenharmony_ci union { 16262306a36Sopenharmony_ci struct tipc_socket_addr id; 16362306a36Sopenharmony_ci struct tipc_service_range nameseq; 16462306a36Sopenharmony_ci struct { 16562306a36Sopenharmony_ci struct tipc_service_addr name; 16662306a36Sopenharmony_ci __u32 domain; 16762306a36Sopenharmony_ci } name; 16862306a36Sopenharmony_ci } addr; 16962306a36Sopenharmony_ci}; 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci/* 17262306a36Sopenharmony_ci * Ancillary data objects supported by recvmsg() 17362306a36Sopenharmony_ci */ 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci#define TIPC_ERRINFO 1 /* error info */ 17662306a36Sopenharmony_ci#define TIPC_RETDATA 2 /* returned data */ 17762306a36Sopenharmony_ci#define TIPC_DESTNAME 3 /* destination name */ 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci/* 18062306a36Sopenharmony_ci * TIPC-specific socket option names 18162306a36Sopenharmony_ci */ 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ci#define TIPC_IMPORTANCE 127 /* Default: TIPC_LOW_IMPORTANCE */ 18462306a36Sopenharmony_ci#define TIPC_SRC_DROPPABLE 128 /* Default: based on socket type */ 18562306a36Sopenharmony_ci#define TIPC_DEST_DROPPABLE 129 /* Default: based on socket type */ 18662306a36Sopenharmony_ci#define TIPC_CONN_TIMEOUT 130 /* Default: 8000 (ms) */ 18762306a36Sopenharmony_ci#define TIPC_NODE_RECVQ_DEPTH 131 /* Default: none (read only) */ 18862306a36Sopenharmony_ci#define TIPC_SOCK_RECVQ_DEPTH 132 /* Default: none (read only) */ 18962306a36Sopenharmony_ci#define TIPC_MCAST_BROADCAST 133 /* Default: TIPC selects. No arg */ 19062306a36Sopenharmony_ci#define TIPC_MCAST_REPLICAST 134 /* Default: TIPC selects. No arg */ 19162306a36Sopenharmony_ci#define TIPC_GROUP_JOIN 135 /* Takes struct tipc_group_req* */ 19262306a36Sopenharmony_ci#define TIPC_GROUP_LEAVE 136 /* No argument */ 19362306a36Sopenharmony_ci#define TIPC_SOCK_RECVQ_USED 137 /* Default: none (read only) */ 19462306a36Sopenharmony_ci#define TIPC_NODELAY 138 /* Default: false */ 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ci/* 19762306a36Sopenharmony_ci * Flag values 19862306a36Sopenharmony_ci */ 19962306a36Sopenharmony_ci#define TIPC_GROUP_LOOPBACK 0x1 /* Receive copy of sent msg when match */ 20062306a36Sopenharmony_ci#define TIPC_GROUP_MEMBER_EVTS 0x2 /* Receive membership events in socket */ 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_cistruct tipc_group_req { 20362306a36Sopenharmony_ci __u32 type; /* group id */ 20462306a36Sopenharmony_ci __u32 instance; /* member id */ 20562306a36Sopenharmony_ci __u32 scope; /* cluster/node */ 20662306a36Sopenharmony_ci __u32 flags; 20762306a36Sopenharmony_ci}; 20862306a36Sopenharmony_ci 20962306a36Sopenharmony_ci/* 21062306a36Sopenharmony_ci * Maximum sizes of TIPC bearer-related names (including terminating NULL) 21162306a36Sopenharmony_ci * The string formatting for each name element is: 21262306a36Sopenharmony_ci * media: media 21362306a36Sopenharmony_ci * interface: media:interface name 21462306a36Sopenharmony_ci * link: node:interface-node:interface 21562306a36Sopenharmony_ci */ 21662306a36Sopenharmony_ci#define TIPC_NODEID_LEN 16 21762306a36Sopenharmony_ci#define TIPC_MAX_MEDIA_NAME 16 21862306a36Sopenharmony_ci#define TIPC_MAX_IF_NAME 16 21962306a36Sopenharmony_ci#define TIPC_MAX_BEARER_NAME 32 22062306a36Sopenharmony_ci#define TIPC_MAX_LINK_NAME 68 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_ci#define SIOCGETLINKNAME SIOCPROTOPRIVATE 22362306a36Sopenharmony_ci#define SIOCGETNODEID (SIOCPROTOPRIVATE + 1) 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_cistruct tipc_sioc_ln_req { 22662306a36Sopenharmony_ci __u32 peer; 22762306a36Sopenharmony_ci __u32 bearer_id; 22862306a36Sopenharmony_ci char linkname[TIPC_MAX_LINK_NAME]; 22962306a36Sopenharmony_ci}; 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_cistruct tipc_sioc_nodeid_req { 23262306a36Sopenharmony_ci __u32 peer; 23362306a36Sopenharmony_ci char node_id[TIPC_NODEID_LEN]; 23462306a36Sopenharmony_ci}; 23562306a36Sopenharmony_ci 23662306a36Sopenharmony_ci/* 23762306a36Sopenharmony_ci * TIPC Crypto, AEAD 23862306a36Sopenharmony_ci */ 23962306a36Sopenharmony_ci#define TIPC_AEAD_ALG_NAME (32) 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_cistruct tipc_aead_key { 24262306a36Sopenharmony_ci char alg_name[TIPC_AEAD_ALG_NAME]; 24362306a36Sopenharmony_ci unsigned int keylen; /* in bytes */ 24462306a36Sopenharmony_ci char key[]; 24562306a36Sopenharmony_ci}; 24662306a36Sopenharmony_ci 24762306a36Sopenharmony_ci#define TIPC_AEAD_KEYLEN_MIN (16 + 4) 24862306a36Sopenharmony_ci#define TIPC_AEAD_KEYLEN_MAX (32 + 4) 24962306a36Sopenharmony_ci#define TIPC_AEAD_KEY_SIZE_MAX (sizeof(struct tipc_aead_key) + \ 25062306a36Sopenharmony_ci TIPC_AEAD_KEYLEN_MAX) 25162306a36Sopenharmony_ci 25262306a36Sopenharmony_cistatic inline int tipc_aead_key_size(struct tipc_aead_key *key) 25362306a36Sopenharmony_ci{ 25462306a36Sopenharmony_ci return sizeof(*key) + key->keylen; 25562306a36Sopenharmony_ci} 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ci#define TIPC_REKEYING_NOW (~0U) 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_ci/* The macros and functions below are deprecated: 26062306a36Sopenharmony_ci */ 26162306a36Sopenharmony_ci 26262306a36Sopenharmony_ci#define TIPC_CFG_SRV 0 26362306a36Sopenharmony_ci#define TIPC_ZONE_SCOPE 1 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ci#define TIPC_ADDR_NAMESEQ 1 26662306a36Sopenharmony_ci#define TIPC_ADDR_NAME 2 26762306a36Sopenharmony_ci#define TIPC_ADDR_ID 3 26862306a36Sopenharmony_ci 26962306a36Sopenharmony_ci#define TIPC_NODE_BITS 12 27062306a36Sopenharmony_ci#define TIPC_CLUSTER_BITS 12 27162306a36Sopenharmony_ci#define TIPC_ZONE_BITS 8 27262306a36Sopenharmony_ci 27362306a36Sopenharmony_ci#define TIPC_NODE_OFFSET 0 27462306a36Sopenharmony_ci#define TIPC_CLUSTER_OFFSET TIPC_NODE_BITS 27562306a36Sopenharmony_ci#define TIPC_ZONE_OFFSET (TIPC_CLUSTER_OFFSET + TIPC_CLUSTER_BITS) 27662306a36Sopenharmony_ci 27762306a36Sopenharmony_ci#define TIPC_NODE_SIZE ((1UL << TIPC_NODE_BITS) - 1) 27862306a36Sopenharmony_ci#define TIPC_CLUSTER_SIZE ((1UL << TIPC_CLUSTER_BITS) - 1) 27962306a36Sopenharmony_ci#define TIPC_ZONE_SIZE ((1UL << TIPC_ZONE_BITS) - 1) 28062306a36Sopenharmony_ci 28162306a36Sopenharmony_ci#define TIPC_NODE_MASK (TIPC_NODE_SIZE << TIPC_NODE_OFFSET) 28262306a36Sopenharmony_ci#define TIPC_CLUSTER_MASK (TIPC_CLUSTER_SIZE << TIPC_CLUSTER_OFFSET) 28362306a36Sopenharmony_ci#define TIPC_ZONE_MASK (TIPC_ZONE_SIZE << TIPC_ZONE_OFFSET) 28462306a36Sopenharmony_ci 28562306a36Sopenharmony_ci#define TIPC_ZONE_CLUSTER_MASK (TIPC_ZONE_MASK | TIPC_CLUSTER_MASK) 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_ci#define tipc_portid tipc_socket_addr 28862306a36Sopenharmony_ci#define tipc_name tipc_service_addr 28962306a36Sopenharmony_ci#define tipc_name_seq tipc_service_range 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_cistatic inline __u32 tipc_addr(unsigned int zone, 29262306a36Sopenharmony_ci unsigned int cluster, 29362306a36Sopenharmony_ci unsigned int node) 29462306a36Sopenharmony_ci{ 29562306a36Sopenharmony_ci return (zone << TIPC_ZONE_OFFSET) | 29662306a36Sopenharmony_ci (cluster << TIPC_CLUSTER_OFFSET) | 29762306a36Sopenharmony_ci node; 29862306a36Sopenharmony_ci} 29962306a36Sopenharmony_ci 30062306a36Sopenharmony_cistatic inline unsigned int tipc_zone(__u32 addr) 30162306a36Sopenharmony_ci{ 30262306a36Sopenharmony_ci return addr >> TIPC_ZONE_OFFSET; 30362306a36Sopenharmony_ci} 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_cistatic inline unsigned int tipc_cluster(__u32 addr) 30662306a36Sopenharmony_ci{ 30762306a36Sopenharmony_ci return (addr & TIPC_CLUSTER_MASK) >> TIPC_CLUSTER_OFFSET; 30862306a36Sopenharmony_ci} 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_cistatic inline unsigned int tipc_node(__u32 addr) 31162306a36Sopenharmony_ci{ 31262306a36Sopenharmony_ci return addr & TIPC_NODE_MASK; 31362306a36Sopenharmony_ci} 31462306a36Sopenharmony_ci 31562306a36Sopenharmony_ci#endif 316