static char rcsid
[] = "$Header$";
* XNS Routing Information Protocol Daemon
int supplier
= -1; /* process should supply updates */
struct rip
*msg
= (struct rip
*) &packet
[sizeof (struct idp
)];
extern struct interface
*ifnet
;
while (argc
> 0 && **argv
== '-') {
if (strcmp(*argv
, "-s") == 0) {
if (strcmp(*argv
, "-q") == 0) {
if (strcmp(*argv
, "-t") == 0) {
if (strcmp(*argv
, "-g") == 0) {
if (strcmp(*argv
, "-l") == 0) {
"usage: xnsrouted [ -s ] [ -q ] [ -t ] [ -g ] [ -l ]\n");
ioctl(t
, TIOCNOTTY
, (char *)0);
* Any extra argument is considered
* Collect an initial view of the world by
* snooping in the kernel. Then, send a request packet on all
* directly connected networks to find out what
/* request the state of the world */
msg
->rip_cmd
= htons(RIPCMD_REQUEST
);
xnnet(msg
->rip_nets
[0].rip_dst
) = htonl(DSTNETS_ALL
);
msg
->rip_nets
[0].rip_metric
= htons(HOPCNT_INFINITY
);
* Listen for RIF packets on all interfaces
for( ifp
= ifnet
; ifp
!=0; ifp
= ifp
->int_next
) {
selectbits
|= 1 << ifp
->int_ripsock
[0];
selectbits
|= 1 << ifp
->int_ripsock
[1];
n
= select(20, &ibits
, 0, 0, 0);
for( ifp
= ifnet
; ifp
!=0; ifp
= ifp
->int_next
) {
/* take RIF packet off interface */
if(ibits
& (1 << ifp
->int_ripsock
[n
]))
process(ifp
->int_ripsock
[n
]);
int fromlen
= sizeof (from
), cc
, omask
;
struct idp
*idp
= (struct idp
*)packet
;
cc
= recvfrom(fd
, packet
, sizeof (packet
), 0, &from
, &fromlen
);
if (cc
< 0 && errno
!= EINTR
)
/* We get the IDP header in front of the RIF packet*/
fprintf(ftrace
,"rcv %d bytes on %s ",
cc
, xns_ntoa(&idp
->idp_dst
));
fprintf(ftrace
," from %s\n", xns_ntoa(&idp
->idp_src
));
if (xnnet(idp
->idp_src
.xn_net
) != xnnet(idp
->idp_dst
.xn_net
)) {
fprintf(ftrace
, "XNSrouted: net of interface (%d) != net on ether (%d)!\n",
ntohl(xnnet(idp
->idp_dst
.xn_net
)),
ntohs(xnnet(idp
->idp_src
.xn_net
)));
cc
-= sizeof (struct idp
);
if (fromlen
!= sizeof (struct sockaddr_xn
))
#define mask(s) (1<<((s)-1))
omask
= sigblock(mask(SIGALRM
));
getsocket(domain
, type
, proto
, sxn
)
while ((s
= socket(domain
, type
, proto
, 0)) < 0 && retry
) {
while (bind(s
, sxn
, sizeof (*sxn
), 0) < 0 && retry
) {
* Fork and exit on EMT-- for profiling.