Differences From Artifact [6fea0d2a72]:
- File
utils/ofatalkcfg/OFATalkCfg.m
— part of check-in
[2fc4580a5f]
at
2023-04-12 08:37:12
on branch trunk
— utils/ofatalkcfg: Make the code more portable
This makes it work on macOS 10.5. (user: js, size: 7410) [annotate] [blame] [check-ins using]
To Artifact [88137d01a8]:
- File
utils/ofatalkcfg/OFATalkCfg.m
— part of check-in
[0275bd6301]
at
2023-04-12 10:41:19
on branch trunk
— utils/ofatalkcfg: Only use SOCK_RAW on macOS
Linux accepts it, but NetBSD does not. (user: js, size: 7496) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
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]; } |
︙ | ︙ |