1 /* $Id: isakmp_unity.c,v 1.5 2004/11/09 15:56:00 ludvigm Exp $ */
4 * Copyright (C) 2004 Emmanuel Dreyfus
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <sys/types.h>
35 #include <sys/param.h>
36 #include <sys/socket.h>
37 #include <sys/queue.h>
39 #include <netinet/in.h>
40 #include <arpa/inet.h>
47 #if TIME_WITH_SYS_TIME
48 # include <sys/time.h>
52 # include <sys/time.h>
71 #include "isakmp_var.h"
74 #include "isakmp_xauth.h"
75 #include "isakmp_unity.h"
76 #include "isakmp_cfg.h"
80 isakmp_unity_req(iph1, attr)
81 struct ph1handle *iph1;
82 struct isakmp_data *attr;
85 vchar_t *reply_attr = NULL;
87 if ((iph1->mode_cfg->flags & ISAKMP_CFG_VENDORID_UNITY) == 0) {
88 plog(LLV_ERROR, LOCATION, NULL,
89 "Unity mode config request but the peer "
90 "did not declare itself as unity compliant\n");
94 type = ntohs(attr->type);
96 /* Handle short attributes */
97 if ((type & ISAKMP_GEN_MASK) == ISAKMP_GEN_TV) {
98 type &= ~ISAKMP_GEN_MASK;
100 plog(LLV_DEBUG, LOCATION, NULL,
101 "Short attribute %d = %d\n",
102 type, ntohs(attr->lorv));
106 plog(LLV_DEBUG, LOCATION, NULL,
107 "Ignored short attribute %d\n", type);
116 #define MAXMOTD 65536
117 char buf[MAXMOTD + 1];
119 char *filename = &isakmp_cfg_config.motd[0];
122 if ((fd = open(filename, O_RDONLY, 0)) == -1) {
123 plog(LLV_ERROR, LOCATION, NULL,
124 "Cannot open \"%s\"\n", filename);
128 if ((len = read(fd, buf, MAXMOTD)) == -1) {
129 plog(LLV_ERROR, LOCATION, NULL,
130 "Cannot read \"%s\"\n", filename);
137 reply_attr = isakmp_cfg_string(iph1, attr, buf);
143 case UNITY_SAVE_PASSWD:
144 reply_attr = isakmp_cfg_short(iph1, attr, 0);
147 case UNITY_DDNS_HOSTNAME:
148 reply_attr = isakmp_cfg_copy(iph1, attr);
151 case UNITY_DEF_DOMAIN:
153 case UNITY_SPLITDNS_NAME:
154 case UNITY_SPLIT_INCLUDE:
155 case UNITY_NATT_PORT:
156 case UNITY_BACKUP_SERVERS:
158 plog(LLV_DEBUG, LOCATION, NULL,
159 "Ignored attribute %d\n", type);