1 /*************************************************
2 * rpld - an IBM style RIPL server *
3 *************************************************/
5 /* Copyright (c) 1999,2000,2001 James McKenzie.
7 * Copyright (c) 1998,2000,2001 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.
19 static char rcsid[] = "$Id: rpld.c,v 1.35 2001/11/01 15:30:29 root Exp $";
23 * Revision 1.35 2001/11/01 15:30:29 root
26 * Revision 1.34 2001/11/01 15:28:23 root
29 * Revision 1.33 2001/11/01 15:26:45 root
32 * Revision 1.32 2001/11/01 15:26:29 root
35 * Revision 1.31 2001/11/01 15:23:59 root
38 * Revision 1.30 2000/09/26 04:06:07 root
41 * Revision 1.29 2000/09/26 03:48:23 root
44 * Revision 1.28 2000/09/26 02:32:46 root
47 * Revision 1.27 2000/09/26 02:31:38 root
50 * Revision 1.26 2000/09/26 01:42:24 root
53 * Revision 1.25 2000/09/26 01:41:22 root
56 * Revision 1.24 2000/09/26 01:41:20 root
59 * Revision 1.23 2000/09/26 01:41:08 root
62 * Revision 1.22 2000/09/26 01:39:17 root
65 * Revision 1.21 2000/09/26 01:03:19 root
68 * Revision 1.20 2000/07/29 23:25:58 root
71 * Revision 1.19 2000/07/29 23:20:02 root
74 * Revision 1.18 2000/07/23 19:14:19 root
77 * Revision 1.17 2000/07/17 11:59:45 root
80 * Revision 1.16 2000/07/17 10:49:20 root
83 * Revision 1.15 2000/07/17 10:45:38 root
86 * Revision 1.14 2000/07/17 10:43:54 root
89 * Revision 1.13 2000/07/17 10:43:34 root
92 * Revision 1.12 2000/07/16 14:22:06 root
95 * Revision 1.11 2000/07/16 14:05:28 root
98 * Revision 1.10 2000/07/16 13:18:10 root
101 * Revision 1.1 2000/07/16 13:16:33 root
104 * Revision 1.9 1999/09/13 11:17:35 root
107 * Revision 1.8 1999/09/13 11:05:27 root
110 * Revision 1.7 1999/09/13 11:04:13 root
119 #define DEF_IF "eth0"
121 static unsigned char RPL_MC_ADDR[ETH_ALEN] = { 0x3, 0x0, 0x2, 0x0, 0x0, 0x0 };
126 int rpl_sap = RPL_SAP;
131 fprintf (stderr, "Usage \n");
133 "%s [-f] [-C configfile] [-i interface] [-s sap] [-h]\n", name);
134 fprintf (stderr, "\n");
135 fprintf (stderr, "-f do not fork, run in foreground\n");
137 "-C configfile read configfile as the configuration file\n");
139 " rather than the default %s\n", CONFIG_FILE);
141 "-i interface bind to interface rather than default %s\n",
144 "-s sap Use SAP sap, sap may either be decimal or\n");
146 " hex proceeded by 0x common values are 0xfc\n");
148 " 0xf8 and 0xf4 the default is 0x%02x\n", RPL_SAP);
149 fprintf (stderr, "-h print this message\n");
159 unsigned char buf[MAX_FRAME_LEN];
160 struct llchdr *h = (struct llchdr *) buf;
163 char *if_name = DEF_IF;
164 char *config = CONFIG_FILE;
169 openlog ("rpld", LOG_PID, LOG_DAEMON);
174 while ((c = getopt (argc, argv, "C:i:s:fh")) != EOF)
185 if (!strncmp (optarg, "0x", 2))
187 rpl_sap = strtol (optarg + 2, NULL, 16);
191 rpl_sap = strtol (optarg, NULL, 10);
194 if ((rpl_sap <= 0) || (rpl_sap > 255))
197 "%s: argument to -s must be in range 1-255\n",
213 parse_config (config);
216 lld = llc_open (rpl_sap, if_name);
219 syslog (LOG_ERR, "failed to initalize llc layer");
223 if (lld->add_multicast)
225 lld->add_multicast (lld, RPL_MC_ADDR);
228 syslog (LOG_ERR, "my hw addr = %s", ethtoa (lld->mac (lld)));
229 gettimeofday (&last, NULL);
237 tv.tv_usec = pacing >> 1;
245 unsigned char smac[ETH_ALEN];
246 len = lld->recv (lld, buf, sizeof (buf), smac, NULL, &tv);
249 rpl_packet_recvd (lld, buf, len);
251 nit_read_packet (n, buf, sizeof (buf), &tv);
252 if ((len > LLC_HDR_LEN) && (ntohs (h->h_len) <= 1514))
253 { /*Short circuit most packets */
254 llc_recv (n, buf, len);
261 gettimeofday (&tv, NULL);
271 client_dispatch (lld);
272 gettimeofday (&last, NULL);