2 * $Id: route.c,v 1.5 2001-06-25 20:13:45 rufustfirefly Exp $
4 * Copyright (c) 1990,1996 Regents of The University of Michigan.
5 * All Rights Reserved. See COPYRIGHT.
10 #endif /* HAVE_CONFIG_H */
13 #include <sys/param.h>
14 #include <sys/types.h>
15 #include <sys/socket.h>
16 #include <net/route.h>
17 #include <sys/ioctl.h>
19 #include <netatalk/at.h>
25 int route( message, dst, gate, flags )
27 struct sockaddr *dst, *gate;
31 struct ortentry rtent;
36 memset( &rtent, 0, sizeof( struct rtentry ));
38 rtent.rt_gateway = *gate;
39 rtent.rt_flags = flags;
40 return( ioctl( rtfd, message, &rtent ));
50 } mask = { sizeof( struct sockaddr_m ), 0, 0, 0xffff };
53 struct rt_msghdr rtma_rtm;
54 struct sockaddr_at rtma_dst;
55 struct sockaddr_at rtma_gate;
56 struct sockaddr_m rtma_mask;
59 route( message, dst, gate, flags )
61 struct sockaddr_at *dst, *gate;
66 memset( &rtma, 0, sizeof( struct rt_msg_at ));
67 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at );
68 rtma.rtma_rtm.rtm_version = RTM_VERSION;
69 rtma.rtma_rtm.rtm_type = message;
70 rtma.rtma_rtm.rtm_pid = getpid();
71 rtma.rtma_rtm.rtm_addrs = RTA_DST|RTA_GATEWAY;
72 if ( flags & RTF_HOST ) {
73 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at ) -
74 sizeof( struct sockaddr_m );
76 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at );
77 rtma.rtma_rtm.rtm_addrs |= RTA_NETMASK;
78 rtma.rtma_mask = mask;
81 rtma.rtma_rtm.rtm_flags = flags;
83 rtma.rtma_gate = *gate;
84 if (( rc = write( rtfd, &rtma, rtma.rtma_rtm.rtm_msglen )) !=
85 rtma.rtma_rtm.rtm_msglen ) {