Jump to content
Clubplanet Nightlife Community

Attn: Digital7!!!


funketeer

Recommended Posts

/* @(#) net_diag.h $Revision: 1.11.98.2 $ $Date: 95/08/11 15:05:25 $ */

#ifndef _SYS_NET_DIAG_INCLUDED

#define _SYS_NET_DIAG_INCLUDED

#ifdef _KERNEL

#include "../h/time.h"

#include "../h/subsys_id.h"

#else /* _KERNEL */

#include <sys/time.h>

#include <subsys_id.h>

#endif /* _KERNEL */

#ifndef TRUE

#define TRUE 1

#endif /* TRUE */

#ifndef FALSE

#define FALSE 0

#endif /* FALSE */

#define TRACE_QUEUE 0

#define LOG_QUEUE 1

#define KTL_MBLKS -2

#define KTL_MBUFS -1

/* KTL_IOVECS > 0 */

#ifndef NUM_MASK_ELEMENTS

#define NUM_MASK_ELEMENTS 8

#define NUM_BITS_IN_INTEGER 32

#endif /* NUM_MASK_ELEMENTS */

#define CARD_INSTANCE_MASK 0xff

/* Filters Specific to Tracing */

typedef struct {

int kind;

int max_data_size;

int device_id_mask[NUM_MASK_ELEMENTS];

} netdiag_t_filters;

/* Filters Specific to Logging */

typedef struct {

int log_class;

int device_id;

} netdiag_l_filters;

/* Card name list common to both

* log and trace subsystems */

typedef struct dev_name {

int tr_or_log; /* this card is for log or trace */

int firmlog_level;

int len_of_device_name; /* include the NULL char of string */

struct dev_name *next;

caddr_t device; /* anchor for the device names */

} device_name;

/* Trace and Log filters for each subsystem */

typedef struct {

netdiag_t_filters trace;

netdiag_l_filters log;

device_name *device_ptr; /* card name list */

} netdiag_subsys_t;

/* Table of all Kernel Subsystems */

#ifdef _KERNEL

extern netdiag_subsys_t netdiag_masks[];

# ifdef _PROTOTYPES

extern void ns_log_event(int, unsigned int, int, int, char *, int, int, int, int, int, int);

extern int ns_trace_link(struct ifnet *, unsigned int, struct mbuf *, int);

extern int klogg_write(short, int, int, short, caddr_t, int);

extern int ktrc_write(short, int, int, int, caddr_t, int);

extern unsigned short kget_log_instance();

# else /* not _PROTOTYPES */

extern void ns_log_event();

extern int ns_trace_link();

extern int klogg_write();

extern int ktrc_write();

extern unsigned short kget_log_instance();

# endif /* not _PROTOTYPES */

#endif /* _KERNEL */

/* ******************************************************************** */

/* Subsystem Macros: */

/* */

/* KTRC_CK: Verify the subsystem ID and check the KIND */

/* KTRC_CHECK: Verify the subsystem ID, check the KIND and Device ID */

/* KLOG_CK: Verify the subsystem ID and check the CLASS */

/* */

/* These macros are provided for kernel subsystems to check the values */

/* of the masks in the netdiag_masks table. These macros return TRUE */

/* if the conditions are met. Note that the results are not guaranteed */

/* unless the calls are protrected with the netdiag_masks spinlocks in */

/* the LOG_MASK_R_SPINLOCK and TRACE_MASK_R_SPINLOCK macros. However, */

/* in the name of performance, it is not required that these spinlocks */

/* be used by subsystems (hint: subsystems should not use these locks */

/* since ktrc_write/klogg_write will be verifying the information). */

/* */

/* ******************************************************************** */

/* checks the range of the SUBSYSTEM value */

#define KTL_RANGE(_ss) \

(((_ss) >= 0 ) && ((_ss) < (MAX_SUBSYS)))

#ifdef _KERNEL

/* Tracing macros */

/* Check that the subsystem was configured and turned ON */

#define KTRC_SUBSYS_ON(_ss) \

((KTL_RANGE(_ss)) && netdiag_masks[_ss].trace.kind)

/* Check that subsys is in range, and make sure DEVICE ID matches */

#define KTRC_DEV_ON(_ss, _dev) \

((KTL_RANGE(_ss)) && \

(((_dev) == -1) || \

((!((_dev) & ~CARD_INSTANCE_MASK)) && \

((1 << ((_dev) % NUM_BITS_IN_INTEGER)) & (netdiag_masks[_ss].trace.device_id_mask[(_dev) / NUM_BITS_IN_INTEGER])))))

/* use one macro to check subsys is ON and KIND matches */

#define KTRC_CK(_ss, _kd) \

((KTL_RANGE(_ss)) && ((_kd) & netdiag_masks[_ss].trace.kind))

/* check that subsys is in range, and make sure KIND matches */

#define KTRC_ON(_ss, _kd) \

(KTRC_CK(_ss, _kd))

/* use one macro to check subsys is ON and KIND and DEVICE ID matches */

#define KTRC_CHECK(_ss, _kd, _dev) \

((KTL_RANGE(_ss)) && \

((_kd) & netdiag_masks[_ss].trace.kind) && \

(((_dev) == -1) || \

((!((_dev) & ~CARD_INSTANCE_MASK)) && \

((1 << ((_dev) % NUM_BITS_IN_INTEGER)) & (netdiag_masks[_ss].trace.device_id_mask[(_dev) / NUM_BITS_IN_INTEGER])))))

/* logging macros */

/* Check that the subsystem was configured and turned ON */

#define KLOGG_SUBSYS_ON(_ss) \

((KTL_RANGE(_ss)) && netdiag_masks[_ss].log.log_class)

/* use one macro to check subsys is ON and CLASS matches */

#define KLOG_CK(_ss, _cl) \

((KTL_RANGE(_ss)) && ((_cl) & netdiag_masks[_ss].log.log_class))

/* check that subsys is in range, and make sure CLASS matches */

#define KLOGG_ON(_ss, _cl) \

(KLOG_CK(_ss, _cl))

#endif /* _KERNEL */

/* This next set of information is from the old ns_diag.h file */

#ifndef _SYS_NS_DIAG_INCLUDED

#define _SYS_NS_DIAG_INCLUDED

/*

* network trace record definition

*/

struct ns_trace_link_hdr {

short tr_event; /* event traced:TR_LINK_xxx */

short tr_if; /* i.f. traced (0 @ rel. 1) */

short tr_traced_len; /* byte len of data traced */

short tr_pkt_len; /* byte len of original pkt */

#ifdef _KERNEL

int tr_tid; /* curr. thread (-1=ICS) */

#else /* _KERNEL */

int tr_pid; /* curr. thread (-1=ICS) */

#endif /* _KERNEL */

struct timeval tr_time; /* std timeval */

short tr_subsys; /* subsystem */

};

/*

* link trace events

*/

#define TR_LINK_INBOUND PDU_IN_BIT

#define OLD_TR_LINK_INBOUND 0x0001 /* Inbound packet */

#define TR_LINK_OUTBOUND PDU_OUT_BIT

#define OLD_TR_LINK_OUTBOUND 0x0002 /* Outbound packet */

#define TR_LINK_LOOP LOOP_BACK_BIT

#define OLD_TR_LINK_LOOP 0x0040 /* loopback packet */

#define TR_X25_L2_IN_HEADER 0x0080 /* x25 Level 2 inbound header */

#define TR_X25_L2_IN_FRAME 0x0100 /* X25 Level 2 inbound frame */

#define TR_X25_L2_OUT_HEADER 0x0200 /* X25 Level 2 outbound header*/

#define TR_X25_L2_OUT_FRAME 0x0400 /* X25 Level 2 outbound frame */

#define TR_X25_L3_IN_HEADER 0x0800 /* X25 Level 3 inbound header */

#define TR_X25_L3_IN_PACKET 0x1000 /* X25 Level 3 inbound packet */

#define TR_X25_L3_OUT_HEADER 0x2000 /* X25 Level 3 outbound header*/

#define TR_X25_L3_OUT_PACKET 0x4000 /* X25 Level 3 outbound packet*/

#define TR_X25_LOOPBACK 0x8000 /* X25 loopback driver */

/*

* link trace tr_if definitions

*/

/* link type and unit number are coded in ONE value */

/* First 2 bytes are Link Type: Last 2 Bytes are Unit Number */

#define TR_IF_UNITMASK 0x00ff /* If unit number mask */

#define TR_IF_TYPEMASK 0xff00 /* If type mask */

#define TR_IF_NUNITS 8 /* Number of bits we can

encode unit no. in */

#define TR_IF_NTYPES 7 /* number of types we can

encode in tr_if - 1 */

#define TR_IF_LAN (1<<TR_IF_NUNITS) /* Flag for lan if */

#define TR_IF_LOOP (2<<TR_IF_NUNITS) /* Loopback if */

#define TR_IF_NI (4<<TR_IF_NUNITS) /* Point-to-Point if */

#define TR_IF_X25 (8<<TR_IF_NUNITS) /* X25 if */

/********************************************************************

****

**** Macros

**** NS_TRACE_LINK (_ifp, _kind, _mbuf, _subsys)

****

********************************************************************

* Input Parameters

* _ifp pointer to an if structure

* _kind inbound, outbound, loopback (TR_LINK_xxxx)

* _mbuf mbuf chain to trace

* _subsys subsystem id

*

* Output Parameters

* none

* Return Value

* none

* Globals Referenced

* none

* Description

*

* This macro checks the trace masks against the kind of the input

* event, and if either mask is set, traces the data.

*

********************************************************************

*/

#ifdef _KERNEL

#define NS_TRACE_LINK(_ifp, _kind, _mbuf, _subsys) \

{ \

if (KTRC_CHECK((_subsys), (_kind), ((_ifp)->if_unit))) \

ns_trace_link((_ifp),(_kind),(_mbuf),(_subsys)); \

}

#endif /* _KERNEL */

/*

* network log record definition

*/

struct ns_log_rec {

short log_event; /* event logged: LE_xxx */

short log_location; /* location of log */

short log_class; /* log class: NS_LC_xxx */

short log_subsys; /* log subsys: NS_LS_xxx */

struct timeval log_time; /* std timeval */

int log_error; /* error if any */

int log_context; /* option context info */

int log_mask; /* current file log mask*/

int log_console_mask;/* console mask */

#ifdef _KERNEL

int log_tid; /* curr. thread (-1=ICS)*/

#else /*_KERNEL */

int log_pid; /* curr. thread (-1=ICS)*/

#endif /* _KERNEL */

short log_flags; /* see NS_LF_ below */

unsigned short log_data_dropped;/* amount of data lost */

unsigned short log_dropped; /* # dropped events */

unsigned short log_dlen; /* total dlen of associated */

/* log data in bytes (header */

/* not included). */

};

#define NSDIAG_MAX_DATA 20

typedef struct {

struct ns_log_rec log;

union {

caddr_t ptr;

char chars[NSDIAG_MAX_DATA];

int words[NSDIAG_MAX_DATA/sizeof(int)];

} data;

} nsdiag_event_msg_type;

/*

* log flags see log_flags above (also a parameter to ns_log_event)

*/

#define NS_LF_NODATA 1

#define NS_LF_DATA 2

#define NS_LF_STR 4

#define NS_LF_INFO 8

#define NS_LF_DATA_DROPPED 16

#define NS_LF_DATA_INMBUF 32

/*

* log class definitions

*/

#define NS_LC_LOGSTAT 0

#define OLD_NS_LC_LOGSTAT 0

#define NS_LC_DISASTER 0x10008

#define OLD_NS_LC_DISASTER 1

#define NS_LC_ERROR 0x20004

#define OLD_NS_LC_ERROR 2

#define NS_LC_WARNING 0x30002

#define OLD_NS_LC_WARNING 3

#define NS_LC_RESOURCELIM 0x40001

#define OLD_NS_LC_RESOURCELIM 4

#define NS_LC_PROLOG 0x50001

#define OLD_NS_LC_PROLOG 5

#define NS_LC_MASK 0xffff /* Mask to find old LC in new LC */

#define NS_LC_COUNT 6 /* number of log classes */

/********************************************************************

****

**** Macros

***** NS_LOG (_evt, _cl, _ss, _src)

***** NS_LOG_STR (_evt, _cl, _ss, _src, _str)

***** NS_LOG_INFO (_evt, _cl, _ss, _src, _nw, _p0, _p1)

***** NS_LOG_INFO5(_evt, _cl, _ss, _src, _nw, _p0, _p1, _p2, _p3, _p4)

***** NS_LOG_DATA (_evt, _cl, _ss, _src, _data, _dlen, _p0, _p1)

*****

***** X25_LOG (_evt, _cl, _ss, _src)

***** X25_LOG_STR (_evt, _cl, _ss, _src, _str)

***** X25_LOG_INFO (_evt, _cl, _ss, _src, _nw, _p0, _p1)

***** X25_LOG_INFO5(_evt, _cl, _ss, _src, _nw, _p0, _p1, _p2, _p3, _p4)

***** X25_LOG_DATA (_evt, _cl, _ss, _src, _data, _dlen, _p0, _p1)

****

********************************************************************

* Input Parameters

* _evt event being logged (LE_xxx)

* _cl event class (NS_LC_xxx)

* _ss subsystem executing the log (NS_LS_xxx)

* _src source of event within subsystem. Always 0

* for release 2.0.

* _str [NS_LF_STR] A NULL terminated C string which is to be

* printfd into the log message. The maximum

* length of this string is MLEN bytes.

*

* _data [NS_LF_DATA] Data to be dumped with the log msg.

* _dlen [NS_LF_DATA] Number of bytes in data (max is MLEN)

*

* _nw [NS_LF_INFO] Number of words of associated info (max 5)

* _p0-_p4 [NS_LF_INFO] Info words which are to be printfd into the

* log message.

*

*

* Output Parameters

* none

* Return Value

* none

* Globals Referenced

* none

* Description

*

* These macros check the log masks against the class of the input

* event, and if either mask is set, logs the event.

*

********************************************************************

*/

#ifdef _KERNEL

#define _NS_LOG_(_evt, _cl, _ss, _type, _data, _nw, _p0, _p1, _p2, _p3, _p4) \

{ \

if (KLOG_CK((_ss), ((_cl) & NS_LC_MASK))) \

ns_log_event((_evt), (_cl), (_ss), (_type), (_data), (_nw), \

(_p0), (_p1), (_p2), (_p3), (_p4)); \

}

#else /* _KERNEL */

#define _NS_LOG_(_evt, _cl, _ss, _type, _data, _nw, _p0, _p1, _p2, _p3, _p4) \

{ \

ns_log_event((_evt), (_cl), (_ss), (_type), (_data), (_nw), \

(_p0), (_p1), (_p2), (_p3), (_p4)); \

}

#endif /* _KERNEL */

#define NS_LOG(_evt, _cl, _ss, _src) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_NODATA, 0, 0, 0, 0, 0, 0, 0)

#define NS_LOG_STR(_evt, _cl, _ss, _src, _str) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_STR, _str, 0, 0, 0, 0, 0, 0)

#define NS_LOG_DATA(_evt, _cl, _ss, _src, _data, _dlen, _p0, _p1) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_DATA, _data, _dlen, _p0, _p1, 0, 0, 0)

#define NS_LOG_INFO(_evt, _cl, _ss, _src, _nw, _p0, _p1) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_INFO, 0, _nw, _p0, _p1, 0, 0, 0)

#define NS_LOG_INFO5(_evt, _cl, _ss, _src, _nw, _p0, _p1, _p2, _p3, _p4) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_INFO, 0, _nw, _p0, _p1, _p2, _p3, _p4)

#define X25_LOG(_evt, _cl, _ss, _src) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_NODATA, 0, 0, 0, 0, 0, 0, 0)

#define X25_LOG_STR(_evt, _cl, _ss, _src, _str) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_STR, _str, 0, 0, 0, 0, 0, 0)

#define X25_LOG_DATA(_evt, _cl, _ss, _src, _data, _dlen, _p0, _p1) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_DATA, _data, _dlen, _p0, _p1, 0, 0, 0)

#define X25_LOG_INFO(_evt, _cl, _ss, _src, _nw, _p0, _p1) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_INFO, 0, _nw, _p0, _p1, 0, 0, 0)

#define X25_LOG_INFO5(_evt, _cl, _ss, _src, _nw, _p0, _p1, _p2, _p3, _p4) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_INFO, 0, _nw, _p0, _p1, _p2, _p3, _p4)

/*****************************************************************************

* These are the events themselves.

*****************************************************************************/

/********************************

* Subsystem: Logging *

********************************/

/* Logging Statistics */

#define LE_LOG_STARTING 0 /* logging has been started */

#define LE_LOG_TERM 1 /* logging has been terminated */

#define LE_LOG_TEST 2 /* logging test */

#define LE_LOG_TEST_STR 3 /* logging test w/string */

#define LE_LOG_TEST_INFO 4 /* logging test w/info */

#define LE_LOG_DROPPED 5 /* messages were dropped */

#define LE_LOG_TEST_DATA 6 /* logging test w/data */

/* Disasters */

#define LE_LOG_DISASTER_TEST 1000 /* logging disaster test */

/* Errors */

#define LE_LOG_ERROR_TEST 2000 /* logging error test */

/* Warnings */

#define LE_LOG_WARNING_TEST 3000 /* logging warning test */

#define LE_LOG_DROPPED_MSG 3001 /* dropped msg warning */

/* Resource Limitations */

#define LE_LOG_RESOURCELIM_TEST 4000 /* logging r. limit test */

/* Protocol Logs */

#define LE_LOG_PROLOG_TEST 5000 /* logging proto. log test */

/***********************************

* Subsystem: RFAR *

***********************************/

/* Errors */

#define LE_RFAR_COPY_FAIL 2000 /* user-kernel copy fail */

#define LE_RFAR_IPC_CREATE 2001 /* ipc create socket fail */

#define LE_RFAR_IPC_SHUTDOWN 2002 /* ipc shutdown fail */

#define LE_RFAR_IPC_MUX_CONN 2003 /* ipc mux connect fail */

#define LE_RFAR_IPC_CONTROL 2004 /* ipc control fail */

#define LE_RFAR_IPC_DEST 2005 /* ipc dest socket fail */

#define LE_RFAR_IPC_SEND 2006 /* ipc send fail */

#define LE_RFAR_IPC_MUX_RECV 2007 /* ipc receive fail */

#define LE_RFAR_CONN_FAIL 2008 /* ipc connect fail */

/* Warnings */

#define LE_RFAR_INODE 3000 /* no memory for inode */

#define LE_RFAR_PROCMEM 3001 /* no memory for process */

/* Resource Limitations */

#define LE_RFAR_NOMEM_RFP 4000 /* no memory for inode */

#define LE_RFAR_NOMEM_NETP 4001 /* no memory for netunam */

#define LE_RFAR_NOMEM_PMP 4002 /* no memory for process */

#define LE_RFAR_NETUNAMS_PER_PROC 4003 /* no more netunams */

/* Protocol Logs */

/******************************************

* Subsystem: IPC (NS & 4.2BSD) *

******************************************/

/* Warnings */

#define LE_IPC_SEND_NOMEM_VC 3000 /* no memory for send on vc */

/* Resource Limitations */

#define LE_NO_NAME_MEM 4000 /* No mem for a name record*/

#define LE_CALL_SOCK_Q_LIM 4001 /* call socket queue limit */

/* Protocol Logs */

#define LE_SOCK_ABORT 5000 /* sock aborted by protocol.*/

/********************************

* Subsystem: TCP *

********************************/

/* Warnings */

#define LE_TCP_TERM 3000 /* TCP terminated */

#define LE_TCP_INPUT_PKT_DROPPED 3001

#define LE_TCP_CKSUM_ERR 3002

#define LE_TCP_TOS_ERR 3003

#define LE_TCP_SEC_ERR 3004

#define LE_TCP_SHORT 3005

#define LE_TCP_MM_MSG_2MANY 3006

#define LE_TCP_MM_MSG_2BIG 3007

#define LE_TCP_MORE_DATA_DEFER 3008

#define LE_TCP_PKT_DROP_STATE 3009

#define LE_TCP_PKT_DROP_SOCK 3010

#define LE_TCP_CONN_DROP_RXMT 3011

#define LE_TCP_CONN_DROP_KEEP_ALIVE 3012

#define LE_TCP_CONN_DROP_UNREACH 3013

#define LE_TCP_REASS_PKT_DROPPED 3014

/* New warning entries for 7_0 */

#define LE_TCP_DROP 3015

#define LE_TCP_DROP_WITH_RST 3016

/* Resource Limitations */

#define LE_TCP_NO_MEM 4000

/* Protocol Logs */

#define LE_TCP_DRAIN 5000

#define LE_TCP_INPUT 5001

#define LE_TCP_SPORT_DPORT 5002

#define LE_TCP_ACK 5003

#define LE_TCP_NEW_WINDOW 5004

#define LE_TCP_INPUT_EXIT 5005

#define LE_TCP_OPT_PROC 5006

#define LE_TCP_REASS 5007

#define LE_TCP_PRESENT 5008

#define LE_TCP_MMUPDT 5009

#define LE_TCP_USRREQ_ENTRY 5010

#define LE_TCP_USRREQ_EXIT 5011

#define LE_TCP_OUTPUT 5012

#define LE_TCP_OUTPUT_NIL 5013

#define LE_TCP_RESPOND 5014

#define LE_TCP_REXMT 5015

/* New protocol log entries for 7_0 */

#define LE_TCP_DATA_IN 5016

#define LE_TCP_DATA_OUT 5017

#define LE_TCP_USRREQ 5018

/* 8.0 TCP protocol logs */

#define LE_TCP_CHANGE_STATE 5019

#define LE_TCP_RESET_SENT 5020

/********************************

* Subsystem: PXP *

********************************/

/* Errors */

#define LE_PXP_INVALID_USER_OPTIONS 2000 /* user made invalid choice.*/

/* Warnings */

#define LE_PXP_SEQNUM_NO_MATCH 3000 /* can not find sequence no.*/

/* Resource Limitations */

#define LE_PXP_RESOURCE_LIMITATION 4000 /* max queue size or no mem */

/* Protocol Logs */

#define LE_PXP_BAD_HEADER 5001 /* pkt w/bad pxp header */

#define LE_PXP_DUPLICATE_REQUEST 5002 /* dup request arrived.*/

#define LE_PXP_CTLINPUT 5003 /* ip: link will be closed.*/

#define LE_PXP_FUNC_NOT_SUPPORTED 5004 /* func not supported by pxp*/

#define LE_PXP_RETRY_EXCEEDED 5005 /* retry timed out. */

/********************************

* Subsystem: UDP *

********************************/

/* Warnings */

#define LE_UDP_BADLEN 3000

/* Protocol Logs */

#define LE_UDP_CKSUM_ERR 5000 /* checksum err in UDP pkt */

#define LE_UDP_CTLINPUT 5003 /* ip: link will be closed. */

/********************************

* Subsystem: IP *

********************************/

/* Warnings */

#define LE_IP_TERM 3000 /* IP terminated */

#define LE_IP_SHORT 3001

#define LE_IP_ICMP_SHORT 3002

#define LE_IP_PKT_DROPPED 3003

#define LE_IP_CKSUM_ERR 3004

#define LE_IP_ICMP_CKSUM_ERR 3005

#define LE_IP_PKT_LOST 3006

#define LE_ICMP_PKT_DROPPED 3007

#define LE_ICMP_BAD_CODE 3008

#define LE_ICMP_TOO_BIG_IGNORED 3009

#define LE_IP_VERSION_ERR 3010

#define LE_IP_BAD_SOURCE 3011

/* Resource Limitations */

#define LE_IP_ICMP_NO_MEM 4000 /* m_get for header failed */

#define LE_IP_NO_MEM 4001

Link to comment
Share on other sites

Originally posted by nexusgroove

/* @(#) net_diag.h $Revision: 1.11.98.2 $ $Date: 95/08/11 15:05:25 $ */

#ifndef _SYS_NET_DIAG_INCLUDED

#define _SYS_NET_DIAG_INCLUDED

#ifdef _KERNEL

#include "../h/time.h"

#include "../h/subsys_id.h"

#else /* _KERNEL */

#include <sys/time.h>

#include <subsys_id.h>

#endif /* _KERNEL */

#ifndef TRUE

#define TRUE 1

#endif /* TRUE */

#ifndef FALSE

#define FALSE 0

#endif /* FALSE */

#define TRACE_QUEUE 0

#define LOG_QUEUE 1

#define KTL_MBLKS -2

#define KTL_MBUFS -1

/* KTL_IOVECS > 0 */

#ifndef NUM_MASK_ELEMENTS

#define NUM_MASK_ELEMENTS 8

#define NUM_BITS_IN_INTEGER 32

#endif /* NUM_MASK_ELEMENTS */

#define CARD_INSTANCE_MASK 0xff

/* Filters Specific to Tracing */

typedef struct {

int kind;

int max_data_size;

int device_id_mask[NUM_MASK_ELEMENTS];

} netdiag_t_filters;

/* Filters Specific to Logging */

typedef struct {

int log_class;

int device_id;

} netdiag_l_filters;

/* Card name list common to both

* log and trace subsystems */

typedef struct dev_name {

int tr_or_log; /* this card is for log or trace */

int firmlog_level;

int len_of_device_name; /* include the NULL char of string */

struct dev_name *next;

caddr_t device; /* anchor for the device names */

} device_name;

/* Trace and Log filters for each subsystem */

typedef struct {

netdiag_t_filters trace;

netdiag_l_filters log;

device_name *device_ptr; /* card name list */

} netdiag_subsys_t;

/* Table of all Kernel Subsystems */

#ifdef _KERNEL

extern netdiag_subsys_t netdiag_masks[];

# ifdef _PROTOTYPES

extern void ns_log_event(int, unsigned int, int, int, char *, int, int, int, int, int, int);

extern int ns_trace_link(struct ifnet *, unsigned int, struct mbuf *, int);

extern int klogg_write(short, int, int, short, caddr_t, int);

extern int ktrc_write(short, int, int, int, caddr_t, int);

extern unsigned short kget_log_instance();

# else /* not _PROTOTYPES */

extern void ns_log_event();

extern int ns_trace_link();

extern int klogg_write();

extern int ktrc_write();

extern unsigned short kget_log_instance();

# endif /* not _PROTOTYPES */

#endif /* _KERNEL */

/* ******************************************************************** */

/* Subsystem Macros: */

/* */

/* KTRC_CK: Verify the subsystem ID and check the KIND */

/* KTRC_CHECK: Verify the subsystem ID, check the KIND and Device ID */

/* KLOG_CK: Verify the subsystem ID and check the CLASS */

/* */

/* These macros are provided for kernel subsystems to check the values */

/* of the masks in the netdiag_masks table. These macros return TRUE */

/* if the conditions are met. Note that the results are not guaranteed */

/* unless the calls are protrected with the netdiag_masks spinlocks in */

/* the LOG_MASK_R_SPINLOCK and TRACE_MASK_R_SPINLOCK macros. However, */

/* in the name of performance, it is not required that these spinlocks */

/* be used by subsystems (hint: subsystems should not use these locks */

/* since ktrc_write/klogg_write will be verifying the information). */

/* */

/* ******************************************************************** */

/* checks the range of the SUBSYSTEM value */

#define KTL_RANGE(_ss) \

(((_ss) >= 0 ) && ((_ss) < (MAX_SUBSYS)))

#ifdef _KERNEL

/* Tracing macros */

/* Check that the subsystem was configured and turned ON */

#define KTRC_SUBSYS_ON(_ss) \

((KTL_RANGE(_ss)) && netdiag_masks[_ss].trace.kind)

/* Check that subsys is in range, and make sure DEVICE ID matches */

#define KTRC_DEV_ON(_ss, _dev) \

((KTL_RANGE(_ss)) && \

(((_dev) == -1) || \

((!((_dev) & ~CARD_INSTANCE_MASK)) && \

((1 << ((_dev) % NUM_BITS_IN_INTEGER)) & (netdiag_masks[_ss].trace.device_id_mask[(_dev) / NUM_BITS_IN_INTEGER])))))

/* use one macro to check subsys is ON and KIND matches */

#define KTRC_CK(_ss, _kd) \

((KTL_RANGE(_ss)) && ((_kd) & netdiag_masks[_ss].trace.kind))

/* check that subsys is in range, and make sure KIND matches */

#define KTRC_ON(_ss, _kd) \

(KTRC_CK(_ss, _kd))

/* use one macro to check subsys is ON and KIND and DEVICE ID matches */

#define KTRC_CHECK(_ss, _kd, _dev) \

((KTL_RANGE(_ss)) && \

((_kd) & netdiag_masks[_ss].trace.kind) && \

(((_dev) == -1) || \

((!((_dev) & ~CARD_INSTANCE_MASK)) && \

((1 << ((_dev) % NUM_BITS_IN_INTEGER)) & (netdiag_masks[_ss].trace.device_id_mask[(_dev) / NUM_BITS_IN_INTEGER])))))

/* logging macros */

/* Check that the subsystem was configured and turned ON */

#define KLOGG_SUBSYS_ON(_ss) \

((KTL_RANGE(_ss)) && netdiag_masks[_ss].log.log_class)

/* use one macro to check subsys is ON and CLASS matches */

#define KLOG_CK(_ss, _cl) \

((KTL_RANGE(_ss)) && ((_cl) & netdiag_masks[_ss].log.log_class))

/* check that subsys is in range, and make sure CLASS matches */

#define KLOGG_ON(_ss, _cl) \

(KLOG_CK(_ss, _cl))

#endif /* _KERNEL */

/* This next set of information is from the old ns_diag.h file */

#ifndef _SYS_NS_DIAG_INCLUDED

#define _SYS_NS_DIAG_INCLUDED

/*

* network trace record definition

*/

struct ns_trace_link_hdr {

short tr_event; /* event traced:TR_LINK_xxx */

short tr_if; /* i.f. traced (0 @ rel. 1) */

short tr_traced_len; /* byte len of data traced */

short tr_pkt_len; /* byte len of original pkt */

#ifdef _KERNEL

int tr_tid; /* curr. thread (-1=ICS) */

#else /* _KERNEL */

int tr_pid; /* curr. thread (-1=ICS) */

#endif /* _KERNEL */

struct timeval tr_time; /* std timeval */

short tr_subsys; /* subsystem */

};

/*

* link trace events

*/

#define TR_LINK_INBOUND PDU_IN_BIT

#define OLD_TR_LINK_INBOUND 0x0001 /* Inbound packet */

#define TR_LINK_OUTBOUND PDU_OUT_BIT

#define OLD_TR_LINK_OUTBOUND 0x0002 /* Outbound packet */

#define TR_LINK_LOOP LOOP_BACK_BIT

#define OLD_TR_LINK_LOOP 0x0040 /* loopback packet */

#define TR_X25_L2_IN_HEADER 0x0080 /* x25 Level 2 inbound header */

#define TR_X25_L2_IN_FRAME 0x0100 /* X25 Level 2 inbound frame */

#define TR_X25_L2_OUT_HEADER 0x0200 /* X25 Level 2 outbound header*/

#define TR_X25_L2_OUT_FRAME 0x0400 /* X25 Level 2 outbound frame */

#define TR_X25_L3_IN_HEADER 0x0800 /* X25 Level 3 inbound header */

#define TR_X25_L3_IN_PACKET 0x1000 /* X25 Level 3 inbound packet */

#define TR_X25_L3_OUT_HEADER 0x2000 /* X25 Level 3 outbound header*/

#define TR_X25_L3_OUT_PACKET 0x4000 /* X25 Level 3 outbound packet*/

#define TR_X25_LOOPBACK 0x8000 /* X25 loopback driver */

/*

* link trace tr_if definitions

*/

/* link type and unit number are coded in ONE value */

/* First 2 bytes are Link Type: Last 2 Bytes are Unit Number */

#define TR_IF_UNITMASK 0x00ff /* If unit number mask */

#define TR_IF_TYPEMASK 0xff00 /* If type mask */

#define TR_IF_NUNITS 8 /* Number of bits we can

encode unit no. in */

#define TR_IF_NTYPES 7 /* number of types we can

encode in tr_if - 1 */

#define TR_IF_LAN (1<<TR_IF_NUNITS) /* Flag for lan if */

#define TR_IF_LOOP (2<<TR_IF_NUNITS) /* Loopback if */

#define TR_IF_NI (4<<TR_IF_NUNITS) /* Point-to-Point if */

#define TR_IF_X25 (8<<TR_IF_NUNITS) /* X25 if */

/********************************************************************

****

**** Macros

**** NS_TRACE_LINK (_ifp, _kind, _mbuf, _subsys)

****

********************************************************************

* Input Parameters

* _ifp pointer to an if structure

* _kind inbound, outbound, loopback (TR_LINK_xxxx)

* _mbuf mbuf chain to trace

* _subsys subsystem id

*

* Output Parameters

* none

* Return Value

* none

* Globals Referenced

* none

* Description

*

* This macro checks the trace masks against the kind of the input

* event, and if either mask is set, traces the data.

*

********************************************************************

*/

#ifdef _KERNEL

#define NS_TRACE_LINK(_ifp, _kind, _mbuf, _subsys) \

{ \

if (KTRC_CHECK((_subsys), (_kind), ((_ifp)->if_unit))) \

ns_trace_link((_ifp),(_kind),(_mbuf),(_subsys)); \

}

#endif /* _KERNEL */

/*

* network log record definition

*/

struct ns_log_rec {

short log_event; /* event logged: LE_xxx */

short log_location; /* location of log */

short log_class; /* log class: NS_LC_xxx */

short log_subsys; /* log subsys: NS_LS_xxx */

struct timeval log_time; /* std timeval */

int log_error; /* error if any */

int log_context; /* option context info */

int log_mask; /* current file log mask*/

int log_console_mask;/* console mask */

#ifdef _KERNEL

int log_tid; /* curr. thread (-1=ICS)*/

#else /*_KERNEL */

int log_pid; /* curr. thread (-1=ICS)*/

#endif /* _KERNEL */

short log_flags; /* see NS_LF_ below */

unsigned short log_data_dropped;/* amount of data lost */

unsigned short log_dropped; /* # dropped events */

unsigned short log_dlen; /* total dlen of associated */

/* log data in bytes (header */

/* not included). */

};

#define NSDIAG_MAX_DATA 20

typedef struct {

struct ns_log_rec log;

union {

caddr_t ptr;

char chars[NSDIAG_MAX_DATA];

int words[NSDIAG_MAX_DATA/sizeof(int)];

} data;

} nsdiag_event_msg_type;

/*

* log flags see log_flags above (also a parameter to ns_log_event)

*/

#define NS_LF_NODATA 1

#define NS_LF_DATA 2

#define NS_LF_STR 4

#define NS_LF_INFO 8

#define NS_LF_DATA_DROPPED 16

#define NS_LF_DATA_INMBUF 32

/*

* log class definitions

*/

#define NS_LC_LOGSTAT 0

#define OLD_NS_LC_LOGSTAT 0

#define NS_LC_DISASTER 0x10008

#define OLD_NS_LC_DISASTER 1

#define NS_LC_ERROR 0x20004

#define OLD_NS_LC_ERROR 2

#define NS_LC_WARNING 0x30002

#define OLD_NS_LC_WARNING 3

#define NS_LC_RESOURCELIM 0x40001

#define OLD_NS_LC_RESOURCELIM 4

#define NS_LC_PROLOG 0x50001

#define OLD_NS_LC_PROLOG 5

#define NS_LC_MASK 0xffff /* Mask to find old LC in new LC */

#define NS_LC_COUNT 6 /* number of log classes */

/********************************************************************

****

**** Macros

***** NS_LOG (_evt, _cl, _ss, _src)

***** NS_LOG_STR (_evt, _cl, _ss, _src, _str)

***** NS_LOG_INFO (_evt, _cl, _ss, _src, _nw, _p0, _p1)

***** NS_LOG_INFO5(_evt, _cl, _ss, _src, _nw, _p0, _p1, _p2, _p3, _p4)

***** NS_LOG_DATA (_evt, _cl, _ss, _src, _data, _dlen, _p0, _p1)

*****

***** X25_LOG (_evt, _cl, _ss, _src)

***** X25_LOG_STR (_evt, _cl, _ss, _src, _str)

***** X25_LOG_INFO (_evt, _cl, _ss, _src, _nw, _p0, _p1)

***** X25_LOG_INFO5(_evt, _cl, _ss, _src, _nw, _p0, _p1, _p2, _p3, _p4)

***** X25_LOG_DATA (_evt, _cl, _ss, _src, _data, _dlen, _p0, _p1)

****

********************************************************************

* Input Parameters

* _evt event being logged (LE_xxx)

* _cl event class (NS_LC_xxx)

* _ss subsystem executing the log (NS_LS_xxx)

* _src source of event within subsystem. Always 0

* for release 2.0.

* _str [NS_LF_STR] A NULL terminated C string which is to be

* printfd into the log message. The maximum

* length of this string is MLEN bytes.

*

* _data [NS_LF_DATA] Data to be dumped with the log msg.

* _dlen [NS_LF_DATA] Number of bytes in data (max is MLEN)

*

* _nw [NS_LF_INFO] Number of words of associated info (max 5)

* _p0-_p4 [NS_LF_INFO] Info words which are to be printfd into the

* log message.

*

*

* Output Parameters

* none

* Return Value

* none

* Globals Referenced

* none

* Description

*

* These macros check the log masks against the class of the input

* event, and if either mask is set, logs the event.

*

********************************************************************

*/

#ifdef _KERNEL

#define _NS_LOG_(_evt, _cl, _ss, _type, _data, _nw, _p0, _p1, _p2, _p3, _p4) \

{ \

if (KLOG_CK((_ss), ((_cl) & NS_LC_MASK))) \

ns_log_event((_evt), (_cl), (_ss), (_type), (_data), (_nw), \

(_p0), (_p1), (_p2), (_p3), (_p4)); \

}

#else /* _KERNEL */

#define _NS_LOG_(_evt, _cl, _ss, _type, _data, _nw, _p0, _p1, _p2, _p3, _p4) \

{ \

ns_log_event((_evt), (_cl), (_ss), (_type), (_data), (_nw), \

(_p0), (_p1), (_p2), (_p3), (_p4)); \

}

#endif /* _KERNEL */

#define NS_LOG(_evt, _cl, _ss, _src) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_NODATA, 0, 0, 0, 0, 0, 0, 0)

#define NS_LOG_STR(_evt, _cl, _ss, _src, _str) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_STR, _str, 0, 0, 0, 0, 0, 0)

#define NS_LOG_DATA(_evt, _cl, _ss, _src, _data, _dlen, _p0, _p1) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_DATA, _data, _dlen, _p0, _p1, 0, 0, 0)

#define NS_LOG_INFO(_evt, _cl, _ss, _src, _nw, _p0, _p1) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_INFO, 0, _nw, _p0, _p1, 0, 0, 0)

#define NS_LOG_INFO5(_evt, _cl, _ss, _src, _nw, _p0, _p1, _p2, _p3, _p4) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_INFO, 0, _nw, _p0, _p1, _p2, _p3, _p4)

#define X25_LOG(_evt, _cl, _ss, _src) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_NODATA, 0, 0, 0, 0, 0, 0, 0)

#define X25_LOG_STR(_evt, _cl, _ss, _src, _str) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_STR, _str, 0, 0, 0, 0, 0, 0)

#define X25_LOG_DATA(_evt, _cl, _ss, _src, _data, _dlen, _p0, _p1) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_DATA, _data, _dlen, _p0, _p1, 0, 0, 0)

#define X25_LOG_INFO(_evt, _cl, _ss, _src, _nw, _p0, _p1) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_INFO, 0, _nw, _p0, _p1, 0, 0, 0)

#define X25_LOG_INFO5(_evt, _cl, _ss, _src, _nw, _p0, _p1, _p2, _p3, _p4) \

_NS_LOG_(_evt, _cl, _ss, NS_LF_INFO, 0, _nw, _p0, _p1, _p2, _p3, _p4)

/*****************************************************************************

* These are the events themselves.

*****************************************************************************/

/********************************

* Subsystem: Logging *

********************************/

/* Logging Statistics */

#define LE_LOG_STARTING 0 /* logging has been started */

#define LE_LOG_TERM 1 /* logging has been terminated */

#define LE_LOG_TEST 2 /* logging test */

#define LE_LOG_TEST_STR 3 /* logging test w/string */

#define LE_LOG_TEST_INFO 4 /* logging test w/info */

#define LE_LOG_DROPPED 5 /* messages were dropped */

#define LE_LOG_TEST_DATA 6 /* logging test w/data */

/* Disasters */

#define LE_LOG_DISASTER_TEST 1000 /* logging disaster test */

/* Errors */

#define LE_LOG_ERROR_TEST 2000 /* logging error test */

/* Warnings */

#define LE_LOG_WARNING_TEST 3000 /* logging warning test */

#define LE_LOG_DROPPED_MSG 3001 /* dropped msg warning */

/* Resource Limitations */

#define LE_LOG_RESOURCELIM_TEST 4000 /* logging r. limit test */

/* Protocol Logs */

#define LE_LOG_PROLOG_TEST 5000 /* logging proto. log test */

/***********************************

* Subsystem: RFAR *

***********************************/

/* Errors */

#define LE_RFAR_COPY_FAIL 2000 /* user-kernel copy fail */

#define LE_RFAR_IPC_CREATE 2001 /* ipc create socket fail */

#define LE_RFAR_IPC_SHUTDOWN 2002 /* ipc shutdown fail */

#define LE_RFAR_IPC_MUX_CONN 2003 /* ipc mux connect fail */

#define LE_RFAR_IPC_CONTROL 2004 /* ipc control fail */

#define LE_RFAR_IPC_DEST 2005 /* ipc dest socket fail */

#define LE_RFAR_IPC_SEND 2006 /* ipc send fail */

#define LE_RFAR_IPC_MUX_RECV 2007 /* ipc receive fail */

#define LE_RFAR_CONN_FAIL 2008 /* ipc connect fail */

/* Warnings */

#define LE_RFAR_INODE 3000 /* no memory for inode */

#define LE_RFAR_PROCMEM 3001 /* no memory for process */

/* Resource Limitations */

#define LE_RFAR_NOMEM_RFP 4000 /* no memory for inode */

#define LE_RFAR_NOMEM_NETP 4001 /* no memory for netunam */

#define LE_RFAR_NOMEM_PMP 4002 /* no memory for process */

#define LE_RFAR_NETUNAMS_PER_PROC 4003 /* no more netunams */

/* Protocol Logs */

/******************************************

* Subsystem: IPC (NS & 4.2BSD) *

******************************************/

/* Warnings */

#define LE_IPC_SEND_NOMEM_VC 3000 /* no memory for send on vc */

/* Resource Limitations */

#define LE_NO_NAME_MEM 4000 /* No mem for a name record*/

#define LE_CALL_SOCK_Q_LIM 4001 /* call socket queue limit */

/* Protocol Logs */

#define LE_SOCK_ABORT 5000 /* sock aborted by protocol.*/

/********************************

* Subsystem: TCP *

********************************/

/* Warnings */

#define LE_TCP_TERM 3000 /* TCP terminated */

#define LE_TCP_INPUT_PKT_DROPPED 3001

#define LE_TCP_CKSUM_ERR 3002

#define LE_TCP_TOS_ERR 3003

#define LE_TCP_SEC_ERR 3004

#define LE_TCP_SHORT 3005

#define LE_TCP_MM_MSG_2MANY 3006

#define LE_TCP_MM_MSG_2BIG 3007

#define LE_TCP_MORE_DATA_DEFER 3008

#define LE_TCP_PKT_DROP_STATE 3009

#define LE_TCP_PKT_DROP_SOCK 3010

#define LE_TCP_CONN_DROP_RXMT 3011

#define LE_TCP_CONN_DROP_KEEP_ALIVE 3012

#define LE_TCP_CONN_DROP_UNREACH 3013

#define LE_TCP_REASS_PKT_DROPPED 3014

/* New warning entries for 7_0 */

#define LE_TCP_DROP 3015

#define LE_TCP_DROP_WITH_RST 3016

/* Resource Limitations */

#define LE_TCP_NO_MEM 4000

/* Protocol Logs */

#define LE_TCP_DRAIN 5000

#define LE_TCP_INPUT 5001

#define LE_TCP_SPORT_DPORT 5002

#define LE_TCP_ACK 5003

#define LE_TCP_NEW_WINDOW 5004

#define LE_TCP_INPUT_EXIT 5005

#define LE_TCP_OPT_PROC 5006

#define LE_TCP_REASS 5007

#define LE_TCP_PRESENT 5008

#define LE_TCP_MMUPDT 5009

#define LE_TCP_USRREQ_ENTRY 5010

#define LE_TCP_USRREQ_EXIT 5011

#define LE_TCP_OUTPUT 5012

#define LE_TCP_OUTPUT_NIL 5013

#define LE_TCP_RESPOND 5014

#define LE_TCP_REXMT 5015

/* New protocol log entries for 7_0 */

#define LE_TCP_DATA_IN 5016

#define LE_TCP_DATA_OUT 5017

#define LE_TCP_USRREQ 5018

/* 8.0 TCP protocol logs */

#define LE_TCP_CHANGE_STATE 5019

#define LE_TCP_RESET_SENT 5020

/********************************

* Subsystem: PXP *

********************************/

/* Errors */

#define LE_PXP_INVALID_USER_OPTIONS 2000 /* user made invalid choice.*/

/* Warnings */

#define LE_PXP_SEQNUM_NO_MATCH 3000 /* can not find sequence no.*/

/* Resource Limitations */

#define LE_PXP_RESOURCE_LIMITATION 4000 /* max queue size or no mem */

/* Protocol Logs */

#define LE_PXP_BAD_HEADER 5001 /* pkt w/bad pxp header */

#define LE_PXP_DUPLICATE_REQUEST 5002 /* dup request arrived.*/

#define LE_PXP_CTLINPUT 5003 /* ip: link will be closed.*/

#define LE_PXP_FUNC_NOT_SUPPORTED 5004 /* func not supported by pxp*/

#define LE_PXP_RETRY_EXCEEDED 5005 /* retry timed out. */

/********************************

* Subsystem: UDP *

********************************/

/* Warnings */

#define LE_UDP_BADLEN 3000

/* Protocol Logs */

#define LE_UDP_CKSUM_ERR 5000 /* checksum err in UDP pkt */

#define LE_UDP_CTLINPUT 5003 /* ip: link will be closed. */

/********************************

* Subsystem: IP *

********************************/

/* Warnings */

#define LE_IP_TERM 3000 /* IP terminated */

#define LE_IP_SHORT 3001

#define LE_IP_ICMP_SHORT 3002

#define LE_IP_PKT_DROPPED 3003

#define LE_IP_CKSUM_ERR 3004

#define LE_IP_ICMP_CKSUM_ERR 3005

#define LE_IP_PKT_LOST 3006

#define LE_ICMP_PKT_DROPPED 3007

#define LE_ICMP_BAD_CODE 3008

#define LE_ICMP_TOO_BIG_IGNORED 3009

#define LE_IP_VERSION_ERR 3010

#define LE_IP_BAD_SOURCE 3011

/* Resource Limitations */

#define LE_IP_ICMP_NO_MEM 4000 /* m_get for header failed */

#define LE_IP_NO_MEM 4001

Yeah, I know :(

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...