2 * $Id: route.c,v 1.5.2.1 2002-02-07 23:59:11 srittau 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 ));
51 } mask = { sizeof( struct sockaddr_m ), 0, 0, 0xffff, 0 };
54 struct rt_msghdr rtma_rtm;
55 struct sockaddr_at rtma_dst;
56 struct sockaddr_at rtma_gate;
57 struct sockaddr_m rtma_mask;
60 route( message, dst, gate, flags )
62 struct sockaddr_at *dst, *gate;
67 memset( &rtma, 0, sizeof( struct rt_msg_at ));
68 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at );
69 rtma.rtma_rtm.rtm_version = RTM_VERSION;
70 rtma.rtma_rtm.rtm_type = message;
71 rtma.rtma_rtm.rtm_pid = getpid();
72 rtma.rtma_rtm.rtm_addrs = RTA_DST|RTA_GATEWAY;
73 if ( flags & RTF_HOST ) {
74 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at ) -
75 sizeof( struct sockaddr_m );
77 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at );
78 rtma.rtma_rtm.rtm_addrs |= RTA_NETMASK;
79 rtma.rtma_mask = mask;
82 rtma.rtma_rtm.rtm_flags = flags;
84 rtma.rtma_gate = *gate;
85 if (( rc = write( rtfd, &rtma, rtma.rtma_rtm.rtm_msglen )) !=
86 rtma.rtma_rtm.rtm_msglen ) {