enable -fno-strict-aliasing until the code base gets a hefty clean up to fix all...
[platform/upstream/net-tools.git] / lib / activate.c
1 /*
2  * lib/activate.c     This file contains a small interface function to
3  *                      use the HW specific activate routines for line
4  *                      disciplines
5  *
6  * NET-LIB      A collection of functions used from the base set of the
7  *              NET-3 Networking Distribution for the LINUX operating
8  *              system. (net-tools, net-drivers)
9  *
10  * Version:     $Id: activate.c,v 1.3 1998/11/15 20:08:55 freitag Exp $
11  *
12  * Author:      Bernd 'eckes' Eckenfels <net-tools@lina.inka.de>
13  *              Copyright 1996 Bernd Eckenfels, Germany
14  *
15  * Modifications:
16  *
17  *960322 {0.01} Bernd Eckenfels:        creation
18  *980411 {0.01i} Arnaldo Carvalho:      i18n: now uses gettext
19  *
20  *              This program is free software; you can redistribute it
21  *              and/or  modify it under  the terms of  the GNU General
22  *              Public  License as  published  by  the  Free  Software
23  *              Foundation;  either  version 2 of the License, or  (at
24  *              your option) any later version.
25  */
26 #include <stdio.h>
27 #include <string.h>
28 #include "net-support.h"
29 #include "pathnames.h"
30 #include "version.h"
31 #include "config.h"
32 #include "intl.h"
33
34 extern struct hwtype slip_hwtype;
35 extern struct hwtype cslip_hwtype;
36 extern struct hwtype slip6_hwtype;
37 extern struct hwtype cslip6_hwtype;
38 extern struct hwtype adaptive_hwtype;
39 extern struct hwtype ppp_hwtype;
40
41 extern int SLIP_activate(int fd);
42 extern int CSLIP_activate(int fd);
43 extern int SLIP6_activate(int fd);
44 extern int CSLIP6_activate(int fd);
45 extern int ADAPTIVE_activate(int fd);
46 extern int PPP_activate(int fd);
47
48 void activate_init(void)
49 {
50 #if HAVE_HWSLIP
51     slip_hwtype.activate = SLIP_activate;
52     cslip_hwtype.activate = CSLIP_activate;
53     slip6_hwtype.activate = SLIP6_activate;
54     cslip6_hwtype.activate = CSLIP6_activate;
55     adaptive_hwtype.activate = ADAPTIVE_activate;
56 #endif
57 #if HAVE_HWPPP
58     ppp_hwtype.activate = PPP_activate;
59 #endif
60 }
61
62 int activate_ld(const char *hwname, int fd)
63 {
64     struct hwtype *hw;
65
66     hw = get_hwtype(hwname);
67
68     if (!hw) {
69         fprintf(stderr, _("Hardware type `%s' not supported.\n"), hwname);
70         return (E_NOSUPP);
71     }
72     if (!hw->activate) {
73         fprintf(stderr, _("Cannot change line discipline to `%s'.\n"), hw->name);
74         return (E_OPTERR);
75     }
76     return (hw->activate(fd));
77 }