📄 clnp.h
字号:
#define CLNPSRCRT_CADDR(oidx, options)\ ((caddr_t)(CLNP_OFFTOOPT(options, oidx->cni_srcrt_s) + CLNPSRCRT_OFF(oidx, options)))/* * return true if the src route has run out of routes * this is true if the offset of next route is greater than the end of the rt */#define CLNPSRCRT_TERM(oidx, options)\ (CLNPSRCRT_OFF(oidx, options) > oidx->cni_srcrt_len)/* * Options a user can set/get */#define CLNPOPT_FLAGS 0x01 /* flags: seg permitted, no er xmit, etc */#define CLNPOPT_OPTS 0x02 /* datagram options *//* * Values for particular datagram options */#define CLNPOVAL_PAD 0xcc /* padding */#define CLNPOVAL_SECURE 0xc5 /* security */#define CLNPOVAL_SRCRT 0xc8 /* source routing */#define CLNPOVAL_RECRT 0xcb /* record route */#define CLNPOVAL_QOS 0xc3 /* quality of service */#define CLNPOVAL_PRIOR 0xcd /* priority */#define CLNPOVAL_ERREAS 0xc1 /* ER PDU ONLY: reason for discard */#define CLNPOVAL_SRCSPEC 0x40 /* source address specific */#define CLNPOVAL_DSTSPEC 0x80 /* destination address specific */#define CLNPOVAL_GLOBAL 0xc0 /* globally unique *//* Globally Unique QOS */#define CLNPOVAL_SEQUENCING 0x10 /* sequencing preferred */#define CLNPOVAL_CONGESTED 0x08 /* congestion experienced */#define CLNPOVAL_LOWDELAY 0x04 /* low transit delay */#define CLNPOVAL_PARTRT 0x00 /* partial source routing */#define CLNPOVAL_COMPRT 0x01 /* complete source routing *//* * Clnp flags used in a control block flags field. * NOTE: these must be out of the range of bits defined in ../net/raw_cb.h */#define CLNP_NO_SEG 0x010 /* segmentation not permitted */#define CLNP_NO_ER 0x020 /* do not generate ERs */#define CLNP_SEND_RAW 0x080 /* send pkt as RAW DT rather than TP DT */#define CLNP_NO_CKSUM 0x100 /* don't use clnp checksum */#define CLNP_ECHO 0x200 /* send echo request */#define CLNP_NOCACHE 0x400 /* don't store cache information */#define CLNP_ECHOR 0x800 /* send echo reply *//* valid clnp flags */#define CLNP_VFLAGS (CLNP_SEND_RAW|CLNP_NO_SEG|CLNP_NO_ER|CLNP_NO_CKSUM\ |CLNP_ECHO|CLNP_NOCACHE|CLNP_ECHOR)/* * Constants used by clnp */#define CLNP_HDR_MIN (sizeof (struct clnp_fixed))#define CLNP_HDR_MAX (254)#define CLNP_TTL_UNITS 2 /* 500 milliseconds */#define CLNP_TTL 15*CLNP_TTL_UNITS /* time to live (seconds) */#define ISO8473_V1 0x01/* * Clnp packet types * In order to test raw clnp and tp/clnp simultaneously, a third type of * packet has been defined: CLNP_RAW. This is done so that the input * routine can switch to the correct input routine (rclnp_input or * tpclnp_input) based on the type field. If clnp had a higher level protocol * field, this would not be necessary. */#define CLNP_DT 0x1C /* normal data */#define CLNP_ER 0x01 /* error report */#define CLNP_RAW 0x1D /* debug only */#define CLNP_EC 0x1E /* echo packet */#define CLNP_ECR 0x1F /* echo reply *//* * ER pdu error codes */#define GEN_NOREAS 0x00 /* reason not specified */#define GEN_PROTOERR 0x01 /* protocol procedure error */#define GEN_BADCSUM 0x02 /* incorrect checksum */#define GEN_CONGEST 0x03 /* pdu discarded due to congestion */#define GEN_HDRSYNTAX 0x04 /* header syntax error */#define GEN_SEGNEEDED 0x05 /* segmentation needed, but not permitted */#define GEN_INCOMPLETE 0x06 /* incomplete pdu received */#define GEN_DUPOPT 0x07 /* duplicate option *//* address errors */#define ADDR_DESTUNREACH 0x80 /* destination address unreachable */#define ADDR_DESTUNKNOWN 0x81 /* destination address unknown *//* source routing */#define SRCRT_UNSPECERR 0x90 /* unspecified src rt error */#define SRCRT_SYNTAX 0x91 /* syntax error in src rt field */#define SRCRT_UNKNOWNADDR 0x92 /* unknown addr in src rt field */#define SRCRT_BADPATH 0x93 /* path not acceptable *//* lifetime */#define TTL_EXPTRANSIT 0xa0 /* lifetime expired during transit */#define TTL_EXPREASS 0xa1 /* lifetime expired during reassembly *//* pdu discarded */#define DISC_UNSUPPOPT 0xb0 /* unsupported option not specified? */#define DISC_UNSUPPVERS 0xb1 /* unsupported protocol version */#define DISC_UNSUPPSECURE 0xb2 /* unsupported security option */#define DISC_UNSUPPSRCRT 0xb3 /* unsupported src rt option */#define DISC_UNSUPPRECRT 0xb4 /* unsupported rec rt option *//* reassembly */#define REASS_INTERFERE 0xc0 /* reassembly interference */#define CLNP_ERRORS 22#ifdef KERNELint clnp_er_index();#endif#ifdef CLNP_ER_CODESu_char clnp_er_codes[CLNP_ERRORS] = {GEN_NOREAS, GEN_PROTOERR, GEN_BADCSUM, GEN_CONGEST,GEN_HDRSYNTAX, GEN_SEGNEEDED, GEN_INCOMPLETE, GEN_DUPOPT,ADDR_DESTUNREACH, ADDR_DESTUNKNOWN,SRCRT_UNSPECERR, SRCRT_SYNTAX, SRCRT_UNKNOWNADDR, SRCRT_BADPATH,TTL_EXPTRANSIT, TTL_EXPREASS,DISC_UNSUPPOPT, DISC_UNSUPPVERS, DISC_UNSUPPSECURE,DISC_UNSUPPSRCRT, DISC_UNSUPPRECRT, REASS_INTERFERE };#endif#ifdef TROLL#define TR_DUPEND 0x01 /* duplicate end of fragment */#define TR_DUPPKT 0x02 /* duplicate entire packet */#define TR_DROPPKT 0x04 /* drop packet on output */#define TR_TRIM 0x08 /* trim bytes from packet */#define TR_CHANGE 0x10 /* change bytes in packet */#define TR_MTU 0x20 /* delta to change device mtu */#define TR_CHUCK 0x40 /* drop packet in rclnp_input */#define TR_BLAST 0x80 /* force rclnp_output to blast many packet */#define TR_RAWLOOP 0x100 /* make if_loop call clnpintr directly */struct troll { int tr_ops; /* operations to perform */ float tr_dup_size; /* % to duplicate */ float tr_dup_freq; /* frequency to duplicate packets */ float tr_drop_freq; /* frequence to drop packets */ int tr_mtu_adj; /* delta to adjust if mtu */ int tr_blast_cnt; /* # of pkts to blast out */};#define SN_OUTPUT(clcp, m)\ troll_output(clcp->clc_ifp, m, clcp->clc_firsthop, clcp->clc_rt)#define SN_MTU(ifp, rt) (((rt && rt->rt_rmx.rmx_mtu) ?\ rt->rt_rmx.rmx_mtu : clnp_badmtu(ifp, rt, __LINE__, __FILE__))\ - trollctl.tr_mtu_adj)#ifdef KERNELextern float troll_random;#endif#else /* NO TROLL */#define SN_OUTPUT(clcp, m)\ (*clcp->clc_ifp->if_output)(clcp->clc_ifp, m, clcp->clc_firsthop, clcp->clc_rt)#define SN_MTU(ifp, rt) (((rt && rt->rt_rmx.rmx_mtu) ?\ rt->rt_rmx.rmx_mtu : clnp_badmtu(ifp, rt, __LINE__, __FILE__)))#endif /* TROLL *//* * Macro to remove an address from a clnp header */#define CLNP_EXTRACT_ADDR(isoa, hoff, hend)\ {\ isoa.isoa_len = (u_char)*hoff;\ if ((((++hoff) + isoa.isoa_len) > hend) ||\ (isoa.isoa_len > 20) || (isoa.isoa_len == 0)) {\ hoff = (caddr_t)0;\ } else {\ (void) bcopy(hoff, (caddr_t)isoa.isoa_genaddr, isoa.isoa_len);\ hoff += isoa.isoa_len;\ }\ }/* * Macro to insert an address into a clnp header */#define CLNP_INSERT_ADDR(hoff, isoa)\ *hoff++ = (isoa).isoa_len;\ (void) bcopy((caddr_t)((isoa).isoa_genaddr), hoff, (isoa).isoa_len);\ hoff += (isoa).isoa_len;/* * Clnp hdr cache. Whenever a clnp packet is sent, a copy of the * header is made and kept in this cache. In addition to a copy of * the cached clnp hdr, the cache contains * information necessary to determine whether the new packet * to send requires a new header to be built. */struct clnp_cache { /* these fields are used to check the validity of the cache */ struct iso_addr clc_dst; /* destination of packet */ struct mbuf *clc_options; /* ptr to options mbuf */ int clc_flags; /* flags passed to clnp_output */ /* these fields are state that clnp_output requires to finish the pkt */ int clc_segoff; /* offset of seg part of header */ struct rtentry *clc_rt; /* ptr to rtentry (points into the route structure) */ struct sockaddr *clc_firsthop; /* first hop of packet */ struct ifnet *clc_ifp; /* ptr to interface structure */ struct iso_ifaddr *clc_ifa; /* ptr to interface address */ struct mbuf *clc_hdr; /* cached pkt hdr (finally)! */};#ifndef satosiso#define satosiso(sa)\ ((struct sockaddr_iso *)(sa))#endif#ifdef KERNELcaddr_t clnp_insert_addr();struct iso_addr *clnp_srcaddr();struct mbuf *clnp_reass();#ifdef TROLLstruct troll trollctl;#endif /* TROLL */#endif /* KERNEL */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -