Virgin import of the NgATM SAAL layer shared kernel/user part v0.9.

This commit is contained in:
Hartmut Brandt 2003-10-22 07:41:16 +00:00
commit 8711ce79a7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor-sys/ngatm/dist/; revision=121326
10 changed files with 6498 additions and 0 deletions

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2003-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/misc/unimsg_common.c,v 1.2 2003/09/19 12:05:45 hbb Exp $
*/
#include <netnatm/unimsg.h>
/*
* Make sure there is enough space in front of the data for
* len bytes, and update the read pointer.
*/
int
uni_msg_prepend(struct uni_msg *msg, size_t len)
{
size_t need;
if (uni_msg_leading(msg) >= len) {
msg->b_rptr -= len;
return (0);
}
need = len - uni_msg_leading(msg);
if (uni_msg_ensure(msg, need))
return (-1);
memcpy(msg->b_rptr + need, msg->b_rptr, uni_msg_len(msg));
msg->b_rptr += need - len;
msg->b_wptr += need;
return (0);
}

View File

@ -0,0 +1,577 @@
/*
* Copyright (c) 1996-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/saal_sscfu.c,v 1.3 2003/09/19 12:02:03 hbb Exp $
*
* SSCF on the UNI
*/
#include <netnatm/saal/sscfu.h>
#include <netnatm/saal/sscfupriv.h>
#define MKSTR(S) #S
static const char *const sscf_sigs[] = {
MKSTR(SAAL_ESTABLISH_request),
MKSTR(SAAL_ESTABLISH_indication),
MKSTR(SAAL_ESTABLISH_confirm),
MKSTR(SAAL_RELEASE_request),
MKSTR(SAAL_RELEASE_confirm),
MKSTR(SAAL_RELEASE_indication),
MKSTR(SAAL_DATA_request),
MKSTR(SAAL_DATA_indication),
MKSTR(SAAL_UDATA_request),
MKSTR(SAAL_UDATA_indication),
};
static const char *const sscf_states[] = {
MKSTR(SSCF_RELEASED),
MKSTR(SSCF_AWAITING_ESTABLISH),
MKSTR(SSCF_AWAITING_RELEASE),
MKSTR(SSCF_ESTABLISHED),
MKSTR(SSCF_RESYNC),
};
#define AA_SIG(S,G,M) \
((S)->funcs->send_upper((S), (S)->aarg, (G), (M)))
#define SSCOP_AASIG(S,G,M,P) \
((S)->funcs->send_lower((S), (S)->aarg, (G), (M), (P)))
MEMINIT();
static void sscfu_unqueue(struct sscfu *sscf);
/************************************************************/
/*
* INSTANCE AND CLASS MANAGEMENT
*/
/*
* Initialize SSCF.
*/
struct sscfu *
sscfu_create(void *a, const struct sscfu_funcs *funcs)
{
struct sscfu *sscf;
MEMZALLOC(sscf, struct sscfu *, sizeof(struct sscfu));
if (sscf == NULL)
return (NULL);
sscf->funcs = funcs;
sscf->aarg = a;
sscf->state = SSCFU_RELEASED;
sscf->inhand = 0;
SIGQ_INIT(&sscf->sigs);
sscf->debug = 0;
return (sscf);
}
/*
* Reset the instance. Call only if you know, what you're doing.
*/
void
sscfu_reset(struct sscfu *sscf)
{
sscf->state = SSCFU_RELEASED;
sscf->inhand = 0;
SIGQ_CLEAR(&sscf->sigs);
}
/*
* Destroy SSCF
*/
void
sscfu_destroy(struct sscfu *sscf)
{
SIGQ_CLEAR(&sscf->sigs);
MEMFREE(sscf);
}
enum sscfu_state
sscfu_getstate(const struct sscfu *sscf)
{
return (sscf->state);
}
u_int
sscfu_getdefparam(struct sscop_param *p)
{
memset(p, 0, sizeof(*p));
p->timer_cc = 1000;
p->timer_poll = 750;
p->timer_keep_alive = 2000;
p->timer_no_response = 7000;
p->timer_idle = 15000;
p->maxk = 4096;
p->maxj = 4096;
p->maxcc = 4;
p->maxpd = 25;
return (SSCOP_SET_TCC | SSCOP_SET_TPOLL | SSCOP_SET_TKA |
SSCOP_SET_TNR | SSCOP_SET_TIDLE | SSCOP_SET_MAXK |
SSCOP_SET_MAXJ | SSCOP_SET_MAXCC | SSCOP_SET_MAXPD);
}
const char *
sscfu_signame(enum saal_sig sig)
{
static char str[40];
if (sig >= sizeof(sscf_sigs)/sizeof(sscf_sigs[0])) {
sprintf(str, "BAD SAAL_SIGNAL %u", sig);
return (str);
} else {
return (sscf_sigs[sig]);
}
}
const char *
sscfu_statename(enum sscfu_state s)
{
static char str[40];
if (s >= sizeof(sscf_states)/sizeof(sscf_states[0])) {
sprintf(str, "BAD SSCFU state %u", s);
return (str);
} else {
return (sscf_states[s]);
}
}
/************************************************************/
/*
* EXTERNAL INPUT SIGNAL MAPPING
*/
static __inline void
set_state(struct sscfu *sscf, enum sscfu_state state)
{
VERBOSE(sscf, SSCFU_DBG_STATE, (sscf, sscf->aarg,
"change state from %s to %s",
sscf_states[sscf->state], sscf_states[state]));
sscf->state = state;
}
/*
* signal from SSCOP to SSCF
* Message must be freed by the user specified handler, if
* it is passed.
*/
void
sscfu_input(struct sscfu *sscf, enum sscop_aasig sig,
struct SSCFU_MBUF_T *m, u_int arg __unused)
{
sscf->inhand = 1;
VERBOSE(sscf, SSCFU_DBG_LSIG, (sscf, sscf->aarg,
"SSCF got signal %d. in state %s", sig, sscf_states[sscf->state]));
switch (sig) {
case SSCOP_RELEASE_indication:
/* arg is: UU, SRC */
switch (sscf->state) {
case SSCFU_RELEASED:
if (m)
MBUF_FREE(m);
goto badsig;
case SSCFU_AWAITING_ESTABLISH:
set_state(sscf, SSCFU_RELEASED);
AA_SIG(sscf, SAAL_RELEASE_indication, m);
break;
case SSCFU_AWAITING_RELEASE:
if (m)
MBUF_FREE(m);
goto badsig;
case SSCFU_ESTABLISHED:
set_state(sscf, SSCFU_RELEASED);
AA_SIG(sscf, SAAL_RELEASE_indication, m);
break;
case SSCFU_RESYNC:
set_state(sscf, SSCFU_RELEASED);
AA_SIG(sscf, SAAL_RELEASE_indication, m);
break;
}
break;
case SSCOP_ESTABLISH_indication:
/* arg is: UU */
switch (sscf->state) {
case SSCFU_RELEASED:
set_state(sscf, SSCFU_ESTABLISHED);
SSCOP_AASIG(sscf, SSCOP_ESTABLISH_response, NULL, 1);
AA_SIG(sscf, SAAL_ESTABLISH_indication, m);
break;
case SSCFU_AWAITING_ESTABLISH:
case SSCFU_AWAITING_RELEASE:
case SSCFU_ESTABLISHED:
case SSCFU_RESYNC:
if (m)
MBUF_FREE(m);
goto badsig;
}
break;
case SSCOP_ESTABLISH_confirm:
/* arg is: UU */
switch (sscf->state) {
case SSCFU_RELEASED:
if (m)
MBUF_FREE(m);
goto badsig;
case SSCFU_AWAITING_ESTABLISH:
set_state(sscf, SSCFU_ESTABLISHED);
AA_SIG(sscf, SAAL_ESTABLISH_confirm, m);
break;
case SSCFU_AWAITING_RELEASE:
case SSCFU_ESTABLISHED:
case SSCFU_RESYNC:
if (m)
MBUF_FREE(m);
goto badsig;
}
break;
case SSCOP_RELEASE_confirm:
/* arg is: */
switch (sscf->state) {
case SSCFU_RELEASED:
case SSCFU_AWAITING_ESTABLISH:
goto badsig;
case SSCFU_AWAITING_RELEASE:
set_state(sscf, SSCFU_RELEASED);
AA_SIG(sscf, SAAL_RELEASE_confirm, NULL);
break;
case SSCFU_ESTABLISHED:
case SSCFU_RESYNC:
goto badsig;
}
break;
case SSCOP_DATA_indication:
/* arg is: MU */
sscf->funcs->window(sscf, sscf->aarg, 1);
switch (sscf->state) {
case SSCFU_RELEASED:
case SSCFU_AWAITING_ESTABLISH:
case SSCFU_AWAITING_RELEASE:
MBUF_FREE(m);
goto badsig;
case SSCFU_ESTABLISHED:
AA_SIG(sscf, SAAL_DATA_indication, m);
break;
case SSCFU_RESYNC:
MBUF_FREE(m);
goto badsig;
}
break;
case SSCOP_RECOVER_indication:
/* arg is: */
switch (sscf->state) {
case SSCFU_RELEASED:
case SSCFU_AWAITING_ESTABLISH:
case SSCFU_AWAITING_RELEASE:
goto badsig;
case SSCFU_ESTABLISHED:
SSCOP_AASIG(sscf, SSCOP_RECOVER_response, NULL, 0);
AA_SIG(sscf, SAAL_ESTABLISH_indication, NULL);
break;
case SSCFU_RESYNC:
goto badsig;
}
break;
case SSCOP_RESYNC_indication:
/* arg is: UU */
switch (sscf->state) {
case SSCFU_RELEASED:
case SSCFU_AWAITING_ESTABLISH:
case SSCFU_AWAITING_RELEASE:
if (m)
MBUF_FREE(m);
goto badsig;
case SSCFU_ESTABLISHED:
SSCOP_AASIG(sscf, SSCOP_RESYNC_response, NULL, 0);
AA_SIG(sscf, SAAL_ESTABLISH_indication, m);
break;
case SSCFU_RESYNC:
if (m)
MBUF_FREE(m);
goto badsig;
}
break;
case SSCOP_RESYNC_confirm:
/* arg is: */
switch (sscf->state) {
case SSCFU_RELEASED:
case SSCFU_AWAITING_ESTABLISH:
case SSCFU_AWAITING_RELEASE:
case SSCFU_ESTABLISHED:
case SSCFU_RESYNC:
set_state(sscf, SSCFU_ESTABLISHED);
AA_SIG(sscf, SAAL_ESTABLISH_confirm, NULL);
break;
}
break;
case SSCOP_UDATA_indication:
/* arg is: MD */
AA_SIG(sscf, SAAL_UDATA_indication, m);
break;
case SSCOP_RETRIEVE_indication:
if (m)
MBUF_FREE(m);
goto badsig;
case SSCOP_RETRIEVE_COMPL_indication:
goto badsig;
case SSCOP_ESTABLISH_request:
case SSCOP_RELEASE_request:
case SSCOP_ESTABLISH_response:
case SSCOP_DATA_request:
case SSCOP_RECOVER_response:
case SSCOP_RESYNC_request:
case SSCOP_RESYNC_response:
case SSCOP_UDATA_request:
case SSCOP_RETRIEVE_request:
ASSERT(0);
break;
}
sscfu_unqueue(sscf);
return;
badsig:
VERBOSE(sscf, SSCFU_DBG_ERR, (sscf, sscf->aarg,
"bad signal %d. in state %s", sig, sscf_states[sscf->state]));
sscfu_unqueue(sscf);
}
/*
* Handle signals from the user
*/
static void
sscfu_dosig(struct sscfu *sscf, enum saal_sig sig, struct SSCFU_MBUF_T *m)
{
VERBOSE(sscf, SSCFU_DBG_EXEC, (sscf, sscf->aarg,
"executing signal %s(%s)",
sscf_sigs[sig], sscf_states[sscf->state]));
switch (sig) {
case SAAL_ESTABLISH_request:
/* arg is opt UU */
switch (sscf->state) {
case SSCFU_RELEASED:
set_state(sscf, SSCFU_AWAITING_ESTABLISH);
SSCOP_AASIG(sscf, SSCOP_ESTABLISH_request, m, 1);
break;
case SSCFU_AWAITING_ESTABLISH:
if (m)
MBUF_FREE(m);
goto badsig;
case SSCFU_AWAITING_RELEASE:
set_state(sscf, SSCFU_AWAITING_ESTABLISH);
SSCOP_AASIG(sscf, SSCOP_ESTABLISH_request, m, 1);
break;
case SSCFU_ESTABLISHED:
set_state(sscf, SSCFU_RESYNC);
SSCOP_AASIG(sscf, SSCOP_RESYNC_request, m, 0);
break;
case SSCFU_RESYNC:
if (m)
MBUF_FREE(m);
goto badsig;
}
break;
case SAAL_RELEASE_request:
/* arg is opt UU */
switch(sscf->state) {
case SSCFU_RELEASED:
if (m)
MBUF_FREE(m);
AA_SIG(sscf, SAAL_RELEASE_confirm, NULL);
break;
case SSCFU_AWAITING_ESTABLISH:
set_state(sscf, SSCFU_AWAITING_RELEASE);
SSCOP_AASIG(sscf, SSCOP_RELEASE_request, m, 0);
break;
case SSCFU_AWAITING_RELEASE:
if (m)
MBUF_FREE(m);
goto badsig;
case SSCFU_ESTABLISHED:
set_state(sscf, SSCFU_AWAITING_RELEASE);
SSCOP_AASIG(sscf, SSCOP_RELEASE_request, m, 0);
break;
case SSCFU_RESYNC:
set_state(sscf, SSCFU_AWAITING_RELEASE);
SSCOP_AASIG(sscf, SSCOP_RELEASE_request, m, 0);
break;
}
break;
case SAAL_DATA_request:
/* arg is DATA */
switch (sscf->state) {
case SSCFU_RELEASED:
case SSCFU_AWAITING_ESTABLISH:
case SSCFU_AWAITING_RELEASE:
MBUF_FREE(m);
goto badsig;
case SSCFU_ESTABLISHED:
SSCOP_AASIG(sscf, SSCOP_DATA_request, m, 0);
break;
case SSCFU_RESYNC:
MBUF_FREE(m);
goto badsig;
}
break;
case SAAL_UDATA_request:
/* arg is UDATA */
SSCOP_AASIG(sscf, SSCOP_UDATA_request, m, 0);
break;
case SAAL_ESTABLISH_indication:
case SAAL_ESTABLISH_confirm:
case SAAL_RELEASE_confirm:
case SAAL_RELEASE_indication:
case SAAL_DATA_indication:
case SAAL_UDATA_indication:
ASSERT(0);
break;
}
return;
badsig:
VERBOSE(sscf, SSCFU_DBG_ERR, (sscf, sscf->aarg,
"bad signal %s in state %s", sscf_sigs[sig],
sscf_states[sscf->state]));
}
/*
* Handle user signal.
*/
int
sscfu_saalsig(struct sscfu *sscf, enum saal_sig sig, struct SSCFU_MBUF_T *m)
{
struct sscfu_sig *s;
if (sscf->inhand) {
VERBOSE(sscf, SSCFU_DBG_EXEC, (sscf, sscf->aarg,
"queuing user signal %s(%s)",
sscf_sigs[sig], sscf_states[sscf->state]));
SIG_ALLOC(s);
if (s == NULL)
return (ENOMEM);
s->sig = sig;
s->m = m;
SIGQ_APPEND(&sscf->sigs, s);
return (0);
}
sscf->inhand = 1;
sscfu_dosig(sscf, sig, m);
sscfu_unqueue(sscf);
return (0);
}
/*
* Unqueue all qeueued signals. Must be called with inhand==1.
*/
static void
sscfu_unqueue(struct sscfu *sscf)
{
struct sscfu_sig *s;
while ((s = SIGQ_GET(&sscf->sigs)) != NULL) {
sscfu_dosig(sscf, s->sig, s->m);
SIG_FREE(s);
}
sscf->inhand = 0;
}
void
sscfu_setdebug(struct sscfu *sscf, u_int n)
{
sscf->debug = n;
}
u_int
sscfu_getdebug(const struct sscfu *sscf)
{
return (sscf->debug);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,103 @@
/*
* Copyright (c) 1996-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/sscfu.h,v 1.3 2003/09/19 12:02:03 hbb Exp $
*
* Public include file for UNI SSCF
*/
#ifndef _NETNATM_SAAL_SSCFU_H_
#define _NETNATM_SAAL_SSCFU_H_
#include <sys/types.h>
#include <netnatm/saal/sscopdef.h>
#include <netnatm/saal/sscfudef.h>
/*
* Define how a buffer looks like.
*/
#ifdef _KERNEL
#ifdef __FreeBSD__
#define SSCFU_MBUF_T mbuf
#endif
#else
#define SSCFU_MBUF_T uni_msg
#endif
struct SSCFU_MBUF_T;
struct sscfu;
/* functions to be supplied by the SSCOP user */
struct sscfu_funcs {
/* upper (SAAL) interface output */
void (*send_upper)(struct sscfu *, void *, enum saal_sig,
struct SSCFU_MBUF_T *);
/* lower (SSCOP) interface output */
void (*send_lower)(struct sscfu *, void *, enum sscop_aasig,
struct SSCFU_MBUF_T *, u_int);
/* function to move the SSCOP window */
void (*window)(struct sscfu *, void *, u_int);
/* debugging function */
void (*verbose)(struct sscfu *, void *, const char *, ...)
__printflike(3, 4);
};
/* Function defined by the SSCF-UNI code */
/* allocate and initialize a new SSCF instance */
struct sscfu *sscfu_create(void *, const struct sscfu_funcs *);
/* destroy an SSCF instance and free all resources */
void sscfu_destroy(struct sscfu *);
/* reset the SSCF to the released state */
void sscfu_reset(struct sscfu *);
/* lower input interface (SSCOP signals) */
void sscfu_input(struct sscfu *, enum sscop_aasig, struct SSCFU_MBUF_T *, u_int);
/* upper input interface (SAAL) */
int sscfu_saalsig(struct sscfu *, enum saal_sig, struct SSCFU_MBUF_T *);
/* retrieve the current state */
enum sscfu_state sscfu_getstate(const struct sscfu *);
/* char'ify signals and states */
const char *sscfu_signame(enum saal_sig);
const char *sscfu_statename(enum sscfu_state);
/* retrieve the default set of parameters for SSCOP */
u_int sscfu_getdefparam(struct sscop_param *);
/* get/set debugging flags */
void sscfu_setdebug(struct sscfu *, u_int);
u_int sscfu_getdebug(const struct sscfu *);
#endif

View File

@ -0,0 +1,73 @@
/*
* Copyright (c) 1996-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/sscfudef.h,v 1.3 2003/09/19 12:02:03 hbb Exp $
*
* Definitions of UNI SSCF constants.
*/
#ifndef _NETNATM_SAAL_SSCFUDEF_H_
#define _NETNATM_SAAL_SSCFUDEF_H_
/*
* Signals at the upper boundary of the SSCF.
*/
enum saal_sig {
SAAL_ESTABLISH_request, /* U -> SAAL: (UU) */
SAAL_ESTABLISH_indication, /* SAAL -> U: (UU) */
SAAL_ESTABLISH_confirm, /* SAAL -> U: (UU) */
SAAL_RELEASE_request, /* U -> SAAL: (UU) */
SAAL_RELEASE_confirm, /* SAAL -> U: */
SAAL_RELEASE_indication, /* SAAL -> U: (UU) */
SAAL_DATA_request, /* U -> SAAL: (DATA) */
SAAL_DATA_indication, /* SAAL -> U: (DATA) */
SAAL_UDATA_request, /* U -> SAAL: (UDATA) */
SAAL_UDATA_indication, /* SAAL -> U: (UDATA) */
};
/*
* States of the SSCF
*/
enum sscfu_state {
SSCFU_RELEASED, /* 1/1 */
SSCFU_AWAITING_ESTABLISH, /* 2/2 */
SSCFU_AWAITING_RELEASE, /* 4/10 */
SSCFU_ESTABLISHED, /* 3/4 */
SSCFU_RESYNC, /* 2/5 */
};
/*
* Debugging flags
*/
enum {
SSCFU_DBG_LSIG = 0x01,
SSCFU_DBG_ERR = 0x02,
SSCFU_DBG_STATE = 0x04,
SSCFU_DBG_EXEC = 0x08,
};
#endif

View File

@ -0,0 +1,66 @@
/*
* Copyright (c) 1996-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/sscfupriv.h,v 1.3 2003/09/19 12:02:03 hbb Exp $
*
* Private SSCF-UNI definitions.
*/
#ifdef _KERNEL
#ifdef __FreeBSD__
#include <netgraph/atm/sscfu/ng_sscfu_cust.h>
#endif
#else
#include "sscfucust.h"
#endif
/*
* Structure for signal queueing.
*/
struct sscfu_sig {
sscfu_sigq_link_t link; /* link to next signal */
enum saal_sig sig; /* the signal */
struct SSCFU_MBUF_T *m; /* associated message */
};
struct sscfu {
enum sscfu_state state; /* SSCF state */
const struct sscfu_funcs *funcs; /* func vector */
void *aarg; /* user arg */
int inhand; /* need to queue signals */
sscfu_sigq_head_t sigs; /* signal queue */
u_int debug; /* debugging flags */
};
/*
* Debugging
*/
#ifdef SSCFU_DEBUG
#define VERBOSE(S,M,F) if ((S)->debug & (M)) (S)->funcs->verbose F
#else
#define VERBOSE(S,M,F)
#endif

View File

@ -0,0 +1,126 @@
/*
* Copyright (c) 1996-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/sscop.h,v 1.3 2003/09/19 12:02:03 hbb Exp $
*
* External interface to sscop.
*/
#ifndef _NETNATM_SAAL_SSCOP_H_
#define _NETNATM_SAAL_SSCOP_H_
#include <netnatm/saal/sscopdef.h>
/*
* Define how a buffer looks like.
*/
#ifdef _KERNEL
#ifdef __FreeBSD__
#define SSCOP_MBUF_T mbuf
#endif
#else
#define SSCOP_MBUF_T uni_msg
#endif
struct SSCOP_MBUF_T;
struct sscop;
/*
* Vector for user functions
*/
struct sscop_funcs {
/* management signal from SSCOP */
void (*send_manage)(struct sscop *, void *, enum sscop_maasig,
struct SSCOP_MBUF_T *, u_int, u_int);
/* AAL signal from SSCOP */
void (*send_upper)(struct sscop *, void *, enum sscop_aasig,
struct SSCOP_MBUF_T *, u_int);
/* send a PDU to the wire */
void (*send_lower)(struct sscop *, void *,
struct SSCOP_MBUF_T *);
/* print a message */
void (*verbose)(struct sscop *, void *, const char *, ...)
__printflike(3,4);
#ifndef _KERNEL
/* start a timer */
void *(*start_timer)(struct sscop *, void *, u_int,
void (*)(void *));
/* stop a timer */
void (*stop_timer)(struct sscop *, void *, void *);
#endif
};
/* Function defined by the SSCOP code */
/* create a new SSCOP instance and initialize to default values */
struct sscop *sscop_create(void *, const struct sscop_funcs *);
/* destroy an SSCOP instance */
void sscop_destroy(struct sscop *);
/* get the current parameters of an SSCOP */
void sscop_getparam(const struct sscop *, struct sscop_param *);
/* set new parameters in an SSCOP */
int sscop_setparam(struct sscop *, struct sscop_param *, u_int *);
/* deliver an signal to the SSCOP */
int sscop_aasig(struct sscop *, enum sscop_aasig, struct SSCOP_MBUF_T *, u_int);
/* deliver an management signal to the SSCOP */
int sscop_maasig(struct sscop *, enum sscop_maasig, struct SSCOP_MBUF_T *);
/* SSCOP input function */
void sscop_input(struct sscop *, struct SSCOP_MBUF_T *);
/* Move the window by a given number of messages. Return the new window */
u_int sscop_window(struct sscop *, u_int);
/* declare the lower layer busy or not busy */
u_int sscop_setbusy(struct sscop *, int);
/* retrieve the state */
enum sscop_state sscop_getstate(const struct sscop *);
/* map signals to strings */
const char *sscop_msigname(enum sscop_maasig);
const char *sscop_signame(enum sscop_aasig);
const char *sscop_statename(enum sscop_state);
/* set/get debugging state */
void sscop_setdebug(struct sscop *, u_int);
u_int sscop_getdebug(const struct sscop *);
/* reset the instance */
void sscop_reset(struct sscop *);
#endif

View File

@ -0,0 +1,154 @@
/*
* Copyright (c) 1996-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/sscopdef.h,v 1.3 2003/09/19 12:02:03 hbb Exp $
*
* Definitions of SSCOP constants and parameter blocks. This is seen by
* the outside world.
*/
#ifndef _NETNATM_SAAL_SSCOPDEF_H_
#define _NETNATM_SAAL_SSCOPDEF_H_
#include <sys/types.h>
/*
* AA-interface signals
*/
enum sscop_aasig {
SSCOP_ESTABLISH_request, /* <- UU, BR */
SSCOP_ESTABLISH_indication, /* -> UU */
SSCOP_ESTABLISH_response, /* <- UU, BR */
SSCOP_ESTABLISH_confirm, /* -> UU */
SSCOP_RELEASE_request, /* <- UU */
SSCOP_RELEASE_indication, /* -> UU, SRC */
SSCOP_RELEASE_confirm, /* -> */
SSCOP_DATA_request, /* <- MU */
SSCOP_DATA_indication, /* -> MU, SN */
SSCOP_UDATA_request, /* <- MU */
SSCOP_UDATA_indication, /* -> MU */
SSCOP_RECOVER_indication, /* -> */
SSCOP_RECOVER_response, /* <- */
SSCOP_RESYNC_request, /* <- UU */
SSCOP_RESYNC_indication, /* -> UU */
SSCOP_RESYNC_response, /* <- */
SSCOP_RESYNC_confirm, /* -> */
SSCOP_RETRIEVE_request, /* <- RN */
SSCOP_RETRIEVE_indication, /* -> MU */
SSCOP_RETRIEVE_COMPL_indication,/* -> */
};
enum sscop_maasig {
SSCOP_MDATA_request, /* <- MU */
SSCOP_MDATA_indication, /* -> MU */
SSCOP_MERROR_indication, /* -> CODE, CNT */
};
/*
* Values for retrieval. Numbers in SSCOP are 24bit, so
* we can use the large values
*/
enum {
SSCOP_MAXSEQNO = 0xffffff,
SSCOP_RETRIEVE_UNKNOWN = SSCOP_MAXSEQNO + 1,
SSCOP_RETRIEVE_TOTAL = SSCOP_MAXSEQNO + 2,
};
/*
* SSCOP states
*/
enum sscop_state {
SSCOP_IDLE, /* initial state */
SSCOP_OUT_PEND, /* outgoing connection pending */
SSCOP_IN_PEND, /* incoming connection pending */
SSCOP_OUT_DIS_PEND, /* outgoing disconnect pending */
SSCOP_OUT_RESYNC_PEND, /* outgoing resynchronisation pending */
SSCOP_IN_RESYNC_PEND, /* incoming resynchronisation pending */
SSCOP_OUT_REC_PEND, /* outgoing recovery pending */
SSCOP_REC_PEND, /* recovery response pending */
SSCOP_IN_REC_PEND, /* incoming recovery pending */
SSCOP_READY, /* data transfer ready */
};
#define SSCOP_NSTATES 10
struct sscop_param {
uint32_t timer_cc; /* timer_cc in msec */
uint32_t timer_poll; /* timer_poll im msec */
uint32_t timer_keep_alive;/* timer_keep_alive in msec */
uint32_t timer_no_response;/*timer_no_response in msec */
uint32_t timer_idle; /* timer_idle in msec */
uint32_t maxk; /* maximum user data in bytes */
uint32_t maxj; /* maximum u-u info in bytes */
uint32_t maxcc; /* max. retransmissions for control packets */
uint32_t maxpd; /* max. vt(pd) before sending poll */
uint32_t maxstat; /* max. number of elements in stat list */
uint32_t mr; /* initial window */
uint32_t flags; /* flags */
};
enum {
SSCOP_ROBUST = 0x0001, /* atmf/97-0216 robustness */
SSCOP_POLLREX = 0x0002, /* send POLL after retransmit */
};
enum {
SSCOP_SET_TCC = 0x0001,
SSCOP_SET_TPOLL = 0x0002,
SSCOP_SET_TKA = 0x0004,
SSCOP_SET_TNR = 0x0008,
SSCOP_SET_TIDLE = 0x0010,
SSCOP_SET_MAXK = 0x0020,
SSCOP_SET_MAXJ = 0x0040,
SSCOP_SET_MAXCC = 0x0080,
SSCOP_SET_MAXPD = 0x0100,
SSCOP_SET_MAXSTAT = 0x0200,
SSCOP_SET_MR = 0x0400,
SSCOP_SET_ROBUST = 0x0800,
SSCOP_SET_POLLREX = 0x1000,
SSCOP_SET_ALLMASK = 0x1fff,
};
enum {
SSCOP_DBG_USIG = 0x0001,
SSCOP_DBG_TIMER = 0x0002,
SSCOP_DBG_BUG = 0x0004,
SSCOP_DBG_INSIG = 0x0008,
SSCOP_DBG_STATE = 0x0010,
SSCOP_DBG_PDU = 0x0020,
SSCOP_DBG_ERR = 0x0040,
SSCOP_DBG_EXEC = 0x0080,
SSCOP_DBG_FLOW = 0x0100,
};
#endif

View File

@ -0,0 +1,308 @@
/*
* Copyright (c) 1996-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/sscoppriv.h,v 1.3 2003/09/19 12:02:03 hbb Exp $
*
* Private SSCOP definitions.
*
*/
#ifdef _KERNEL
#ifdef __FreeBSD__
#include <netgraph/atm/sscop/ng_sscop_cust.h>
#endif
#else /* !_KERNEL */
#include "sscopcust.h"
#endif
/*
* PDU trailer
*/
union pdu {
u_int sscop_null;
struct {
#if _BYTE_ORDER == _BIG_ENDIAN
u_int pl : 2; /* pad length */
u_int : 1; /* reserved field */
u_int s : 1; /* source */
u_int type : 4; /* PDU type */
u_int ns : 24; /* sequence number */
#else
u_int ns : 24; /* sequence number */
u_int type : 4; /* PDU type */
u_int s : 1; /* source */
u_int : 1; /* reserved field */
u_int pl : 2; /* pad length */
#endif
} ss;
};
#define sscop_pl ss.pl
#define sscop_s ss.s
#define sscop_type ss.type
#define sscop_ns ss.ns
/*
* seqno list entry format
*/
union seqno {
u_int sscop_null;
struct {
#if _BYTE_ORDER == _BIG_ENDIAN
u_int : 8; /* pad */
u_int n : 24; /* seqno */
#else
u_int n : 24; /* seqno */
u_int : 8; /* pad */
#endif
} ss;
};
#define sscop_n ss.n
/*
* Begin pdu
*/
union bgn {
u_int sscop_null;
struct {
#if _BYTE_ORDER == _BIG_ENDIAN
u_int : 24; /* reserved */
u_int bgns : 8; /* VT_MR */
#else
u_int bgns : 8; /* VT_MR */
u_int : 24; /* reserved */
#endif
} ss;
};
#define sscop_bgns ss.bgns
/*
* pdu types
*/
enum pdu_type {
PDU_BGN = 0x1, /* request initialization */
PDU_BGAK = 0x2, /* request acknowledgement */
PDU_END = 0x3, /* disconnect command */
PDU_ENDAK = 0x4, /* disconnect acknowledgement */
PDU_RS = 0x5, /* resynchronisation command */
PDU_RSAK = 0x6, /* resynchronisation acknowledgement */
PDU_BGREJ = 0x7, /* connection reject */
PDU_SD = 0x8, /* sequenced connection-mode data */
PDU_ER = 0x9, /* recovery command */
PDU_POLL = 0xa, /* xmit state info with req. for recv state */
PDU_STAT = 0xb, /* solicited receiver state info */
PDU_USTAT = 0xc, /* unsolicited receiver state info */
PDU_UD = 0xd, /* unumbered user data */
PDU_MD = 0xe, /* unumbered management data */
PDU_ERAK = 0xf, /* recovery acknowledgement */
};
/*
* These are all signals, that are used by SSCOP. Don't change the order or
* number without also changing the associated tables.
*/
enum sscop_sigtype {
/* received PDU's */
SIG_BGN, /* request initialization */
SIG_BGAK, /* request acknowledgement */
SIG_END, /* disconnect command */
SIG_ENDAK, /* disconnect acknowledgement */
SIG_RS, /* resynchronisation command */
SIG_RSAK, /* resynchronisation acknowledgement */
SIG_BGREJ, /* connection reject */
SIG_SD, /* sequenced connection-mode data */
SIG_ER, /* recovery command */
SIG_POLL, /* xmitter state info with req for recv state */
SIG_STAT, /* solicited receiver state info */
SIG_USTAT, /* unsolicited receiver state info */
SIG_UD, /* unumbered user data */
SIG_MD, /* unumbered management data */
SIG_ERAK, /* recovery acknoledgement */
/* timer expiry */
SIG_T_CC, /* CC timer */
SIG_T_POLL, /* POLL timer */
SIG_T_KA, /* KEEP ALIVE timer */
SIG_T_NR, /* NO RESPONSE timer */
SIG_T_IDLE, /* IDLE timer */
/* user originated signals */
SIG_PDU_Q, /* PDU enqueued pseudosignal */
SIG_USER_DATA, /* user data request */
SIG_ESTAB_REQ, /* establish connection request */
SIG_ESTAB_RESP, /* establish connection response */
SIG_RELEASE_REQ, /* release connection request */
SIG_RECOVER, /* automatic recover response */
SIG_SYNC_REQ, /* resynchronisation request */
SIG_SYNC_RESP, /* resynchronisation response */
SIG_UDATA, /* UDATA request */
SIG_MDATA, /* MDATA request */
SIG_UPDU_Q, /* UDATA PDU enqueued pseudosignal */
SIG_MPDU_Q, /* MDATA PDU enqueued pseudosignal */
SIG_RETRIEVE, /* RETRIEVE */
/* number of signals */
SIG_NUM
};
/*
* This is a message as contained in a sscop message queue. It holds a pointer
* to the real message.
*/
struct sscop_msg {
sscop_msgq_link_t link;
u_int seqno; /* seq no */
u_int poll_seqno; /* poll seqno (for messages in xmit buffer) */
u_int rexmit; /* in retransmission queue? */
struct SSCOP_MBUF_T *m; /* the message */
};
/*
* This structure is used to hold signals in the signal queue
*/
struct sscop_sig {
sscop_sigq_link_t link; /* next signal */
enum sscop_sigtype sig; /* THE signal */
struct sscop_msg *msg; /* signal argument (message) */
};
/*
* This structure holds the entire sscop state
*/
struct sscop {
enum sscop_state state; /* current state */
const struct sscop_funcs *funcs;
/* send state */
u_int vt_s; /* seqno for next pdu first time transmitted */
u_int vt_ps; /* current poll seqno */
u_int vt_a; /* next expected in-sequence sd pdu */
u_int vt_pa; /* poll seqno of next stat pdu */
u_int vt_ms; /* maximum allowed send sd seqno */
u_int vt_pd; /* poll data state */
u_int vt_cc; /* connection control state */
u_int vt_sq; /* transmitter connection sequence */
/* receive state */
u_int vr_r; /* receive state */
u_int vr_h; /* highes expected state */
u_int vr_mr; /* maximum acceptable */
u_int vr_sq; /* receiver connection state */
/* timers */
sscop_timer_t t_cc; /* timer_CC */
sscop_timer_t t_nr; /* timer_NO_RESPONSE */
sscop_timer_t t_ka; /* timer KEEP_ALIVE */
sscop_timer_t t_poll; /* timer_POLL */
sscop_timer_t t_idle; /* idle timer */
/* maximum values */
u_int maxj; /* maximum uu-info */
u_int maxk; /* maximum info */
u_int maxcc; /* maximum number of bgn, end, er and rs */
u_int maxpd; /* maximum value of vt_pd */
u_int maxstat; /* maximum length of list */
u_int timercc; /* connection control timer */
u_int timerka; /* keep alive timer */
u_int timernr; /* no response timer */
u_int timerpoll; /* polling */
u_int timeridle; /* idle timer */
u_int robustness; /* atmf/97-0216 robustness enhancement */
u_int poll_after_rex; /* optional POLL after re-transmission */
u_int mr; /* initial window */
/*
* buffers and queues.
* All expect the xq hold SD PDUs.
*/
sscop_msgq_head_t xq; /* xmit queue (input from user before xmit) */
sscop_msgq_head_t uxq; /* UD xmit queue */
sscop_msgq_head_t mxq; /* MD xmit queue */
sscop_msgq_head_t xbuf; /* transmission buffer (SD PDUs transmitted) */
int rxq; /* number of PDUs in retransmission queue */
sscop_msgq_head_t rbuf; /* receive buffer (SD PDUs) */
int last_end_src; /* source field from last xmitted end pdu */
int clear_buffers; /* flag */
int credit; /* send window not closed */
u_int ll_busy; /* lower layer busy */
u_int rs_mr; /* N(MR) in last RS PDU */
u_int rs_sq; /* N(SQ) in last RS PDU */
struct SSCOP_MBUF_T *uu_bgn; /* last UU data */
struct SSCOP_MBUF_T *uu_bgak; /* ... */
struct SSCOP_MBUF_T *uu_bgrej; /* ... */
struct SSCOP_MBUF_T *uu_end; /* ... */
struct SSCOP_MBUF_T *uu_rs; /* ... */
/* signal queues */
sscop_sigq_head_t sigs; /* saved signals */
sscop_sigq_head_t saved_sigs; /* saved signals */
int in_sig; /* in signal handler */
/* debugging */
u_int debug;
/* AA interface */
void *aarg;
};
/*
* Default values for SSCOP
*/
enum {
MAXK = 4096,
MAXMAXK = 65528,
MAXJ = 4096,
MAXMAXJ = 65524,
MAXCC = 4,
MAXSTAT = 67,
MAXPD = 25,
MAXMR = 128, /* ??? */
TIMERCC = 1000,
TIMERKA = 2000,
TIMERNR = 7000,
TIMERPOLL = 750,
TIMERIDLE = 15000,
};
/*
* Sequence number arithmetic
*/
#define SEQNO_DIFF(A,B) (((A) < (B)) ? ((A) + (1<<24) - (B)) : ((A) - (B)))
/*
* Debugging
*/
#ifdef SSCOP_DEBUG
#define VERBOSE(S,M,F) if ((S)->debug & (M)) (S)->funcs->verbose F
#define VERBERR(S,M,F) if ((S)->debug & (M)) (S)->funcs->verbose F
#define ISVERBOSE(S,M) ((S)->debug & (M))
#else
#define VERBOSE(S,M,F)
#define VERBERR(S,M,F)
#define ISVERBOSE(S,M) (0)
#endif

View File

@ -0,0 +1,90 @@
/*
* Copyright (c) 1996-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/unimsg.h,v 1.3 2003/09/19 11:52:40 hbb Exp $
*
* This defines the structure of messages as handled by this library.
*/
#ifndef _NETNATM_UNIMSG_H_
#define _NETNATM_UNIMSG_H_
#include <sys/types.h>
#ifdef _KERNEL
#ifdef __FreeBSD__
#include <sys/systm.h>
#endif
#else
#include <string.h>
#endif
struct uni_msg {
u_char *b_wptr; /* tail pointer */
u_char *b_rptr; /* head pointer */
u_char *b_buf; /* data buffer */
u_char *b_lim; /* end of data buffer */
};
/* return the current length of the message */
#define uni_msg_len(M) ((size_t)((M)->b_wptr - (M)->b_rptr))
/* return the number of space behind the message */
#define uni_msg_space(M) ((size_t)((M)->b_lim - (M)->b_wptr))
/* return the amount of leading free space */
#define uni_msg_leading(M) ((size_t)((M)->b_rptr - (M)->b_buf))
/* return the maximum size of the message (length plus free space) */
#define uni_msg_size(M) ((size_t)((M)->b_lim - (M)->b_buf));
/* ensure that there is space for another S bytes. If reallocation fails
* free message and return -1 */
#define uni_msg_ensure(M, S) \
((uni_msg_space(M) >= (S)) ? 0 : uni_msg_extend(M, S))
int uni_msg_append(struct uni_msg *, void *, size_t);
int uni_msg_extend(struct uni_msg *, size_t);
#define uni_msg_rptr(MSG, TYPE) ((TYPE)(void *)(MSG)->b_rptr)
#define uni_msg_wptr(MSG, TYPE) ((TYPE)(void *)(MSG)->b_wptr)
int uni_msg_prepend(struct uni_msg *, size_t);
#ifndef _KERNEL
struct uni_msg *uni_msg_alloc(size_t);
struct uni_msg *uni_msg_build(void *, ...);
void uni_msg_destroy(struct uni_msg *);
u_int uni_msg_strip32(struct uni_msg *);
u_int uni_msg_get32(struct uni_msg *);
int uni_msg_append32(struct uni_msg *, u_int);
int uni_msg_append8(struct uni_msg *, u_int);
u_int uni_msg_trail32(const struct uni_msg *, int);
struct uni_msg *uni_msg_dup(const struct uni_msg *);
#endif /* _KERNEL */
#endif