162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * net/tipc/udp_media.h: Include file for UDP bearer media
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Copyright (c) 1996-2006, 2013-2016, Ericsson AB
562306a36Sopenharmony_ci * Copyright (c) 2005, 2010-2011, Wind River Systems
662306a36Sopenharmony_ci * All rights reserved.
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
962306a36Sopenharmony_ci * modification, are permitted provided that the following conditions are met:
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
1262306a36Sopenharmony_ci *    notice, this list of conditions and the following disclaimer.
1362306a36Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright
1462306a36Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in the
1562306a36Sopenharmony_ci *    documentation and/or other materials provided with the distribution.
1662306a36Sopenharmony_ci * 3. Neither the names of the copyright holders nor the names of its
1762306a36Sopenharmony_ci *    contributors may be used to endorse or promote products derived from
1862306a36Sopenharmony_ci *    this software without specific prior written permission.
1962306a36Sopenharmony_ci *
2062306a36Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the
2162306a36Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free
2262306a36Sopenharmony_ci * Software Foundation.
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2562306a36Sopenharmony_ci * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2662306a36Sopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2762306a36Sopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
2862306a36Sopenharmony_ci * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2962306a36Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3062306a36Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3162306a36Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3262306a36Sopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3362306a36Sopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3462306a36Sopenharmony_ci * POSSIBILITY OF SUCH DAMAGE.
3562306a36Sopenharmony_ci */
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#ifdef CONFIG_TIPC_MEDIA_UDP
3862306a36Sopenharmony_ci#ifndef _TIPC_UDP_MEDIA_H
3962306a36Sopenharmony_ci#define _TIPC_UDP_MEDIA_H
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#include <linux/ip.h>
4262306a36Sopenharmony_ci#include <linux/udp.h>
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ciint tipc_udp_nl_bearer_add(struct tipc_bearer *b, struct nlattr *attr);
4562306a36Sopenharmony_ciint tipc_udp_nl_add_bearer_data(struct tipc_nl_msg *msg, struct tipc_bearer *b);
4662306a36Sopenharmony_ciint tipc_udp_nl_dump_remoteip(struct sk_buff *skb, struct netlink_callback *cb);
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci/* check if configured MTU is too low for tipc headers */
4962306a36Sopenharmony_cistatic inline bool tipc_udp_mtu_bad(u32 mtu)
5062306a36Sopenharmony_ci{
5162306a36Sopenharmony_ci	if (mtu >= (TIPC_MIN_BEARER_MTU + sizeof(struct iphdr) +
5262306a36Sopenharmony_ci	    sizeof(struct udphdr)))
5362306a36Sopenharmony_ci		return false;
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci	pr_warn("MTU too low for tipc bearer\n");
5662306a36Sopenharmony_ci	return true;
5762306a36Sopenharmony_ci}
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#endif
6062306a36Sopenharmony_ci#endif
61