2 * Copyright (c) 1990,1996 Regents of The University of Michigan.
3 * All Rights Reserved. See COPYRIGHT.
10 #include <sys/param.h>
11 #include <sys/types.h>
12 #include <sys/socket.h>
13 #include <net/route.h>
15 #include <netatalk/at.h>
20 route( message, dst, gate, flags )
22 struct sockaddr *dst, *gate;
27 bzero( &rtent, sizeof( struct rtentry ));
29 rtent.rt_gateway = *gate;
30 rtent.rt_flags = flags;
31 return( ioctl( rtfd, message, &rtent ));
41 } mask = { sizeof( struct sockaddr_m ), 0, 0, 0xffff };
44 struct rt_msghdr rtma_rtm;
45 struct sockaddr_at rtma_dst;
46 struct sockaddr_at rtma_gate;
47 struct sockaddr_m rtma_mask;
50 route( message, dst, gate, flags )
52 struct sockaddr_at *dst, *gate;
57 bzero( &rtma, sizeof( struct rt_msg_at ));
58 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at );
59 rtma.rtma_rtm.rtm_version = RTM_VERSION;
60 rtma.rtma_rtm.rtm_type = message;
61 rtma.rtma_rtm.rtm_pid = getpid();
62 rtma.rtma_rtm.rtm_addrs = RTA_DST|RTA_GATEWAY;
63 if ( flags & RTF_HOST ) {
64 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at ) -
65 sizeof( struct sockaddr_m );
67 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at );
68 rtma.rtma_rtm.rtm_addrs |= RTA_NETMASK;
69 rtma.rtma_mask = mask;
72 rtma.rtma_rtm.rtm_flags = flags;
74 rtma.rtma_gate = *gate;
75 if (( rc = write( rtfd, &rtma, rtma.rtma_rtm.rtm_msglen )) !=
76 rtma.rtma_rtm.rtm_msglen ) {