Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / usr.sbin / atm / atmarpd / atmarp_config.c
1 /*
2  *
3  * ===================================
4  * HARP  |  Host ATM Research Platform
5  * ===================================
6  *
7  *
8  * This Host ATM Research Platform ("HARP") file (the "Software") is
9  * made available by Network Computing Services, Inc. ("NetworkCS")
10  * "AS IS".  NetworkCS does not provide maintenance, improvements or
11  * support of any kind.
12  *
13  * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14  * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15  * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16  * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17  * In no event shall NetworkCS be responsible for any damages, including
18  * but not limited to consequential damages, arising from or relating to
19  * any use of the Software or related support.
20  *
21  * Copyright 1994-1998 Network Computing Services, Inc.
22  *
23  * Copies of this Software may be made, however, the above copyright
24  * notice must be reproduced on all copies.
25  *
26  *      @(#) $FreeBSD: src/usr.sbin/atm/atmarpd/atmarp_config.c,v 1.3 1999/08/28 01:15:29 peter Exp $
27  *      @(#) $DragonFly: src/usr.sbin/atm/atmarpd/atmarp_config.c,v 1.2 2003/06/17 04:29:52 dillon Exp $
28  */
29
30 /*
31  * Server Cache Synchronization Protocol (SCSP) Support
32  * ----------------------------------------------------
33  *
34  * SCSP-ATMARP server interface: configuration support
35  *
36  */
37
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <sys/socket.h>
41 #include <net/if.h>
42 #include <netinet/in.h>
43 #include <netatm/port.h>
44 #include <netatm/queue.h>
45 #include <netatm/atm.h>
46 #include <netatm/atm_if.h>
47 #include <netatm/atm_sap.h>
48 #include <netatm/atm_sys.h>
49 #include <netatm/atm_ioctl.h>
50  
51 #include <errno.h>
52 #include <libatm.h>
53 #include <stdio.h>
54 #include <stdlib.h>
55 #include <string.h>
56 #include <syslog.h>
57
58 #include "../scspd/scsp_msg.h"
59 #include "../scspd/scsp_if.h"
60 #include "../scspd/scsp_var.h"
61 #include "atmarp_var.h"
62
63 /*
64  * Configure network interface for ATMARP cache synchronization
65  *
66  * Verify the network interface name and set the appropriate fields
67  * in the ATMARP interface entry.
68  *
69  * Arguments:
70  *      netif   pointer to network interface name
71  *
72  * Returns:
73  *      0       success
74  *      errno   reason for failure
75  *
76  */
77 int
78 atmarp_cfg_netif(netif)
79         char    *netif;
80 {
81         int                     rc;
82         Atmarp_intf             *aip = (Atmarp_intf *)0;
83
84         /*
85          * Get an ATMARP interface block
86          */
87         aip = (Atmarp_intf *)UM_ALLOC(sizeof(Atmarp_intf));
88         if (!aip)
89                 atmarp_mem_err("atmarp_cfg_netif: sizeof(Atmarp_intf)");
90         UM_ZERO(aip, sizeof(Atmarp_intf));
91
92         /*
93          * Make sure we're configuring a valid
94          * network interface
95          */
96         rc = verify_nif_name(netif);
97         if (rc == 0) {
98                 fprintf(stderr, "%s: \"%s\" is not a valid network interface\n",
99                                 prog, netif);
100                 rc = EINVAL;
101                 goto cfg_fail;
102         } else if (rc < 0) {
103                 rc = errno;
104                 fprintf(stderr, "%s: can't verify network interface \"%s\"\n",
105                                 prog, netif);
106                 goto cfg_fail;
107         }
108
109         /*
110          * Update the interface entry
111          */
112         strcpy(aip->ai_intf, netif);
113         aip->ai_state = AI_STATE_NULL;
114         aip->ai_scsp_sock = -1;
115         LINK2TAIL(aip, Atmarp_intf, atmarp_intf_head, ai_next);
116
117         return(0);
118
119 cfg_fail:
120         if (aip)
121                 UM_FREE(aip);
122
123         return(rc);
124 }