xref: /openbmc/linux/net/tipc/udp_media.h (revision 901271e0)
1ef20cd4dSRichard Alpe /*
2ef20cd4dSRichard Alpe  * net/tipc/udp_media.h: Include file for UDP bearer media
3ef20cd4dSRichard Alpe  *
4ef20cd4dSRichard Alpe  * Copyright (c) 1996-2006, 2013-2016, Ericsson AB
5ef20cd4dSRichard Alpe  * Copyright (c) 2005, 2010-2011, Wind River Systems
6ef20cd4dSRichard Alpe  * All rights reserved.
7ef20cd4dSRichard Alpe  *
8ef20cd4dSRichard Alpe  * Redistribution and use in source and binary forms, with or without
9ef20cd4dSRichard Alpe  * modification, are permitted provided that the following conditions are met:
10ef20cd4dSRichard Alpe  *
11ef20cd4dSRichard Alpe  * 1. Redistributions of source code must retain the above copyright
12ef20cd4dSRichard Alpe  *    notice, this list of conditions and the following disclaimer.
13ef20cd4dSRichard Alpe  * 2. Redistributions in binary form must reproduce the above copyright
14ef20cd4dSRichard Alpe  *    notice, this list of conditions and the following disclaimer in the
15ef20cd4dSRichard Alpe  *    documentation and/or other materials provided with the distribution.
16ef20cd4dSRichard Alpe  * 3. Neither the names of the copyright holders nor the names of its
17ef20cd4dSRichard Alpe  *    contributors may be used to endorse or promote products derived from
18ef20cd4dSRichard Alpe  *    this software without specific prior written permission.
19ef20cd4dSRichard Alpe  *
20ef20cd4dSRichard Alpe  * Alternatively, this software may be distributed under the terms of the
21ef20cd4dSRichard Alpe  * GNU General Public License ("GPL") version 2 as published by the Free
22ef20cd4dSRichard Alpe  * Software Foundation.
23ef20cd4dSRichard Alpe  *
24ef20cd4dSRichard Alpe  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25ef20cd4dSRichard Alpe  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26ef20cd4dSRichard Alpe  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27ef20cd4dSRichard Alpe  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28ef20cd4dSRichard Alpe  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29ef20cd4dSRichard Alpe  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30ef20cd4dSRichard Alpe  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31ef20cd4dSRichard Alpe  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32ef20cd4dSRichard Alpe  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33ef20cd4dSRichard Alpe  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34ef20cd4dSRichard Alpe  * POSSIBILITY OF SUCH DAMAGE.
35ef20cd4dSRichard Alpe  */
36ef20cd4dSRichard Alpe 
37ef20cd4dSRichard Alpe #ifdef CONFIG_TIPC_MEDIA_UDP
38ef20cd4dSRichard Alpe #ifndef _TIPC_UDP_MEDIA_H
39ef20cd4dSRichard Alpe #define _TIPC_UDP_MEDIA_H
40ef20cd4dSRichard Alpe 
41901271e0SGhantaKrishnamurthy MohanKrishna #include <linux/ip.h>
42901271e0SGhantaKrishnamurthy MohanKrishna #include <linux/udp.h>
43901271e0SGhantaKrishnamurthy MohanKrishna 
44ef20cd4dSRichard Alpe int tipc_udp_nl_bearer_add(struct tipc_bearer *b, struct nlattr *attr);
45fdb3acccSRichard Alpe int tipc_udp_nl_add_bearer_data(struct tipc_nl_msg *msg, struct tipc_bearer *b);
46832629caSRichard Alpe int tipc_udp_nl_dump_remoteip(struct sk_buff *skb, struct netlink_callback *cb);
47ef20cd4dSRichard Alpe 
48901271e0SGhantaKrishnamurthy MohanKrishna /* check if configured MTU is too low for tipc headers */
tipc_udp_mtu_bad(u32 mtu)49901271e0SGhantaKrishnamurthy MohanKrishna static inline bool tipc_udp_mtu_bad(u32 mtu)
50901271e0SGhantaKrishnamurthy MohanKrishna {
51901271e0SGhantaKrishnamurthy MohanKrishna 	if (mtu >= (TIPC_MIN_BEARER_MTU + sizeof(struct iphdr) +
52901271e0SGhantaKrishnamurthy MohanKrishna 	    sizeof(struct udphdr)))
53901271e0SGhantaKrishnamurthy MohanKrishna 		return false;
54901271e0SGhantaKrishnamurthy MohanKrishna 
55901271e0SGhantaKrishnamurthy MohanKrishna 	pr_warn("MTU too low for tipc bearer\n");
56901271e0SGhantaKrishnamurthy MohanKrishna 	return true;
57901271e0SGhantaKrishnamurthy MohanKrishna }
58901271e0SGhantaKrishnamurthy MohanKrishna 
59ef20cd4dSRichard Alpe #endif
60ef20cd4dSRichard Alpe #endif
61