MySQL 26.10.0
Source Code Documentation
sock_probe.h
Go to the documentation of this file.
1/* Copyright (c) 2015, 2026, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef SOCK_PROBE_H
25#define SOCK_PROBE_H
26
27#include "xcom/xcom_common.h"
28
29#include "xcom/xcom_os_layer.h"
30
31struct sock_probe;
32typedef struct sock_probe sock_probe;
33
34#ifndef INVALID_SOCKET
35#define INVALID_SOCKET -1
36#endif
37
38/**
39 Find the index of the local node within a node_list.
40
41 This function scans the supplied XCom node list and identifies the first
42 entry that matches the local node. It first applies the globally configured
43 port matcher. If an explicit XCom identity is configured, matching is based
44 on that configured endpoint; otherwise, the function falls back to matching
45 the candidate addresses against the local interfaces visible to the current
46 process.
47
48 The function evaluates global XCom state, namely the installed port matcher,
49 the configured XCom identity, and the configured network namespace manager.
50 The caller does not need to switch to the configured network namespace before
51 invoking this function; if a namespace is configured, the function enters and
52 restores it internally before probing interfaces.
53
54 @param[in] nodes The node list to scan.
55
56 @return The index of the first entry classified as the local node, or
57 VOID_NODE_NO if no entry matches, if no port matcher is installed, if
58 the socket probe cannot be initialized, or if every candidate is
59 rejected by parsing, port mismatch, configured-identity mismatch, or
60 local-interface validation.
61*/
62node_no xcom_find_node_index(node_list *nodes);
63
64/**
65 Check whether a candidate endpoint identifies this local node.
66
67 This function first applies the globally configured port matcher to the
68 candidate port. If an explicit XCom identity is configured, matching is based
69 on that configured endpoint; otherwise, the function falls back to resolving
70 the candidate host/IP and comparing it against the local interfaces visible
71 to the current process.
72
73 The function evaluates global XCom state, namely the installed port matcher,
74 the configured XCom identity, and the configured network namespace manager.
75 The caller does not need to switch to the configured network namespace before
76 invoking this function; if a namespace is configured, the function enters and
77 restores it internally before probing interfaces.
78
79 @param[in] name The candidate host or IP to classify.
80 @param[in] port The candidate XCom port to classify.
81
82 @retval 1 The candidate endpoint was classified as this local node.
83 @retval 0 The candidate endpoint was not classified as this local node, or
84 the local probe state could not be initialized.
85*/
86node_no xcom_mynode_match(const char *name, xcom_port port);
87
88typedef int (*port_matcher)(xcom_port if_port);
91
92#endif
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33
int(* port_matcher)(xcom_port if_port)
Definition: sock_probe.h:88
node_no xcom_mynode_match(const char *name, xcom_port port)
Check whether a candidate endpoint identifies this local node.
Definition: sock_probe.cc:380
node_no xcom_find_node_index(node_list *nodes)
Find the index of the local node within a node_list.
Definition: sock_probe.cc:309
void set_port_matcher(port_matcher x)
Definition: sock_probe.cc:66
port_matcher get_port_matcher()
Definition: sock_probe.cc:68
case opt name
Definition: sslopt-case.h:29
Definition: sock_probe_ix.h:54
unsigned short xcom_port
Definition: xcom_common.h:46