178064Sume/* $KAME: ipsec_strerror.c,v 1.7 2000/07/30 00:45:12 itojun Exp $ */ 262583Sitojun 355505Sshin/* 455505Sshin * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. 555505Sshin * All rights reserved. 655505Sshin * 755505Sshin * Redistribution and use in source and binary forms, with or without 855505Sshin * modification, are permitted provided that the following conditions 955505Sshin * are met: 1055505Sshin * 1. Redistributions of source code must retain the above copyright 1155505Sshin * notice, this list of conditions and the following disclaimer. 1255505Sshin * 2. Redistributions in binary form must reproduce the above copyright 1355505Sshin * notice, this list of conditions and the following disclaimer in the 1455505Sshin * documentation and/or other materials provided with the distribution. 1555505Sshin * 3. Neither the name of the project nor the names of its contributors 1655505Sshin * may be used to endorse or promote products derived from this software 1755505Sshin * without specific prior written permission. 1855505Sshin * 1955505Sshin * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 2055505Sshin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2155505Sshin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2255505Sshin * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2355505Sshin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2455505Sshin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2555505Sshin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2655505Sshin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2755505Sshin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2855505Sshin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2955505Sshin * SUCH DAMAGE. 3055505Sshin */ 3155505Sshin 3284208Sdillon#include <sys/cdefs.h> 3384208Sdillon__FBSDID("$FreeBSD$"); 3484208Sdillon 3555505Sshin#include <sys/types.h> 3655505Sshin#include <sys/param.h> 3755505Sshin 3855505Sshin#include <string.h> 39171135Sgnn#include <netipsec/ipsec.h> 4055505Sshin 4155505Sshin#include "ipsec_strerror.h" 4255505Sshin 4362583Sitojunint __ipsec_errcode; 4455505Sshin 4578064Sumestatic const char *ipsec_errlist[] = { 4655505Sshin"Success", /*EIPSEC_NO_ERROR*/ 4755505Sshin"Not supported", /*EIPSEC_NOT_SUPPORTED*/ 4855505Sshin"Invalid argument", /*EIPSEC_INVAL_ARGUMENT*/ 4955505Sshin"Invalid sadb message", /*EIPSEC_INVAL_SADBMSG*/ 5055505Sshin"Invalid version", /*EIPSEC_INVAL_VERSION*/ 5155505Sshin"Invalid security policy", /*EIPSEC_INVAL_POLICY*/ 5255505Sshin"Invalid address specification", /*EIPSEC_INVAL_ADDRESS*/ 5355505Sshin"Invalid ipsec protocol", /*EIPSEC_INVAL_PROTO*/ 5455505Sshin"Invalid ipsec mode", /*EIPSEC_INVAL_MODE*/ 5555505Sshin"Invalid ipsec level", /*EIPSEC_INVAL_LEVEL*/ 5655505Sshin"Invalid SA type", /*EIPSEC_INVAL_SATYPE*/ 5755505Sshin"Invalid message type", /*EIPSEC_INVAL_MSGTYPE*/ 5855505Sshin"Invalid extension type", /*EIPSEC_INVAL_EXTTYPE*/ 5955505Sshin"Invalid algorithm type", /*EIPSEC_INVAL_ALGS*/ 6055505Sshin"Invalid key length", /*EIPSEC_INVAL_KEYLEN*/ 6155505Sshin"Invalid address family", /*EIPSEC_INVAL_FAMILY*/ 6255505Sshin"Invalid prefix length", /*EIPSEC_INVAL_PREFIXLEN*/ 6355505Sshin"Invalid direciton", /*EIPSEC_INVAL_DIR*/ 6455505Sshin"SPI range violation", /*EIPSEC_INVAL_SPI*/ 6555505Sshin"No protocol specified", /*EIPSEC_NO_PROTO*/ 6655505Sshin"No algorithm specified", /*EIPSEC_NO_ALGS*/ 6755505Sshin"No buffers available", /*EIPSEC_NO_BUFS*/ 6855505Sshin"Must get supported algorithms list first", /*EIPSEC_DO_GET_SUPP_LIST*/ 6955505Sshin"Protocol mismatch", /*EIPSEC_PROTO_MISMATCH*/ 7055505Sshin"Family mismatch", /*EIPSEC_FAMILY_MISMATCH*/ 7155505Sshin"Too few arguments", /*EIPSEC_FEW_ARGUMENTS*/ 7255505SshinNULL, /*EIPSEC_SYSTEM_ERROR*/ 7355505Sshin"Unknown error", /*EIPSEC_MAX*/ 7455505Sshin}; 7555505Sshin 7678064Sumeconst char *ipsec_strerror(void) 7755505Sshin{ 7862583Sitojun if (__ipsec_errcode < 0 || __ipsec_errcode > EIPSEC_MAX) 7962583Sitojun __ipsec_errcode = EIPSEC_MAX; 8055505Sshin 8162583Sitojun return ipsec_errlist[__ipsec_errcode]; 8255505Sshin} 8355505Sshin 8478064Sumevoid __ipsec_set_strerror(const char *str) 8555505Sshin{ 8662583Sitojun __ipsec_errcode = EIPSEC_SYSTEM_ERROR; 8755505Sshin ipsec_errlist[EIPSEC_SYSTEM_ERROR] = str; 8855505Sshin 8955505Sshin return; 9055505Sshin} 91