Overview
Comment: | utils/ofatalkcfg: Only use SOCK_RAW on macOS
Linux accepts it, but NetBSD does not. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
0275bd63013a7f47536c1eea910e69a3 |
User & Date: | js on 2023-04-12 10:41:19 |
Other Links: | manifest | tags |
Context
2023-04-12
| ||
13:23 | configure: Check for struct ifreq for ofatalkcfg check-in: 4d0e45544c user: js tags: trunk | |
10:41 | utils/ofatalkcfg: Only use SOCK_RAW on macOS check-in: 0275bd6301 user: js tags: trunk | |
09:30 | Build utils/ofatalkcfg by default check-in: c29a0febe0 user: js tags: trunk | |
Changes
Modified utils/ofatalkcfg/OFATalkCfg.m from [6fea0d2a72] to [88137d01a8].
︙ | ︙ | |||
38 39 40 41 42 43 44 45 46 | OF_APPLICATION_DELEGATE(OFATalkCfg) static void configureInterface(OFString *interface, uint16_t network, uint8_t node, uint8_t phase, uint16_t rangeStart, uint16_t rangeEnd) { struct ifreq request; struct sockaddr_at *sat; | > < > > > > > > > > > > > > > > > > > > > > < < < < < < < < < < < < < < < < | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | OF_APPLICATION_DELEGATE(OFATalkCfg) static void configureInterface(OFString *interface, uint16_t network, uint8_t node, uint8_t phase, uint16_t rangeStart, uint16_t rangeEnd) { int sock; struct ifreq request; struct sockaddr_at *sat; if (interface.UTF8StringLength > IFNAMSIZ) { [OFStdErr writeFormat: @"%@: Interface name too long!\n", [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } #ifdef OF_MACOS if ((sock = socket(AF_APPLETALK, SOCK_RAW, 0)) < 0) { #else if ((sock = socket(AF_APPLETALK, SOCK_DGRAM, 0)) < 0) { #endif int errNo = OFSocketErrNo(); [OFStdErr writeFormat: @"%@: Failed to create socket: %@\n", [OFApplication programName], OFStrError(errNo)]; #ifdef OF_LINUX if (errNo == EAFNOSUPPORT) [OFStdErr writeLine: @"Did you forget to run " @"\"modprobe appletalk\"?"]; #endif [OFApplication terminateWithStatus: 1]; } memset(&request, 0, sizeof(request)); strncpy(request.ifr_name, interface.UTF8String, IFNAMSIZ); sat = (struct sockaddr_at *)&request.ifr_addr; sat->sat_family = AF_APPLETALK; sat->sat_net = OFToBigEndian16(network); sat->sat_node = node; /* * The netrange is hidden in sat_zero and different OSes use different * struct names for it, so the portable way is setting sat_zero * directly. */ sat->sat_zero[0] = phase; sat->sat_zero[2] = rangeStart >> 8; sat->sat_zero[3] = rangeStart & 0xFF; sat->sat_zero[4] = rangeEnd >> 8; sat->sat_zero[5] = rangeEnd & 0xFF; if (ioctl(sock, SIOCSIFADDR, &request) != 0) { [OFStdErr writeFormat: @"%@: Failed to set address: %@\n", [OFApplication programName], OFStrError(OFSocketErrNo())]; [OFApplication terminateWithStatus: 1]; } |
︙ | ︙ |