162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * net/tipc/monitor.h
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Copyright (c) 2015, Ericsson AB
562306a36Sopenharmony_ci * All rights reserved.
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
862306a36Sopenharmony_ci * modification, are permitted provided that the following conditions are met:
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
1162306a36Sopenharmony_ci *    notice, this list of conditions and the following disclaimer.
1262306a36Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright
1362306a36Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in the
1462306a36Sopenharmony_ci *    documentation and/or other materials provided with the distribution.
1562306a36Sopenharmony_ci * 3. Neither the names of the copyright holders nor the names of its
1662306a36Sopenharmony_ci *    contributors may be used to endorse or promote products derived from
1762306a36Sopenharmony_ci *    this software without specific prior written permission.
1862306a36Sopenharmony_ci *
1962306a36Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the
2062306a36Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free
2162306a36Sopenharmony_ci * Software Foundation.
2262306a36Sopenharmony_ci *
2362306a36Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2462306a36Sopenharmony_ci * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2562306a36Sopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2662306a36Sopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
2762306a36Sopenharmony_ci * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2862306a36Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2962306a36Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3062306a36Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3162306a36Sopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3262306a36Sopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3362306a36Sopenharmony_ci * POSSIBILITY OF SUCH DAMAGE.
3462306a36Sopenharmony_ci */
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#ifndef _TIPC_MONITOR_H
3762306a36Sopenharmony_ci#define _TIPC_MONITOR_H
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci#include "netlink.h"
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci/* struct tipc_mon_state: link instance's cache of monitor list and domain state
4262306a36Sopenharmony_ci * @list_gen: current generation of this node's monitor list
4362306a36Sopenharmony_ci * @gen: current generation of this node's local domain
4462306a36Sopenharmony_ci * @peer_gen: most recent domain generation received from peer
4562306a36Sopenharmony_ci * @acked_gen: most recent generation of self's domain acked by peer
4662306a36Sopenharmony_ci * @monitoring: this peer endpoint should continuously monitored
4762306a36Sopenharmony_ci * @probing: peer endpoint should be temporarily probed for potential loss
4862306a36Sopenharmony_ci * @synched: domain record's generation has been synched with peer after reset
4962306a36Sopenharmony_ci */
5062306a36Sopenharmony_cistruct tipc_mon_state {
5162306a36Sopenharmony_ci	u16 list_gen;
5262306a36Sopenharmony_ci	u16 peer_gen;
5362306a36Sopenharmony_ci	u16 acked_gen;
5462306a36Sopenharmony_ci	bool monitoring :1;
5562306a36Sopenharmony_ci	bool probing    :1;
5662306a36Sopenharmony_ci	bool reset      :1;
5762306a36Sopenharmony_ci	bool synched    :1;
5862306a36Sopenharmony_ci};
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ciint tipc_mon_create(struct net *net, int bearer_id);
6162306a36Sopenharmony_civoid tipc_mon_delete(struct net *net, int bearer_id);
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_civoid tipc_mon_peer_up(struct net *net, u32 addr, int bearer_id);
6462306a36Sopenharmony_civoid tipc_mon_peer_down(struct net *net, u32 addr, int bearer_id);
6562306a36Sopenharmony_civoid tipc_mon_prep(struct net *net, void *data, int *dlen,
6662306a36Sopenharmony_ci		   struct tipc_mon_state *state, int bearer_id);
6762306a36Sopenharmony_civoid tipc_mon_rcv(struct net *net, void *data, u16 dlen, u32 addr,
6862306a36Sopenharmony_ci		  struct tipc_mon_state *state, int bearer_id);
6962306a36Sopenharmony_civoid tipc_mon_get_state(struct net *net, u32 addr,
7062306a36Sopenharmony_ci			struct tipc_mon_state *state,
7162306a36Sopenharmony_ci			int bearer_id);
7262306a36Sopenharmony_civoid tipc_mon_remove_peer(struct net *net, u32 addr, int bearer_id);
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ciint tipc_nl_monitor_set_threshold(struct net *net, u32 cluster_size);
7562306a36Sopenharmony_ciint tipc_nl_monitor_get_threshold(struct net *net);
7662306a36Sopenharmony_ciint __tipc_nl_add_monitor(struct net *net, struct tipc_nl_msg *msg,
7762306a36Sopenharmony_ci			  u32 bearer_id);
7862306a36Sopenharmony_ciint tipc_nl_add_monitor_peer(struct net *net, struct tipc_nl_msg *msg,
7962306a36Sopenharmony_ci			     u32 bearer_id, u32 *prev_node);
8062306a36Sopenharmony_civoid tipc_mon_reinit_self(struct net *net);
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ciextern const int tipc_max_domain_size;
8362306a36Sopenharmony_ci#endif
84