Deleted Added
full compact
main.c (11820) main.c (11840)
1/*
2 * Copyright (c) 1985, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Copyright (c) 1995 John Hay. All rights reserved.
6 *
7 * This file includes significant work done at Cornell University by
8 * Bill Nesheim. That work included by permission.

--- 21 unchanged lines hidden (view full) ---

30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
1/*
2 * Copyright (c) 1985, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Copyright (c) 1995 John Hay. All rights reserved.
6 *
7 * This file includes significant work done at Cornell University by
8 * Bill Nesheim. That work included by permission.

--- 21 unchanged lines hidden (view full) ---

30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * $Id: main.c,v 1.6 1995/10/11 18:57:21 jhay Exp $
38 * $Id: main.c,v 1.1 1995/10/26 21:28:19 julian Exp $
39 */
40
41#ifndef lint
42static char copyright[] =
43"@(#) Copyright (c) 1985, 1993\n\
44 The Regents of the University of California. All rights reserved.\n";
45#endif /* not lint */
46

--- 27 unchanged lines hidden (view full) ---

74int lookforinterfaces; /* if 1 probe kernel for new up interfaces */
75int performnlist; /* if 1 check if /kernel has changed */
76int externalinterfaces; /* # of remote and local interfaces */
77int timeval; /* local idea of time */
78int noteremoterequests; /* squawk on requests from non-local nets */
79int r; /* Routing socket to install updates with */
80struct sockaddr_ipx ipx_netmask; /* Used in installing routes */
81
39 */
40
41#ifndef lint
42static char copyright[] =
43"@(#) Copyright (c) 1985, 1993\n\
44 The Regents of the University of California. All rights reserved.\n";
45#endif /* not lint */
46

--- 27 unchanged lines hidden (view full) ---

74int lookforinterfaces; /* if 1 probe kernel for new up interfaces */
75int performnlist; /* if 1 check if /kernel has changed */
76int externalinterfaces; /* # of remote and local interfaces */
77int timeval; /* local idea of time */
78int noteremoterequests; /* squawk on requests from non-local nets */
79int r; /* Routing socket to install updates with */
80struct sockaddr_ipx ipx_netmask; /* Used in installing routes */
81
82char packet[MAXPACKETSIZE+sizeof(struct ipxdp)+1];
82char packet[MAXPACKETSIZE+sizeof(struct ipx)+1];
83
84char **argv0;
85
86int supplier = -1; /* process should supply updates */
87int dosap = 1; /* By default do SAP services. */
88
83
84char **argv0;
85
86int supplier = -1; /* process should supply updates */
87int dosap = 1; /* By default do SAP services. */
88
89struct rip *msg = (struct rip *) &packet[sizeof (struct ipxdp)];
89struct rip *msg = (struct rip *) &packet[sizeof (struct ipx)];
90struct sap_packet *sap_msg =
90struct sap_packet *sap_msg =
91 (struct sap_packet *) &packet[sizeof (struct ipxdp)];
91 (struct sap_packet *) &packet[sizeof (struct ipx)];
92void hup(), fkexit(), timer();
93void process(int fd, int pkt_type);
94int getsocket(int type, int proto, struct sockaddr_ipx *sipx);
95
96int
97main(argc, argv)
98 int argc;
99 char *argv[];

--- 143 unchanged lines hidden (view full) ---

243
244void
245process(fd, pkt_type)
246 int fd;
247 int pkt_type;
248{
249 struct sockaddr from;
250 int fromlen = sizeof (from), cc, omask;
92void hup(), fkexit(), timer();
93void process(int fd, int pkt_type);
94int getsocket(int type, int proto, struct sockaddr_ipx *sipx);
95
96int
97main(argc, argv)
98 int argc;
99 char *argv[];

--- 143 unchanged lines hidden (view full) ---

243
244void
245process(fd, pkt_type)
246 int fd;
247 int pkt_type;
248{
249 struct sockaddr from;
250 int fromlen = sizeof (from), cc, omask;
251 struct ipxdp *ipxdp = (struct ipxdp *)packet;
251 struct ipx *ipxdp = (struct ipx *)packet;
252
253 cc = recvfrom(fd, packet, sizeof (packet), 0, &from, &fromlen);
254 if (cc <= 0) {
255 if (cc < 0 && errno != EINTR)
256 syslog(LOG_ERR, "recvfrom: %m");
257 return;
258 }
259 if (tracepackets > 1 && ftrace) {
260 fprintf(ftrace,"rcv %d bytes on %s ",
252
253 cc = recvfrom(fd, packet, sizeof (packet), 0, &from, &fromlen);
254 if (cc <= 0) {
255 if (cc < 0 && errno != EINTR)
256 syslog(LOG_ERR, "recvfrom: %m");
257 return;
258 }
259 if (tracepackets > 1 && ftrace) {
260 fprintf(ftrace,"rcv %d bytes on %s ",
261 cc, ipxdp_ntoa(&ipxdp->ipxdp_dna));
262 fprintf(ftrace," from %s\n", ipxdp_ntoa(&ipxdp->ipxdp_sna));
261 cc, ipxdp_ntoa(&ipxdp->ipx_dna));
262 fprintf(ftrace," from %s\n", ipxdp_ntoa(&ipxdp->ipx_sna));
263 }
264
265 if (noteremoterequests &&
263 }
264
265 if (noteremoterequests &&
266 !ipx_neteqnn(ipxdp->ipxdp_sna.x_net, ipx_zeronet) &&
267 !ipx_neteq(ipxdp->ipxdp_sna, ipxdp->ipxdp_dna))
266 !ipx_neteqnn(ipxdp->ipx_sna.x_net, ipx_zeronet) &&
267 !ipx_neteq(ipxdp->ipx_sna, ipxdp->ipx_dna))
268 {
269 syslog(LOG_ERR,
270 "net of interface (%s) != net on ether (%s)!\n",
268 {
269 syslog(LOG_ERR,
270 "net of interface (%s) != net on ether (%s)!\n",
271 ipxdp_nettoa(ipxdp->ipxdp_dna.x_net),
272 ipxdp_nettoa(ipxdp->ipxdp_sna.x_net));
271 ipxdp_nettoa(ipxdp->ipx_dna.x_net),
272 ipxdp_nettoa(ipxdp->ipx_sna.x_net));
273 }
274
275 /* We get the IPX header in front of the RIF packet*/
273 }
274
275 /* We get the IPX header in front of the RIF packet*/
276 cc -= sizeof (struct ipxdp);
276 cc -= sizeof (struct ipx);
277#define mask(s) (1<<((s)-1))
278 omask = sigblock(mask(SIGALRM));
279 switch(pkt_type) {
280 case SAP_PKT: sap_input(&from, cc);
281 break;
282 case RIP_PKT: rip_input(&from, cc);
283 break;
284 }

--- 19 unchanged lines hidden (view full) ---

304 while (bind(s, (struct sockaddr *)sipx, sizeof (*sipx)) < 0 && retry) {
305 syslog(LOG_ERR, "bind: %m");
306 sleep(5 * retry);
307 retry <<= 1;
308 }
309 if (retry == 0)
310 return (-1);
311 if (domain==AF_IPX) {
277#define mask(s) (1<<((s)-1))
278 omask = sigblock(mask(SIGALRM));
279 switch(pkt_type) {
280 case SAP_PKT: sap_input(&from, cc);
281 break;
282 case RIP_PKT: rip_input(&from, cc);
283 break;
284 }

--- 19 unchanged lines hidden (view full) ---

304 while (bind(s, (struct sockaddr *)sipx, sizeof (*sipx)) < 0 && retry) {
305 syslog(LOG_ERR, "bind: %m");
306 sleep(5 * retry);
307 retry <<= 1;
308 }
309 if (retry == 0)
310 return (-1);
311 if (domain==AF_IPX) {
312 struct ipxdp ipxdp;
312 struct ipx ipxdp;
313 if (setsockopt(s, 0, SO_HEADERS_ON_INPUT, &on, sizeof(on))) {
314 syslog(LOG_ERR, "setsockopt SEE HEADERS: %m");
315 exit(1);
316 }
317 if (ntohs(sipx->sipx_addr.x_port) == IPXPORT_RIP)
313 if (setsockopt(s, 0, SO_HEADERS_ON_INPUT, &on, sizeof(on))) {
314 syslog(LOG_ERR, "setsockopt SEE HEADERS: %m");
315 exit(1);
316 }
317 if (ntohs(sipx->sipx_addr.x_port) == IPXPORT_RIP)
318 ipxdp.ipxdp_pt = IPXPROTO_RI;
318 ipxdp.ipx_pt = IPXPROTO_RI;
319 else if (ntohs(sipx->sipx_addr.x_port) == IPXPORT_SAP)
319 else if (ntohs(sipx->sipx_addr.x_port) == IPXPORT_SAP)
320 ipxdp.ipxdp_pt = IPXPROTO_SAP;
320 ipxdp.ipx_pt = IPXPROTO_SAP;
321 else {
322 syslog(LOG_ERR, "port should be either RIP or SAP");
323 exit(1);
324 }
325 if (setsockopt(s, 0, SO_DEFAULT_HEADERS, &ipxdp, sizeof(ipxdp))) {
326 syslog(LOG_ERR, "setsockopt SET HEADER: %m");
327 exit(1);
328 }

--- 17 unchanged lines hidden ---
321 else {
322 syslog(LOG_ERR, "port should be either RIP or SAP");
323 exit(1);
324 }
325 if (setsockopt(s, 0, SO_DEFAULT_HEADERS, &ipxdp, sizeof(ipxdp))) {
326 syslog(LOG_ERR, "setsockopt SET HEADER: %m");
327 exit(1);
328 }

--- 17 unchanged lines hidden ---