ObjFW  Check-in [ad9452c908]

Overview
Comment:+[networkInterfaces]: Use index as key on Windows

AdapterName turns out to be the empty string on Windows 98.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ad9452c908b42a371bf1ed38a27129c70d3af7e343038f3108116d2f355d3b7f
User & Date: js on 2023-10-21 20:52:48
Other Links: manifest | tags
Context
2023-10-22
21:45
Add OFSocketAddressDescription() check-in: a8c9d73327 user: js tags: trunk
2023-10-21
20:53
+[networkInterfaces]: Use index as key on Windows check-in: 723a396c1a user: js tags: 1.0
20:52
+[networkInterfaces]: Use index as key on Windows check-in: ad9452c908 user: js tags: trunk
2023-10-20
21:15
GitHub Actions: Remove *BSD check-in: dead6a61cc user: js tags: trunk
Changes

Modified src/platform/Windows/OFSystemInfo+NetworkInterfaces.m from [0c6d28d689] to [6f1d4aef92].

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
45
46
47
48
49
50
51

52
53
54
55
56
57
58







-








}

static OFMutableDictionary OF_GENERIC(OFString *, OFNetworkInterface) *
networkInterfacesFromGetAdaptersAddresses(void)
{
	OFMutableDictionary *ret = [OFMutableDictionary dictionary];
	OFStringEncoding encoding = [OFLocale encoding];
	ULONG adapterAddressesSize = sizeof(IP_ADAPTER_ADDRESSES);
	PIP_ADAPTER_ADDRESSES adapterAddresses;

	if ((adapterAddresses = malloc(adapterAddressesSize)) == NULL)
		return nil;

	@try {
77
78
79
80
81
82
83
84
85


86
87
88
89
90
91
92
76
77
78
79
80
81
82


83
84
85
86
87
88
89
90
91







-
-
+
+








		for (PIP_ADAPTER_ADDRESSES iter = adapterAddresses;
		    iter != NULL; iter = iter->Next) {
			OFString *name;
			OFMutableDictionary *interface;
			OFNumber *index;

			name = [OFString stringWithCString: iter->AdapterName
						  encoding: encoding];
			name = [OFString stringWithFormat: @"%lu",
							   iter->IfIndex];

			if ((interface = [ret objectForKey: name]) == nil) {
				interface = [OFMutableDictionary dictionary];
				[ret setObject: interface forKey: name];
			}

			index = [OFNumber numberWithUnsignedInt: iter->IfIndex];
191
192
193
194
195
196
197
198

199
200
201
202
203
204
205
206
190
191
192
193
194
195
196

197

198
199
200
201
202
203
204







-
+
-







		    iter = iter->Next) {
			OFMutableDictionary *interface;
			OFString *name, *IPString;
			OFNumber *index;
			OFSocketAddress IPv4Address;
			OFData *addresses;

			name = [OFString stringWithCString: iter->AdapterName
			name = [OFString stringWithFormat: @"%u", iter->Index];
						  encoding: encoding];

			if ((interface = [ret objectForKey: name]) == nil) {
				interface = [OFMutableDictionary dictionary];
				[ret setObject: interface forKey: name];
			}

			index = [OFNumber numberWithUnsignedInt: iter->Index];