2 * Copyright (c) 1990,1996 Regents of The University of Michigan.
3 * All Rights Reserved. See COPYRIGHT.
11 #include <sys/param.h>
12 #include <sys/types.h>
13 #include <sys/socket.h>
14 #include <net/route.h>
15 #include <sys/ioctl.h>
17 #include <netatalk/at.h>
23 int route( message, dst, gate, flags )
25 struct sockaddr *dst, *gate;
29 struct ortentry rtent;
34 memset( &rtent, 0, sizeof( struct rtentry ));
36 rtent.rt_gateway = *gate;
37 rtent.rt_flags = flags;
38 return( ioctl( rtfd, message, &rtent ));
48 } mask = { sizeof( struct sockaddr_m ), 0, 0, 0xffff };
51 struct rt_msghdr rtma_rtm;
52 struct sockaddr_at rtma_dst;
53 struct sockaddr_at rtma_gate;
54 struct sockaddr_m rtma_mask;
57 route( message, dst, gate, flags )
59 struct sockaddr_at *dst, *gate;
64 memset( &rtma, 0, sizeof( struct rt_msg_at ));
65 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at );
66 rtma.rtma_rtm.rtm_version = RTM_VERSION;
67 rtma.rtma_rtm.rtm_type = message;
68 rtma.rtma_rtm.rtm_pid = getpid();
69 rtma.rtma_rtm.rtm_addrs = RTA_DST|RTA_GATEWAY;
70 if ( flags & RTF_HOST ) {
71 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at ) -
72 sizeof( struct sockaddr_m );
74 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at );
75 rtma.rtma_rtm.rtm_addrs |= RTA_NETMASK;
76 rtma.rtma_mask = mask;
79 rtma.rtma_rtm.rtm_flags = flags;
81 rtma.rtma_gate = *gate;
82 if (( rc = write( rtfd, &rtma, rtma.rtma_rtm.rtm_msglen )) !=
83 rtma.rtma_rtm.rtm_msglen ) {