aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/telemetry
AgeCommit message (Expand)AuthorFilesLines
2016-12-16Pylint fixesTibor Frank3-7/+7
2016-12-01CSIT-481: HC Test: Port mirroring (SPAN)selias1-5/+53
2016-10-03CSIT-235: Switched Port Analyzer mirroring (SPAN) - IPv4selias4-0/+296
ghlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (c) 2019 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * @file
 * @brief NAT active-passive HA
 */

#ifndef __included_nat_ha_h__
#define __included_nat_ha_h__

#include <vnet/vnet.h>
#include <vnet/ip/ip.h>

/* Call back functions for received HA events on passive/failover */
typedef void (*nat_ha_sadd_cb_t) (ip4_address_t * in_addr, u16 in_port,
				  ip4_address_t * out_addr, u16 out_port,
				  ip4_address_t * eh_addr, u16 eh_port,
				  ip4_address_t * ehn_addr, u16 ehn_port,
				  u8 proto, u32 fib_index, u16 flags,
				  u32 thread_index);
typedef void (*nat_ha_sdel_cb_t) (ip4_address_t * out_addr, u16 out_port,
				  ip4_address_t * eh_addr, u16 eh_port,
				  u8 proto, u32 fib_index, u32 thread_index);
typedef void (*nat_ha_sref_cb_t) (ip4_address_t * out_addr, u16 out_port,
				  ip4_address_t * eh_addr, u16 eh_port,
				  u8 proto, u32 fib_index, u32 total_pkts,
				  u64 total_bytes, u32 thread_index);

/**
 * @brief Initialize NAT HA
 */
void nat_ha_init (vlib_main_t * vm, nat_ha_sadd_cb_t sadd_cb,
		  nat_ha_sdel_cb_t sdel_cb, nat_ha_sref_cb_t sref_cb);

/**
 * @brief Set HA listener (local settings)
 *
 * @param addr local IP4 address
 * @param port local UDP port number
 * @param path_mtu path MTU between local and failover
 *
 * @returns 0 on success, non-zero value otherwise.
 */
int nat_ha_set_listener (ip4_address_t * addr, u16 port, u32 path_mtu);

/**
 * @brief Get HA listener/local configuration
 */
void nat_ha_get_listener (ip4_address_t * addr, u16 * port, u32 * path_mtu);

/**
 * @brief Set HA failover (remote settings)
 *
 * @param addr failover IP4 address
 * @param port failvoer UDP port number
 * @param session_refresh_interval number of seconds after which to send
 *                                 session counters refresh
 *
 * @returns 0 on success, non-zero value otherwise.
 */
int nat_ha_set_failover (ip4_address_t * addr, u16 port,
			 u32 session_refresh_interval);

/**
 * @brief Get HA failover/remote settings
 */
void nat_ha_get_failover (ip4_address_t * addr, u16 * port,
			  u32 * session_refresh_interval);

/**
 * @brief Create session add HA event
 *
 * @param in_addr inside IPv4 address
 * @param in_port inside L4 port number
 * @param out_addr outside IPv4 address
 * @param out_port outside L4 port number
 * @param eh_addr external host IPv4 address
 * @param eh_port external host L4 port number
 * @param ehn_addr external host IPv4 address after translation
 * @param ehn_port external host L4 port number after translation
 * @param proto L4 protocol
 * @param fib_index fib index
 * @param flags session flags
 * @param thread_index thread index
 * @param is_resync 1 if HA resync
 */
void nat_ha_sadd (ip4_address_t * in_addr, u16 in_port,
		  ip4_address_t * out_addr, u16 out_port,
		  ip4_address_t * eh_addr, u16 eh_port,
		  ip4_address_t * ehn_addr, u16 ehn_port, u8 proto,
		  u32 fib_index, u16 flags, u32 thread_index, u8 is_resync);

/**
 * @brief Create session delete HA event
 *
 * @param out_addr outside IPv4 address
 * @param out_port outside L4 port number
 * @param eh_addr external host IPv4 address
 * @param eh_port external host L4 port number
 * @param proto L4 protocol
 * @param fib_index fib index
 * @param thread_index thread index
 */
void nat_ha_sdel (ip4_address_t * out_addr, u16 out_port,
		  ip4_address_t * eh_addr, u16 eh_port, u8 proto,
		  u32 fib_index, u32 thread_index);

/**
 * @brief Create session refresh HA event
 *
 * @param out_addr outside IPv4 address
 * @param out_port outside L4 port number
 * @param eh_addr external host IPv4 address
 * @param eh_port external host L4 port number
 * @param proto L4 protocol
 * @param fib_index fib index
 * @param total_pkts total packets processed
 * @param total_bytes total bytes processed
 * @param thread_index thread index
 * @param last_refreshed last session refresh time
 * @param now current time
 */
void nat_ha_sref (ip4_address_t * out_addr, u16 out_port,
		  ip4_address_t * eh_addr, u16 eh_port, u8 proto,
		  u32 fib_index, u32 total_pkts, u64 total_bytes,
		  u32 thread_index, f64 * last_refreshed, f64 now);

/**
 * @brief Flush the current HA data (for testing)
 */
void nat_ha_flush (u8 is_resync);

typedef void (*nat_ha_resync_event_cb_t) (u32 client_index, u32 pid,
					  u32 missed_count);

/**
 * @brief Resync HA (resend existing sessions to new failover)
 */
int nat_ha_resync (u32 client_index, u32 pid,
		   nat_ha_resync_event_cb_t event_callback);

/**
 * @brief Get resync status
 *
 * @param in_resync 1 if resync in progress
 * @param resync_ack_missed number of missed (not ACKed) messages
 */
void nat_ha_get_resync_status (u8 * in_resync, u32 * resync_ack_missed);

#endif /* __included_nat_ha_h__ */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */