MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / get_peer_info

Function get_peer_info

src/remote/inet.cpp:2510–2539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2508#endif
2509
2510void get_peer_info(rem_port* port)
2511{
2512/**************************************
2513*
2514* g e t _ p e e r _ i n f o
2515*
2516**************************************
2517*
2518* Functional description
2519* Port just connected. Obtain some info about connection and peer.
2520*
2521**************************************/
2522 port->port_protocol_id = "TCPv4";
2523
2524 SockAddr address;
2525 if (address.getpeername(port->port_handle) == 0)
2526 {
2527 address.unmapV4(); // convert mapped IPv4 to regular IPv4
2528 char host[64]; // 32 digits, 7 colons, 1 trailing null byte
2529 char serv[16];
2530 int nameinfo = getnameinfo(address.ptr(), address.length(), host, sizeof(host),
2531 serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV);
2532
2533 if (!nameinfo)
2534 port->port_address.printf("%s/%s", host, serv);
2535
2536 if (address.family() == AF_INET6)
2537 port->port_protocol_id = "TCPv6";
2538 }
2539}
2540
2541
2542static void inet_gen_error(bool releasePort, rem_port* port, const Arg::StatusVector& v)

Callers 3

INET_connectFunction · 0.85
accept_connectionFunction · 0.85
aux_connectFunction · 0.85

Calls 6

getpeernameMethod · 0.80
unmapV4Method · 0.80
familyMethod · 0.80
ptrMethod · 0.45
lengthMethod · 0.45
printfMethod · 0.45

Tested by

no test coverage detected