📄 clnp.h
字号:
/*- * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. * * @(#)clnp.h 8.2 (Berkeley) 4/16/94 *//*********************************************************** Copyright IBM Corporation 1987 All Rights ReservedPermission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and thatboth that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not beused in advertising or publicity pertaining to distribution of thesoftware without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLIBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THISSOFTWARE.******************************************************************//* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison *//* $Header: /big/BSD4.4/isis-usr/src/sys/netiso/RCS/clnp.h,v 1.1 1992/02/07 18:14:59 hagens Exp hagens $ *//* $Source: /big/BSD4.4/isis-usr/src/sys/netiso/RCS/clnp.h,v $ *//* should be config option but cpp breaks with too many #defines */#define DECBIT/* * Return true if the mbuf is a cluster mbuf */#define IS_CLUSTER(m) ((m)->m_flags & M_EXT)/* * Move the halfword into the two characters */#define HTOC(msb, lsb, hword)\ (msb) = (u_char)((hword) >> 8);\ (lsb) = (u_char)((hword) & 0xff)/* * Move the two charcters into the halfword */#define CTOH(msb, lsb, hword)\ (hword) = ((msb) << 8) | (lsb)/* * Return true if the checksum has been set - ie. the checksum is * not zero */#define CKSUM_REQUIRED(clnp)\ (((clnp)->cnf_cksum_msb != 0) || ((clnp)->cnf_cksum_lsb != 0))/* * Fixed part of clnp header */struct clnp_fixed { u_char cnf_proto_id; /* network layer protocol identifier */ u_char cnf_hdr_len; /* length indicator (octets) */ u_char cnf_vers; /* version/protocol identifier extension */ u_char cnf_ttl; /* lifetime (500 milliseconds) */ u_char cnf_type; /* type code */ /* Includes err_ok, more_segs, and seg_ok */ u_char cnf_seglen_msb; /* pdu segment length (octets) high byte */ u_char cnf_seglen_lsb; /* pdu segment length (octets) low byte */ u_char cnf_cksum_msb; /* checksum high byte */ u_char cnf_cksum_lsb; /* checksum low byte */};#define CNF_TYPE 0x1f#define CNF_ERR_OK 0x20#define CNF_MORE_SEGS 0x40#define CNF_SEG_OK 0x80#define CLNP_CKSUM_OFF 0x07 /* offset of checksum */#define clnl_fixed clnp_fixed/* * Segmentation part of clnp header */struct clnp_segment { u_short cng_id; /* data unit identifier */ u_short cng_off; /* segment offset */ u_short cng_tot_len; /* total length */};/* * Clnp fragment reassembly structures: * * All packets undergoing reassembly are linked together in * clnp_fragl structures. Each clnp_fragl structure contains a * pointer to the original clnp packet header, as well as a * list of packet fragments. Each packet fragment * is headed by a clnp_frag structure. This structure contains the * offset of the first and last byte of the fragment, as well as * a pointer to the data (an mbuf chain) of the fragment. *//* * NOTE: * The clnp_frag structure is stored in an mbuf immedately preceeding * the fragment data. Since there are words in this struct, * it must be word aligned. * * NOTE: * All the fragment code assumes that the entire clnp header is * contained in the first mbuf. */struct clnp_frag { u_int cfr_first; /* offset of first byte of this frag */ u_int cfr_last; /* offset of last byte of this frag */ u_int cfr_bytes; /* bytes to shave to get to data */ struct mbuf *cfr_data; /* ptr to data for this frag */ struct clnp_frag *cfr_next; /* next fragment in list */};struct clnp_fragl { struct iso_addr cfl_src; /* source of the pkt */ struct iso_addr cfl_dst; /* destination of the pkt */ u_short cfl_id; /* id of the pkt */ u_char cfl_ttl; /* current ttl of pkt */ u_short cfl_last; /* offset of last byte of packet */ struct mbuf *cfl_orighdr; /* ptr to original header */ struct clnp_frag *cfl_frags; /* linked list of fragments for pkt */ struct clnp_fragl *cfl_next; /* next pkt being reassembled */};/* * The following structure is used to index into an options section * of a clnp datagram. These values can be used without worry that * offset or length fields are invalid or too big, etc. That is, * the consistancy of the options will be guaranteed before this * structure is filled in. Any pointer (field ending in p) is * actually the offset from the beginning of the mbuf the option * is contained in. A value of NULL for any pointer * means that the option is not present. The length any option * does not include the option code or option length fields. */struct clnp_optidx { u_short cni_securep; /* ptr to beginning of security option */ char cni_secure_len; /* length of entire security option */ u_short cni_srcrt_s; /* offset of start of src rt option */ u_short cni_srcrt_len; /* length of entire src rt option */ u_short cni_recrtp; /* ptr to beginning of recrt option */ char cni_recrt_len; /* length of entire recrt option */ char cni_priorp; /* ptr to priority option */ u_short cni_qos_formatp; /* ptr to format of qos option */ char cni_qos_len; /* length of entire qos option */ u_char cni_er_reason; /* reason from ER pdu option */ /* ESIS options */ u_short cni_esct; /* value from ISH ESCT option */ u_short cni_netmaskp; /* ptr to beginning of netmask option */ char cni_netmask_len; /* length of entire netmask option */ u_short cni_snpamaskp; /* ptr to beginning of snpamask option */ char cni_snpamask_len; /* length of entire snpamask option */};#define ER_INVALREAS 0xff /* code for invalid ER pdu discard reason *//* given an mbuf and addr of option, return offset from data of mbuf */#define CLNP_OPTTOOFF(m, opt)\ ((u_short) (opt - mtod(m, caddr_t)))/* given an mbuf and offset of option, return address of option */#define CLNP_OFFTOOPT(m, off)\ ((caddr_t) (mtod(m, caddr_t) + off))/* return true iff src route is valid */#define CLNPSRCRT_VALID(oidx)\ ((oidx) && (oidx->cni_srcrt_s))/* return the offset field of the src rt */#define CLNPSRCRT_OFF(oidx, options)\ (*((u_char *)(CLNP_OFFTOOPT(options, oidx->cni_srcrt_s) + 1)))/* return the type field of the src rt */#define CLNPSRCRT_TYPE(oidx, options)\ ((u_char)(*(CLNP_OFFTOOPT(options, oidx->cni_srcrt_s))))/* return the length of the current address */#define CLNPSRCRT_CLEN(oidx, options)\ ((u_char)(*(CLNP_OFFTOOPT(options, oidx->cni_srcrt_s) + CLNPSRCRT_OFF(oidx, options) - 1)))/* return the address of the current address */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -