xref: /linux-6.15/net/tipc/socket.h (revision ac0074ee)
18826cde6SJon Paul Maloy /* net/tipc/socket.h: Include file for TIPC socket code
28826cde6SJon Paul Maloy  *
38826cde6SJon Paul Maloy  * Copyright (c) 2014, Ericsson AB
48826cde6SJon Paul Maloy  * All rights reserved.
58826cde6SJon Paul Maloy  *
68826cde6SJon Paul Maloy  * Redistribution and use in source and binary forms, with or without
78826cde6SJon Paul Maloy  * modification, are permitted provided that the following conditions are met:
88826cde6SJon Paul Maloy  *
98826cde6SJon Paul Maloy  * 1. Redistributions of source code must retain the above copyright
108826cde6SJon Paul Maloy  *    notice, this list of conditions and the following disclaimer.
118826cde6SJon Paul Maloy  * 2. Redistributions in binary form must reproduce the above copyright
128826cde6SJon Paul Maloy  *    notice, this list of conditions and the following disclaimer in the
138826cde6SJon Paul Maloy  *    documentation and/or other materials provided with the distribution.
148826cde6SJon Paul Maloy  * 3. Neither the names of the copyright holders nor the names of its
158826cde6SJon Paul Maloy  *    contributors may be used to endorse or promote products derived from
168826cde6SJon Paul Maloy  *    this software without specific prior written permission.
178826cde6SJon Paul Maloy  *
188826cde6SJon Paul Maloy  * Alternatively, this software may be distributed under the terms of the
198826cde6SJon Paul Maloy  * GNU General Public License ("GPL") version 2 as published by the Free
208826cde6SJon Paul Maloy  * Software Foundation.
218826cde6SJon Paul Maloy  *
228826cde6SJon Paul Maloy  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
238826cde6SJon Paul Maloy  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
248826cde6SJon Paul Maloy  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
258826cde6SJon Paul Maloy  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
268826cde6SJon Paul Maloy  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
278826cde6SJon Paul Maloy  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
288826cde6SJon Paul Maloy  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
298826cde6SJon Paul Maloy  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
308826cde6SJon Paul Maloy  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
318826cde6SJon Paul Maloy  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
328826cde6SJon Paul Maloy  * POSSIBILITY OF SUCH DAMAGE.
338826cde6SJon Paul Maloy  */
348826cde6SJon Paul Maloy 
358826cde6SJon Paul Maloy #ifndef _TIPC_SOCK_H
368826cde6SJon Paul Maloy #define _TIPC_SOCK_H
378826cde6SJon Paul Maloy 
388826cde6SJon Paul Maloy #include "port.h"
398826cde6SJon Paul Maloy #include <net/sock.h>
408826cde6SJon Paul Maloy 
41*ac0074eeSJon Paul Maloy #define TIPC_CONN_OK      0
42*ac0074eeSJon Paul Maloy #define TIPC_CONN_PROBING 1
43*ac0074eeSJon Paul Maloy 
448826cde6SJon Paul Maloy /**
458826cde6SJon Paul Maloy  * struct tipc_sock - TIPC socket structure
468826cde6SJon Paul Maloy  * @sk: socket - interacts with 'port' and with user via the socket API
478826cde6SJon Paul Maloy  * @port: port - interacts with 'sk' and with the rest of the TIPC stack
488826cde6SJon Paul Maloy  * @peer_name: the peer of the connection, if any
498826cde6SJon Paul Maloy  * @conn_timeout: the time we can wait for an unresponded setup request
504f4482dcSJon Paul Maloy  * @dupl_rcvcnt: number of bytes counted twice, in both backlog and rcv queue
518826cde6SJon Paul Maloy  */
528826cde6SJon Paul Maloy 
538826cde6SJon Paul Maloy struct tipc_sock {
548826cde6SJon Paul Maloy 	struct sock sk;
558826cde6SJon Paul Maloy 	struct tipc_port port;
568826cde6SJon Paul Maloy 	unsigned int conn_timeout;
574f4482dcSJon Paul Maloy 	atomic_t dupl_rcvcnt;
588826cde6SJon Paul Maloy };
598826cde6SJon Paul Maloy 
608826cde6SJon Paul Maloy static inline struct tipc_sock *tipc_sk(const struct sock *sk)
618826cde6SJon Paul Maloy {
628826cde6SJon Paul Maloy 	return container_of(sk, struct tipc_sock, sk);
638826cde6SJon Paul Maloy }
648826cde6SJon Paul Maloy 
6558ed9442SJon Paul Maloy static inline struct tipc_sock *tipc_port_to_sock(const struct tipc_port *port)
668826cde6SJon Paul Maloy {
6758ed9442SJon Paul Maloy 	return container_of(port, struct tipc_sock, port);
688826cde6SJon Paul Maloy }
698826cde6SJon Paul Maloy 
7058ed9442SJon Paul Maloy static inline void tipc_sock_wakeup(struct tipc_sock *tsk)
718826cde6SJon Paul Maloy {
7258ed9442SJon Paul Maloy 	tsk->sk.sk_write_space(&tsk->sk);
7324be34b5SJon Paul Maloy }
7424be34b5SJon Paul Maloy 
759816f061SJon Paul Maloy int tipc_sk_rcv(struct sk_buff *buf);
7624be34b5SJon Paul Maloy 
778826cde6SJon Paul Maloy #endif
78