ObjFW  Check-in [723a396c1a]

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 | 1.0
Files: files | file ages | folders
SHA3-256: 723a396c1a4dda15781bb792eed1156e4218874636176ad512fa0e237a2bfa5f
User & Date: js on 2023-10-21 20:53:00
Other Links: branch diff | manifest | tags
Context
2023-10-22
21:47
Fix OFSocketAddressString() for AppleTalk check-in: b64b8e3b3f user: js tags: 1.0
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:16
GitHub Actions: Remove *BSD check-in: 2da978d398 user: js tags: 1.0
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];