blob: 17f49ee44cfd9d162d243a294afe5786ce7c1f63 [file] [log] [blame]
Ying Xuec5fa7b32013-06-17 10:54:39 -04001/*
2 * net/tipc/server.h: Include file for TIPC server code
3 *
4 * Copyright (c) 2012-2013, Wind River Systems
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the names of the copyright holders nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * Alternatively, this software may be distributed under the terms of the
20 * GNU General Public License ("GPL") version 2 as published by the Free
21 * Software Foundation.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef _TIPC_SERVER_H
37#define _TIPC_SERVER_H
38
Ying Xue859fc7c2015-01-09 15:27:01 +080039#include <linux/idr.h>
40#include <linux/tipc.h>
Ying Xue4ac1c8d2015-01-09 15:27:09 +080041#include <net/net_namespace.h>
Ying Xuec5fa7b32013-06-17 10:54:39 -040042
43#define TIPC_SERVER_NAME_LEN 32
Jon Maloy232d07b2018-01-08 21:03:30 +010044#define TIPC_SUB_CLUSTER_SCOPE 0x20
45#define TIPC_SUB_NODE_SCOPE 0x40
Jon Maloy83485002018-01-08 21:03:29 +010046#define TIPC_SUB_NO_STATUS 0x80
Ying Xuec5fa7b32013-06-17 10:54:39 -040047
48/**
49 * struct tipc_server - TIPC server structure
50 * @conn_idr: identifier set of connection
51 * @idr_lock: protect the connection identifier set
52 * @idr_in_use: amount of allocated identifier entry
Ying Xuea62fbcc2015-01-09 15:27:11 +080053 * @net: network namspace instance
Ying Xuec5fa7b32013-06-17 10:54:39 -040054 * @rcvbuf_cache: memory cache of server receive buffer
55 * @rcv_wq: receive workqueue
56 * @send_wq: send workqueue
57 * @max_rcvbuf_size: maximum permitted receive message length
58 * @tipc_conn_new: callback will be called when new connection is incoming
Parthasarathy Bhuvaragan333f7962016-04-12 13:05:21 +020059 * @tipc_conn_release: callback will be called before releasing the connection
Ying Xuec5fa7b32013-06-17 10:54:39 -040060 * @tipc_conn_recvmsg: callback will be called when message arrives
61 * @saddr: TIPC server address
62 * @name: server name
63 * @imp: message importance
64 * @type: socket type
Ying Xuec5fa7b32013-06-17 10:54:39 -040065 */
66struct tipc_server {
67 struct idr conn_idr;
68 spinlock_t idr_lock;
69 int idr_in_use;
Ying Xuea62fbcc2015-01-09 15:27:11 +080070 struct net *net;
Ying Xuec5fa7b32013-06-17 10:54:39 -040071 struct kmem_cache *rcvbuf_cache;
72 struct workqueue_struct *rcv_wq;
73 struct workqueue_struct *send_wq;
74 int max_rcvbuf_size;
Ying Xue4ac1c8d2015-01-09 15:27:09 +080075 void *(*tipc_conn_new)(int conid);
Parthasarathy Bhuvaragan333f7962016-04-12 13:05:21 +020076 void (*tipc_conn_release)(int conid, void *usr_data);
Ying Xue4ac1c8d2015-01-09 15:27:09 +080077 void (*tipc_conn_recvmsg)(struct net *net, int conid,
78 struct sockaddr_tipc *addr, void *usr_data,
79 void *buf, size_t len);
Ying Xuec5fa7b32013-06-17 10:54:39 -040080 struct sockaddr_tipc *saddr;
Ying Xuea62fbcc2015-01-09 15:27:11 +080081 char name[TIPC_SERVER_NAME_LEN];
Ying Xuec5fa7b32013-06-17 10:54:39 -040082 int imp;
83 int type;
Ying Xuec5fa7b32013-06-17 10:54:39 -040084};
85
86int tipc_conn_sendmsg(struct tipc_server *s, int conid,
87 struct sockaddr_tipc *addr, void *data, size_t len);
88
Jon Maloy232d07b2018-01-08 21:03:30 +010089bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type, u32 lower,
90 u32 upper, u32 filter, int *conid);
Jon Maloy14c04492017-10-13 11:04:17 +020091void tipc_topsrv_kern_unsubscr(struct net *net, int conid);
92
Ying Xuec5fa7b32013-06-17 10:54:39 -040093/**
94 * tipc_conn_terminate - terminate connection with server
95 *
96 * Note: Must call it in process context since it might sleep
97 */
98void tipc_conn_terminate(struct tipc_server *s, int conid);
Ying Xuec5fa7b32013-06-17 10:54:39 -040099int tipc_server_start(struct tipc_server *s);
100
101void tipc_server_stop(struct tipc_server *s);
102
103#endif