1 /*************************************************
2 * rpld - an IBM style RIPL server *
3 *************************************************/
5 /* Copyright (c) 1999,2000, James McKenzie.
7 * Copyright (c) 1998,2000, Christopher Lightfoot.
10 * By using this file, you agree to the terms and conditions set
11 * forth in the LICENCE file which can be found at the top level of
12 * the rpld distribution.
14 * IBM is a trademark of IBM corp.
20 "$Id: rpld.c,v 1.30 2000/09/26 04:06:07 root Exp root $";
24 * Revision 1.30 2000/09/26 04:06:07 root
27 * Revision 1.29 2000/09/26 03:48:23 root
30 * Revision 1.28 2000/09/26 02:32:46 root
33 * Revision 1.27 2000/09/26 02:31:38 root
36 * Revision 1.26 2000/09/26 01:42:24 root
39 * Revision 1.25 2000/09/26 01:41:22 root
42 * Revision 1.24 2000/09/26 01:41:20 root
45 * Revision 1.23 2000/09/26 01:41:08 root
48 * Revision 1.22 2000/09/26 01:39:17 root
51 * Revision 1.21 2000/09/26 01:03:19 root
54 * Revision 1.20 2000/07/29 23:25:58 root
57 * Revision 1.19 2000/07/29 23:20:02 root
60 * Revision 1.18 2000/07/23 19:14:19 root
63 * Revision 1.17 2000/07/17 11:59:45 root
66 * Revision 1.16 2000/07/17 10:49:20 root
69 * Revision 1.15 2000/07/17 10:45:38 root
72 * Revision 1.14 2000/07/17 10:43:54 root
75 * Revision 1.13 2000/07/17 10:43:34 root
78 * Revision 1.12 2000/07/16 14:22:06 root
81 * Revision 1.11 2000/07/16 14:05:28 root
84 * Revision 1.10 2000/07/16 13:18:10 root
87 * Revision 1.1 2000/07/16 13:16:33 root
90 * Revision 1.9 1999/09/13 11:17:35 root
93 * Revision 1.8 1999/09/13 11:05:27 root
96 * Revision 1.7 1999/09/13 11:04:13 root
103 #define DEF_IF "eth0"
105 static unsigned char RPL_MC_ADDR[ETH_ALEN] = { 0x3, 0x0, 0x2, 0x0, 0x0, 0x0 };
110 int rpl_sap = RPL_SAP;
115 fprintf (stderr, "Usage \n");
117 "%s [-f] [-C configfile] [-i interface] [-s sap] [-h]\n", name);
118 fprintf (stderr, "\n");
119 fprintf (stderr, "-f do not fork, run in foreground\n");
121 "-C configfile read configfile as the configuration file\n");
123 " rather than the default %s\n", CONFIG_FILE);
125 "-i interface bind to interface rather than default %s\n",
128 "-s sap Use SAP sap, sap may either be decimal or\n");
130 " hex proceeded by 0x common values are 0xfc\n");
132 " 0xf8 and 0xf4 the default is 0x%02x\n", RPL_SAP);
133 fprintf (stderr, "-h print this message\n");
143 unsigned char buf[MAX_FRAME_LEN];
144 struct llchdr *h = (struct llchdr *) buf;
147 char *if_name = DEF_IF;
148 char *config = CONFIG_FILE;
153 openlog ("rpld", LOG_PID, LOG_DAEMON);
158 while ((c = getopt (argc, argv, "C:i:s:fh")) != EOF)
169 if (!strncmp (optarg, "0x", 2))
171 rpl_sap = strtol (optarg + 2, NULL, 16);
175 rpl_sap = strtol (optarg, NULL, 10);
178 if ((rpl_sap <= 0) || (rpl_sap > 255))
181 "%s: argument to -s must be in range 1-255\n",
197 parse_config (config);
200 lld = llc_open (rpl_sap, if_name);
203 syslog (LOG_ERR, "failed to initalize llc layer");
207 if (lld->add_multicast)
209 lld->add_multicast (lld, RPL_MC_ADDR);
212 syslog (LOG_ERR, "my hw addr = %s", ethtoa (lld->mac (lld)));
213 gettimeofday (&last, NULL);
221 tv.tv_usec = pacing >> 1;
230 len = lld->recv (lld, buf, sizeof (buf), smac, NULL, &tv);
233 rpl_packet_recvd (lld, buf, len);
235 nit_read_packet (n, buf, sizeof (buf), &tv);
236 if ((len > LLC_HDR_LEN) && (ntohs (h->h_len) <= 1514))
237 { /*Short circuit most packets */
238 llc_recv (n, buf, len);
245 gettimeofday (&tv, NULL);
255 client_dispatch (lld);
256 gettimeofday (&last, NULL);