ObjFW  Check-in [d5310a5145]

Overview
Comment:configure: Check for if_{indextoname,nametoindex}
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d5310a5145228ac07a8a62d0d64a2424161b1cace5431dd994c27eedb16672af
User & Date: js on 2022-11-04 23:30:20
Other Links: manifest | tags
Context
2022-11-05
10:01
Don't include <net/if.h> on MorphOS check-in: 6235989999 user: js tags: trunk
2022-11-04
23:30
configure: Check for if_{indextoname,nametoindex} check-in: d5310a5145 user: js tags: trunk
23:25
Make Windows XP work again check-in: 631661004a user: js tags: trunk
Changes

Modified configure.ac from [8f2d8a22b8] to [39df9f43ba].

1402
1403
1404
1405
1406
1407
1408

1409
1410
1411
1412
1413
1414
1415
			[Whether we have netinet/in.h])
	])
	AC_CHECK_HEADER(netinet/tcp.h, [
		AC_DEFINE(OF_HAVE_NETINET_TCP_H, 1,
			[Whether we have netinet/tcp.h])
	])
	AC_CHECK_HEADERS([arpa/inet.h netdb.h net/if.h])

	AC_CHECK_HEADER(sys/un.h, [
		AC_DEFINE(OF_HAVE_SYS_UN_H, 1, [Whether we have sys/un.h])
	])
	AC_CHECK_MEMBER([struct sockaddr_in6.sin6_addr], [
		AC_EGREP_CPP(egrep_cpp_yes, [
			#ifdef _WIN32
			typedef int BOOL;







>







1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
			[Whether we have netinet/in.h])
	])
	AC_CHECK_HEADER(netinet/tcp.h, [
		AC_DEFINE(OF_HAVE_NETINET_TCP_H, 1,
			[Whether we have netinet/tcp.h])
	])
	AC_CHECK_HEADERS([arpa/inet.h netdb.h net/if.h])
	AC_CHECK_FUNCS([if_indextoname if_nametoindex])
	AC_CHECK_HEADER(sys/un.h, [
		AC_DEFINE(OF_HAVE_SYS_UN_H, 1, [Whether we have sys/un.h])
	])
	AC_CHECK_MEMBER([struct sockaddr_in6.sin6_addr], [
		AC_EGREP_CPP(egrep_cpp_yes, [
			#ifdef _WIN32
			typedef int BOOL;

Modified src/OFSocket.m from [1bb1aecd92] to [f8a99adefe].

466
467
468
469
470
471
472

473

474
475
476
477
478
479
480
481
482
483
484
485
486
487
	addrIn6->sin6_family = AF_INET6;
#else
	addrIn6->sin6_family = AF_UNSPEC;
#endif
	addrIn6->sin6_port = OFToBigEndian16(port);

	if ((percent = [IPv6 rangeOfString: @"%"].location) != OFNotFound) {

		OFString *interface = [IPv6 substringFromIndex: percent + 1];

		IPv6 = [IPv6 substringToIndex: percent];

#ifdef OF_WINDOWS
		if (if_nametoindexPtr != NULL)
			addrIn6->sin6_scope_id = if_nametoindexPtr([interface
			    cStringWithEncoding: [OFLocale encoding]]);
#else
		addrIn6->sin6_scope_id = if_nametoindex(
		    [interface cStringWithEncoding: [OFLocale encoding]]);
#endif
	}

	doubleColon = [IPv6 rangeOfString: @"::"].location;
	if (doubleColon != OFNotFound) {







>

>


|



|







466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
	addrIn6->sin6_family = AF_INET6;
#else
	addrIn6->sin6_family = AF_UNSPEC;
#endif
	addrIn6->sin6_port = OFToBigEndian16(port);

	if ((percent = [IPv6 rangeOfString: @"%"].location) != OFNotFound) {
#if defined(HAVE_IF_NAMETOINDEX) || defined(OF_WINDOWS)
		OFString *interface = [IPv6 substringFromIndex: percent + 1];
#endif
		IPv6 = [IPv6 substringToIndex: percent];

#if defined(OF_WINDOWS)
		if (if_nametoindexPtr != NULL)
			addrIn6->sin6_scope_id = if_nametoindexPtr([interface
			    cStringWithEncoding: [OFLocale encoding]]);
#elif defined(HAVE_IF_NAMETOINDEX)
		addrIn6->sin6_scope_id = if_nametoindex(
		    [interface cStringWithEncoding: [OFLocale encoding]]);
#endif
	}

	doubleColon = [IPv6 rangeOfString: @"::"].location;
	if (doubleColon != OFNotFound) {
902
903
904
905
906
907
908

909
910
911
912
913
914
915
916
917
918
919
920
921
922
923

924
925
926
927
928
929
930
			    (first ? @"%x" : @":%x"),
			    (addrIn6->sin6_addr.s6_addr[i] << 8) |
			    addrIn6->sin6_addr.s6_addr[i + 1]];
			first = false;
		}
	}


	if (addrIn6->sin6_scope_id != 0) {
#ifdef OF_WINDOWS
		char interface[IF_MAX_STRING_SIZE];

		if (if_indextonamePtr != NULL && if_indextonamePtr(
		    addrIn6->sin6_scope_id, interface) != NULL)
#else
		char interface[IF_NAMESIZE];

		if (if_indextoname(addrIn6->sin6_scope_id, interface) != NULL)
#endif
			[string appendFormat: @"%%%s", interface];
		else
			[string appendFormat: @"%%%u", addrIn6->sin6_scope_id];
	}


	[string makeImmutable];

	return string;
}

OFString *







>

|




|



|




>







904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
			    (first ? @"%x" : @":%x"),
			    (addrIn6->sin6_addr.s6_addr[i] << 8) |
			    addrIn6->sin6_addr.s6_addr[i + 1]];
			first = false;
		}
	}

#if defined(HAVE_IF_INDEXTONAME) || defined(OF_WINDOWS)
	if (addrIn6->sin6_scope_id != 0) {
# ifdef OF_WINDOWS
		char interface[IF_MAX_STRING_SIZE];

		if (if_indextonamePtr != NULL && if_indextonamePtr(
		    addrIn6->sin6_scope_id, interface) != NULL)
# else
		char interface[IF_NAMESIZE];

		if (if_indextoname(addrIn6->sin6_scope_id, interface) != NULL)
# endif
			[string appendFormat: @"%%%s", interface];
		else
			[string appendFormat: @"%%%u", addrIn6->sin6_scope_id];
	}
#endif

	[string makeImmutable];

	return string;
}

OFString *