2 * $Id: route.c,v 1.7 2005-04-28 20:49:46 bfernhomberg Exp $
4 * Copyright (c) 1990,1996 Regents of The University of Michigan.
5 * All Rights Reserved. See COPYRIGHT.
10 #endif /* HAVE_CONFIG_H */
16 #include <sys/param.h>
17 #include <sys/types.h>
18 #include <sys/socket.h>
19 #include <net/route.h>
20 #include <sys/ioctl.h>
21 #include <netatalk/at.h>
27 int route( message, dst, gate, flags )
29 struct sockaddr *dst, *gate;
33 struct ortentry rtent;
38 memset( &rtent, 0, sizeof( struct rtentry ));
40 rtent.rt_gateway = *gate;
41 rtent.rt_flags = flags;
42 return( ioctl( rtfd, message, &rtent ));
53 } mask = { sizeof( struct sockaddr_m ), 0, 0, 0xffff, 0 };
56 struct rt_msghdr rtma_rtm;
57 struct sockaddr_at rtma_dst;
58 struct sockaddr_at rtma_gate;
59 struct sockaddr_m rtma_mask;
62 route( message, dst, gate, flags )
64 struct sockaddr_at *dst, *gate;
69 memset( &rtma, 0, sizeof( struct rt_msg_at ));
70 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at );
71 rtma.rtma_rtm.rtm_version = RTM_VERSION;
72 rtma.rtma_rtm.rtm_type = message;
73 rtma.rtma_rtm.rtm_pid = getpid();
74 rtma.rtma_rtm.rtm_addrs = RTA_DST|RTA_GATEWAY;
75 if ( flags & RTF_HOST ) {
76 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at ) -
77 sizeof( struct sockaddr_m );
79 rtma.rtma_rtm.rtm_msglen = sizeof( struct rt_msg_at );
80 rtma.rtma_rtm.rtm_addrs |= RTA_NETMASK;
81 rtma.rtma_mask = mask;
84 rtma.rtma_rtm.rtm_flags = flags;
86 rtma.rtma_gate = *gate;
87 if (( rc = write( rtfd, &rtma, rtma.rtma_rtm.rtm_msglen )) !=
88 rtma.rtma_rtm.rtm_msglen ) {