diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-04-14 23:04:04 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-04-14 23:04:04 +0000 |
commit | db319329411e4b1db7e19e8cc5eb518525d107ad (patch) | |
tree | dddb463b1b5567290a52f49b6534d5a6f4015fde /packet-pgm.c | |
parent | 46a89d60f56997c8b859d67cd7f6b4442211f871 (diff) | |
download | wireshark-db319329411e4b1db7e19e8cc5eb518525d107ad.tar.gz wireshark-db319329411e4b1db7e19e8cc5eb518525d107ad.tar.bz2 wireshark-db319329411e4b1db7e19e8cc5eb518525d107ad.zip |
From Joerg Mayer:
Declares some variables static.
Creates a new include file packet-rsvp.h, and make use of it
(change some extern decls to #inlcude).
Move the file packet-pgm.h into packet-pgm.c as it is not used
by anything outside packet-pgm.c.
svn path=/trunk/; revision=5162
Diffstat (limited to 'packet-pgm.c')
-rw-r--r-- | packet-pgm.c | 223 |
1 files changed, 221 insertions, 2 deletions
diff --git a/packet-pgm.c b/packet-pgm.c index 27280a156d..dc5eb5c3f2 100644 --- a/packet-pgm.c +++ b/packet-pgm.c @@ -1,7 +1,7 @@ /* packet-pgm.c * Routines for pgm packet disassembly * - * $Id: packet-pgm.c,v 1.14 2002/01/21 07:36:38 guy Exp $ + * $Id: packet-pgm.c,v 1.15 2002/04/14 23:04:03 guy Exp $ * * Copyright (c) 2000 by Talarian Corp * @@ -46,7 +46,6 @@ #include <time.h> #include <string.h> #include <epan/packet.h> -#include "packet-pgm.h" #include "afn.h" #include "ipproto.h" #include <epan/resolv.h> @@ -59,6 +58,226 @@ void proto_reg_handoff_pgm(void); static void proto_rereg_pgm(void); +typedef guint8 nchar_t; +typedef guint16 nshort_t; +typedef guint32 nlong_t; + +/* The PGM main header */ +typedef struct { + nshort_t sport; /* source port */ + nshort_t dport; /* destination port */ + nchar_t type; /* PGM type */ + nchar_t opts; /* options */ + nshort_t cksum; /* checksum */ + nchar_t gsi[6]; /* Global Source ID */ + nshort_t tsdulen; /* TSDU length */ +} pgm_type; +#define pgmhdr_ntoh(_p) \ + (_p)->sport = ntohs((_p)->sport); \ + (_p)->dport = ntohs((_p)->dport); \ + (_p)->type = ntohs((_p)->type); \ + (_p)->opts = ntohs((_p)->opts); \ + (_p)->cksum = ntohs((_p)->cksum); \ + (_p)->tsdulen = ntohs((_p)->tsdulen) + +/* The PGM SPM header */ +typedef struct { + nlong_t sqn; /* SPM's sequence number */ + nlong_t trail; /* Trailing edge sequence number */ + nlong_t lead; /* Leading edge sequence number */ + nshort_t path_afi; /* NLA AFI */ + nshort_t res; /* reserved */ + nlong_t path; /* Path NLA */ +} pgm_spm_t; +static const size_t PGM_SPM_SZ = sizeof(pgm_type)+sizeof(pgm_spm_t); +#define spm_ntoh(_p) \ + (_p)->sqn = ntohl((_p)->sqn); \ + (_p)->trail = ntohl((_p)->trail); \ + (_p)->lead = ntohl((_p)->lead); \ + (_p)->path_afi = ntohs((_p)->path_afi); \ + (_p)->res = ntohs((_p)->res); + +/* The PGM Data (ODATA/RDATA) header */ +typedef struct { + nlong_t sqn; /* Data Packet sequence number */ + nlong_t trail; /* Trailing edge sequence number */ +} pgm_data_t; +#define data_ntoh(_p) \ + (_p)->sqn = ntohl((_p)->sqn); \ + (_p)->trail = ntohl((_p)->trail) +static const size_t PGM_DATA_HDR_SZ = sizeof(pgm_type)+sizeof(pgm_data_t); + +/* The PGM NAK (NAK/N-NAK/NCF) header */ +typedef struct { + nlong_t sqn; /* Requested sequence number */ + nshort_t src_afi; /* NLA AFI for source (IPv4 is set to 1) */ + nshort_t src_res; /* reserved */ + nlong_t src; /* Source NLA */ + nshort_t grp_afi; /* Multicast group AFI (IPv4 is set to 1) */ + nshort_t grp_res; /* reserved */ + nlong_t grp; /* Multicast group NLA */ +} pgm_nak_t; +static const size_t PGM_NAK_SZ = sizeof(pgm_type)+sizeof(pgm_nak_t); +#define nak_ntoh(_p) \ + (_p)->sqn = ntohl((_p)->sqn); \ + (_p)->src_afi = ntohs((_p)->src_afi); \ + (_p)->src_res = ntohs((_p)->src_res); \ + (_p)->grp_afi = ntohs((_p)->grp_afi); \ + (_p)->grp_res = ntohs((_p)->grp_res) + +/* The PGM ACK header (PGMCC) */ +typedef struct { + nlong_t rx_max_sqn; /* RX_MAX sequence number */ + nlong_t bitmap; /* Received Packet Bitmap */ +} pgm_ack_t; +static const size_t PGM_ACK_SZ = sizeof(pgm_type)+sizeof(pgm_ack_t); +#define ack_ntoh(_p) \ + (_p)->rx_max_sqn = ntohl((_p)->rx_max_sqn); \ + (_p)->bitmap = ntohl((_p)->bitmap) + +/* constants for hdr types */ +#if defined(PGM_SPEC_01_PCKTS) +/* old spec-01 types */ +#define PGM_SPM_PCKT 0x00 +#define PGM_ODATA_PCKT 0x10 +#define PGM_RDATA_PCKT 0x11 +#define PGM_NAK_PCKT 0x20 +#define PGM_NNAK_PCKT 0x21 +#define PGM_NCF_PCKT 0x30 +#else +/* spec-02 types (as well as spec-04+) */ +#define PGM_SPM_PCKT 0x00 +#define PGM_ODATA_PCKT 0x04 +#define PGM_RDATA_PCKT 0x05 +#define PGM_NAK_PCKT 0x08 +#define PGM_NNAK_PCKT 0x09 +#define PGM_NCF_PCKT 0x0A +#define PGM_ACK_PCKT 0x0D +#endif /* PGM_SPEC_01_PCKTS */ + +/* port swapping on NAK and NNAKs or not (default is to swap) */ +/* PGM_NO_PORT_SWAP */ + +/* option flags (main PGM header) */ +#define PGM_OPT 0x01 +#define PGM_OPT_NETSIG 0x02 +#define PGM_OPT_VAR_PKTLEN 0x40 +#define PGM_OPT_PARITY 0x80 + +/* option types */ +#define PGM_OPT_LENGTH 0x00 +#define PGM_OPT_END 0x80 +#define PGM_OPT_FRAGMENT 0x01 +#define PGM_OPT_NAK_LIST 0x02 +#define PGM_OPT_JOIN 0x03 +#define PGM_OPT_REDIRECT 0x07 +#define PGM_OPT_SYN 0x0D +#define PGM_OPT_FIN 0x0E +#define PGM_OPT_RST 0x0F +#define PGM_OPT_PARITY_PRM 0x08 +#define PGM_OPT_PARITY_GRP 0x09 +#define PGM_OPT_CURR_TGSIZE 0x0A +#define PGM_OPT_PGMCC_DATA 0x12 +#define PGM_OPT_PGMCC_FEEDBACK 0x13 + +static const nchar_t PGM_OPT_INVALID = 0x7F; + +/* OPX bit values */ +#define PGM_OPX_IGNORE 0x00 +#define PGM_OPX_INVAL 0x01 +#define PGM_OPX_DISCARD 0x10 + +/* option formats */ +typedef struct { + nchar_t type; + nchar_t len; + nchar_t opx; + nchar_t res; +} pgm_opt_generic_t; + +typedef struct { + nchar_t type; + nchar_t len; + nshort_t total_len; +} pgm_opt_length_t; + +typedef struct { + nchar_t type; + nchar_t len; + nchar_t opx; + nchar_t res; +} pgm_opt_nak_list_t; + +/* + * To squeeze the whole option into 255 bytes, we + * can only have 62 in the list + */ +#define PGM_MAX_NAK_LIST_SZ (62) + +typedef struct { + nchar_t type; + nchar_t len; + nchar_t opx; + nchar_t res; + nlong_t opt_join_min; +} pgm_opt_join_t; + +typedef struct { + nchar_t type; + nchar_t len; + nchar_t opx; + nchar_t po; + nlong_t prm_tgsz; +} pgm_opt_parity_prm_t; + +/* OPT_PARITY_PRM P and O bits */ +static const nchar_t PGM_OPT_PARITY_PRM_PRO = 0x2; +static const nchar_t PGM_OPT_PARITY_PRM_OND = 0x1; + +typedef struct { + nchar_t type; + nchar_t len; + nchar_t opx; + nchar_t res; + nlong_t prm_grp; +} pgm_opt_parity_grp_t; + +typedef struct { + nchar_t type; + nchar_t len; + nchar_t opx; + nchar_t res; + nlong_t prm_atgsz; +} pgm_opt_curr_tgsize_t; + +typedef struct { + nchar_t type; + nchar_t len; + nchar_t opx; + nchar_t res; + nlong_t tsp; + nshort_t acker_afi; + nshort_t res2; + nlong_t acker; +} pgm_opt_pgmcc_data_t; + +typedef struct { + nchar_t type; + nchar_t len; + nchar_t opx; + nchar_t res; + nlong_t tsp; + nshort_t acker_afi; + nshort_t loss_rate; + nlong_t acker; +} pgm_opt_pgmcc_feedback_t; + +/* + * Udp port for UDP encapsulation + */ +#define DEFAULT_UDP_ENCAP_UCAST_PORT 3055 +#define DEFAULT_UDP_ENCAP_MCAST_PORT 3056 + static int udp_encap_ucast_port = 0; static int udp_encap_mcast_port = 0; static int old_encap_ucast_port = 0; |