Differences From Artifact [a520433515]:
- File
utils/ofatalkcfg/OFATalkCfg.m
— part of check-in
[77d211a25a]
at
2023-04-11 19:20:31
on branch trunk
— Add utils/ofatalkcfg
This is a utility to configure AppleTalk on a network interface.
For now, this is not built by default if AppleTalk sockets are
available, as it is still in an early state. (user: js, size: 7203) [annotate] [blame] [check-ins using]
To Artifact [af3b7cdc64]:
- File utils/ofatalkcfg/OFATalkCfg.m — part of check-in [e27b645562] at 2023-04-12 06:54:10 on branch trunk — Make utils/ofatalkcfg work on NetBSD (user: js, size: 7264) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
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 | #ifdef HAVE_NET_IF_H # include <net/if.h> #endif #ifdef HAVE_SYS_IOCTL_H # include <sys/ioctl.h> #endif #import "OFApplication.h" #import "OFArray.h" #import "OFOptionsParser.h" #import "OFSocket.h" #import "OFStdIOStream.h" #import "OFInvalidFormatException.h" @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 = { 0 }; struct sockaddr_at *sat; struct atalk_netrange *nr; int sock; if (interface.UTF8StringLength > IFNAMSIZ) { [OFStdErr writeFormat: @"%@: Interface name too long!\n", [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } 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; | > > > > > | | 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 | #ifdef HAVE_NET_IF_H # include <net/if.h> #endif #ifdef HAVE_SYS_IOCTL_H # include <sys/ioctl.h> #endif #include "unistd.h" #import "OFApplication.h" #import "OFArray.h" #import "OFOptionsParser.h" #import "OFSocket.h" #import "OFStdIOStream.h" #import "OFInvalidFormatException.h" @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 = { 0 }; struct sockaddr_at *sat; #ifdef OF_LINUX struct atalk_netrange *nr; #else struct netrange *nr; #endif int sock; if (interface.UTF8StringLength > IFNAMSIZ) { [OFStdErr writeFormat: @"%@: Interface name too long!\n", [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } 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; nr = (__typeof__(nr))(void *)sat->sat_zero; nr->nr_phase = phase; nr->nr_firstnet = OFToBigEndian16(rangeStart); nr->nr_lastnet = OFToBigEndian16(rangeEnd); if ((sock = socket(AF_APPLETALK, SOCK_DGRAM, 0)) < 0) { [OFStdErr writeFormat: @"%@: Failed to create socket: %@\n", [OFApplication programName], |
︙ | ︙ | |||
137 138 139 140 141 142 143 | [OFStdErr writeFormat: @"%@: More than one interface " @"specified!\n", [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } if (networkString == nil) { | | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | [OFStdErr writeFormat: @"%@: More than one interface " @"specified!\n", [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } if (networkString == nil) { [OFStdErr writeFormat: @"%@: --network not specified!\n", [OFApplication programName]]; [OFApplication terminateWithStatus: 1]; } @try { network = [networkString unsignedLongLongValueWithBase: 0]; } @catch (OFInvalidFormatException *e) { [OFStdErr writeFormat: @"%@: Invalid format for --network!\n", |
︙ | ︙ |