Differences From Artifact [54a3258015]:
- File utils/ofatalkcfg/OFATalkCfg.m — part of check-in [a143f67237] at 2023-04-12 07:47:43 on branch trunk — utils/ofatalkcfg: Add default phase and range (user: js, size: 7286) [annotate] [blame] [check-ins using]
To 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]
︙ | ︙ | |||
12 13 14 15 16 17 18 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <errno.h> | < < < < < < < > > > > > > > | < < < < < > > > | > > | | > | > | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 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 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <errno.h> #include "unistd.h" #import "OFApplication.h" #import "OFArray.h" #import "OFOptionsParser.h" #import "OFSocket.h" #import "OFStdIOStream.h" #import "OFInvalidFormatException.h" #ifdef HAVE_NET_IF_H # include <net/if.h> #endif #ifdef HAVE_SYS_IOCTL_H # include <sys/ioctl.h> #endif @interface OFATalkCfg: OFObject <OFApplicationDelegate> @end 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; int sock; if (interface.UTF8StringLength > IFNAMSIZ) { [OFStdErr writeFormat: @"%@: Interface name too long!\n", [OFApplication programName]]; [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 ((sock = socket(AF_APPLETALK, SOCK_RAW, 0)) < 0) { int errNo = OFSocketErrNo(); [OFStdErr writeFormat: @"%@: Failed to create socket: %@\n", [OFApplication programName], OFStrError(errNo)]; #ifdef OF_LINUX |
︙ | ︙ |