Maik Broemme contributed gcc warning fixes (break after default: label)
[oss-qm-packages.git] / lib / slip_ac.c
blobc48937b98b4171e1b2967588fd8256e99d269e5b
1 /*
2 * lib/slip_ac.c This file contains the activation for the
3 * SLIP line disciplines, called from activate_ld().
5 * Version: $Id: slip_ac.c,v 1.3 1998/11/15 20:12:20 freitag Exp $
7 * Author: Bernd 'eckes' Eckenfels
8 * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
9 * Copyright 1993 MicroWalt Corporation
11 * Modified by Alan Cox, May 94 to cover NET-3
13 * This program is free software; you can redistribute it
14 * and/or modify it under the terms of the GNU General
15 * Public License as published by the Free Software
16 * Foundation; either version 2 of the License, or (at
17 * your option) any later version.
19 #include "config.h"
21 #if HAVE_HWSLIP
23 #include <sys/types.h>
24 #include <sys/ioctl.h>
25 #include <sys/socket.h>
26 #include <net/if_arp.h>
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <ctype.h>
30 #include <errno.h>
31 #include <fcntl.h>
32 #include <string.h>
33 #include <termios.h>
34 #include <unistd.h>
35 #include "net-support.h"
36 #include "pathnames.h"
39 /* Set the line discipline of a terminal line. */
40 static int SLIP_set_disc(int fd, int disc)
42 if (ioctl(fd, TIOCSETD, &disc) < 0) {
43 fprintf(stderr, "SLIP_set_disc(%d): %s\n", disc, strerror(errno));
44 return (-errno);
46 return (0);
50 /* Set the encapsulation type of a terminal line. */
51 static int SLIP_set_encap(int fd, int encap)
53 if (ioctl(fd, SIOCSIFENCAP, &encap) < 0) {
54 fprintf(stderr, "SLIP_set_encap(%d): %s\n", encap, strerror(errno));
55 return (-errno);
57 return (0);
61 /* Start the SLIP encapsulation on the file descriptor. */
62 int SLIP_activate(int fd)
64 if (SLIP_set_disc(fd, N_SLIP) < 0)
65 return (-1);
66 if (SLIP_set_encap(fd, 0) < 0)
67 return (-1);
68 return (0);
72 /* Start the VJ-SLIP encapsulation on the file descriptor. */
73 int CSLIP_activate(int fd)
75 if (SLIP_set_disc(fd, N_SLIP) < 0)
76 return (-1);
77 if (SLIP_set_encap(fd, 1) < 0)
78 return (-1);
79 return (0);
83 /* Start the SLIP-6 encapsulation on the file descriptor. */
84 int SLIP6_activate(int fd)
86 if (SLIP_set_disc(fd, N_SLIP) < 0)
87 return (-1);
88 if (SLIP_set_encap(fd, 2) < 0)
89 return (-1);
90 return (0);
94 /* Start the VJ-SLIP-6 encapsulation on the file descriptor. */
95 int CSLIP6_activate(int fd)
97 if (SLIP_set_disc(fd, N_SLIP) < 0)
98 return (-1);
99 if (SLIP_set_encap(fd, 3) < 0)
100 return (-1);
101 return (0);
105 /* Start adaptive encapsulation on the file descriptor. */
106 int ADAPTIVE_activate(int fd)
108 if (SLIP_set_disc(fd, N_SLIP) < 0)
109 return (-1);
110 if (SLIP_set_encap(fd, 8) < 0)
111 return (-1);
112 return (0);
114 #endif /* HAVE_HWSLIP */