MCPcopy Create free account
hub / github.com/SIPp/sipp / open_connections

Function open_connections

src/socket.cpp:2310–2654  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2308}
2309
2310int open_connections()
2311{
2312 int status=0;
2313 int family_hint = PF_UNSPEC;
2314 local_port = 0;
2315
2316 if (!strlen(remote_host)) {
2317 if ((sendMode != MODE_SERVER)) {
2318 ERROR("Missing remote host parameter. This scenario requires it");
2319 }
2320 } else {
2321 int temp_remote_port;
2322 get_host_and_port(remote_host, remote_host, &temp_remote_port);
2323 if (temp_remote_port != 0) {
2324 remote_port = temp_remote_port;
2325 }
2326
2327 /* Resolving the remote IP */
2328 {
2329 fprintf(stderr, "Resolving remote host '%s'... ", remote_host);
2330 struct addrinfo hints;
2331
2332 memset((char*)&hints, 0, sizeof(hints));
2333 hints.ai_flags = AI_PASSIVE;
2334 hints.ai_family = AF_UNSPEC;
2335
2336#ifdef USE_LOCAL_IP_HINTS
2337 struct addrinfo * local_addr;
2338 int ret;
2339 if (strlen(local_ip)) {
2340 if ((ret = getaddrinfo(local_ip, nullptr, &hints, &local_addr)) != 0) {
2341 ERROR("Can't get local IP address in getaddrinfo, "
2342 "local_ip='%s', ret=%d", local_ip, ret);
2343 }
2344
2345 /* Use local address hints when getting the remote */
2346 if (local_addr->ai_addr->sa_family == AF_INET6) {
2347 local_ip_is_ipv6 = true;
2348 hints.ai_family = AF_INET6;
2349 } else {
2350 hints.ai_family = AF_INET;
2351 }
2352 }
2353#endif
2354
2355 /* FIXME: add DNS SRV support using liburli? */
2356 if (gai_getsockaddr(&remote_sockaddr, remote_host, remote_port,
2357 hints.ai_flags, hints.ai_family) != 0) {
2358 ERROR("Unknown remote host '%s'.\n"
2359 "Use 'sipp -h' for details", remote_host);
2360 }
2361
2362 get_inet_address(&remote_sockaddr, remote_ip, sizeof(remote_ip));
2363 family_hint = remote_sockaddr.ss_family;
2364 if (remote_sockaddr.ss_family == AF_INET) {
2365 strcpy(remote_ip_w_brackets, remote_ip);
2366 } else {
2367 sprintf(remote_ip_w_brackets, "[%.39s]", remote_ip);

Callers 1

mainFunction · 0.85

Calls 15

ERRORFunction · 0.85
get_host_and_portFunction · 0.85
gai_getsockaddrFunction · 0.85
get_inet_addressFunction · 0.85
ERROR_NOFunction · 0.85
socklen_from_addrFunction · 0.85
new_sipp_socketFunction · 0.85
sipp_customize_socketFunction · 0.85
sockaddr_update_portFunction · 0.85
sipp_bind_socketFunction · 0.85
WARNINGFunction · 0.85
connect_to_peerFunction · 0.85

Tested by

no test coverage detected