/* tsaperror.c - print out TPKT error codes */

#ifndef	lint
static char *rcsid = "$Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/tsap/tsaperror.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $";
#endif

/* 
 * $Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/tsap/tsaperror.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $
 *
 *
 * $Log: tsaperror.c,v $
 * Revision 1.1.1.1  2018/04/24 16:12:56  root
 * BSD 4.3reno
 *
 * Revision 7.0  89/11/23  22:30:43  mrose
 * Release 6.0
 * 
 */

/*
 *				  NOTICE
 *
 *    Acquisition, use, and distribution of this module and related
 *    materials are subject to the restrictions of a license agreement.
 *    Consult the Preface in the User's Manual for the full terms of
 *    this agreement.
 *
 */


/* LINTLIBRARY */

#include <stdio.h>
#include "tsap.h"

/*  */

static char *disc_err0[] = {
    "Reason not specified",
    "Congestion at TSAP",
    "Session entity not attached to TSAP",
    "Address unknown"
};

static int  disc_err0_cnt = sizeof disc_err0 / sizeof disc_err0[0];


static char *disc_err8[] = {
    "Normal disconnect initiated by session entity",
    "Remote transport entity congestion at connect time",
    "Connection negotiation failed (proposed class(es) not supported)",
    "Duplicate source reference detected for the same pair of NSAPs",
    "Mismatched references",
    "Protocol error",
    "Not used",
    "Reference overflow",
    "Connect request refused on this network connection",
    "Not used",
    "Header or parameter length invalid",
    "Network disconnect",
    "Invalid parameter",
    "Invalid operation",
    "Timer expired",
    "Indications waiting"
};

static int  disc_err8_cnt = sizeof disc_err8 / sizeof disc_err8[0];

/*  */

char *TErrString(code)
register int	code;
{
    register int    fcode;
    static char buffer[BUFSIZ];

    code &= 0xff;
    if (code & DR_BASE) {
	if ((fcode = code & ~DR_BASE) < disc_err8_cnt)
	    return disc_err8[fcode];
    }
    else
	if (code < disc_err0_cnt)
	    return disc_err0[code];

    (void) sprintf (buffer, "unknown error code 0x%x", code);
    return buffer;
}
