X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=userapps%2Fopensource%2Fipsec-tools%2Fsrc%2Fracoon%2Fisakmp_unity.c;fp=userapps%2Fopensource%2Fipsec-tools%2Fsrc%2Fracoon%2Fisakmp_unity.c;h=472799bf875484965d9283222e9ab0d185be6107;hb=864458111a0e69d94bbae210d5b7349ca072a6b7;hp=0000000000000000000000000000000000000000;hpb=57a096f051259ceaefd5977f30d269884e1dd248;p=bcm963xx.git diff --git a/userapps/opensource/ipsec-tools/src/racoon/isakmp_unity.c b/userapps/opensource/ipsec-tools/src/racoon/isakmp_unity.c new file mode 100755 index 00000000..472799bf --- /dev/null +++ b/userapps/opensource/ipsec-tools/src/racoon/isakmp_unity.c @@ -0,0 +1,167 @@ +/* $Id: isakmp_unity.c,v 1.5 2004/11/09 15:56:00 ludvigm Exp $ */ + +/* + * Copyright (C) 2004 Emmanuel Dreyfus + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "config.h" + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#include + +#include "var.h" +#include "misc.h" +#include "vmbuf.h" +#include "plog.h" +#include "sockmisc.h" +#include "schedule.h" +#include "debug.h" + +#include "isakmp_var.h" +#include "isakmp.h" +#include "handler.h" +#include "isakmp_xauth.h" +#include "isakmp_unity.h" +#include "isakmp_cfg.h" +#include "strnames.h" + +vchar_t * +isakmp_unity_req(iph1, attr) + struct ph1handle *iph1; + struct isakmp_data *attr; +{ + int type; + vchar_t *reply_attr = NULL; + + if ((iph1->mode_cfg->flags & ISAKMP_CFG_VENDORID_UNITY) == 0) { + plog(LLV_ERROR, LOCATION, NULL, + "Unity mode config request but the peer " + "did not declare itself as unity compliant\n"); + return NULL; + } + + type = ntohs(attr->type); + + /* Handle short attributes */ + if ((type & ISAKMP_GEN_MASK) == ISAKMP_GEN_TV) { + type &= ~ISAKMP_GEN_MASK; + + plog(LLV_DEBUG, LOCATION, NULL, + "Short attribute %d = %d\n", + type, ntohs(attr->lorv)); + + switch (type) { + default: + plog(LLV_DEBUG, LOCATION, NULL, + "Ignored short attribute %d\n", type); + break; + } + + return reply_attr; + } + + switch(type) { + case UNITY_BANNER: { +#define MAXMOTD 65536 + char buf[MAXMOTD + 1]; + int fd; + char *filename = &isakmp_cfg_config.motd[0]; + size_t len; + + if ((fd = open(filename, O_RDONLY, 0)) == -1) { + plog(LLV_ERROR, LOCATION, NULL, + "Cannot open \"%s\"\n", filename); + return NULL; + } + + if ((len = read(fd, buf, MAXMOTD)) == -1) { + plog(LLV_ERROR, LOCATION, NULL, + "Cannot read \"%s\"\n", filename); + close(fd); + return NULL; + } + close(fd); + + buf[len] = '\0'; + reply_attr = isakmp_cfg_string(iph1, attr, buf); + + break; + } + + case UNITY_PFS: + case UNITY_SAVE_PASSWD: + reply_attr = isakmp_cfg_short(iph1, attr, 0); + break; + + case UNITY_DDNS_HOSTNAME: + reply_attr = isakmp_cfg_copy(iph1, attr); + break; + + case UNITY_DEF_DOMAIN: + case UNITY_FW_TYPE: + case UNITY_SPLITDNS_NAME: + case UNITY_SPLIT_INCLUDE: + case UNITY_NATT_PORT: + case UNITY_BACKUP_SERVERS: + default: + plog(LLV_DEBUG, LOCATION, NULL, + "Ignored attribute %d\n", type); + return NULL; + break; + } + + return reply_attr; +} + +