00001 // 00002 // header.hh : Diffusion Datagram Header 00003 // authors : Chalermek Intanagonwiwat and Fabio Silva 00004 // 00005 // Copyright (C) 2000-2002 by the University of Southern California 00006 // $Id: header.hh,v 1.8 2006/02/21 15:20:18 mahrenho Exp $ 00007 // 00008 // This program is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU General Public License, 00010 // version 2, as published by the Free Software Foundation. 00011 // 00012 // This program is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License along 00018 // with this program; if not, write to the Free Software Foundation, Inc., 00019 // 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 00020 // 00021 // Linking this file statically or dynamically with other modules is making 00022 // a combined work based on this file. Thus, the terms and conditions of 00023 // the GNU General Public License cover the whole combination. 00024 // 00025 // In addition, as a special exception, the copyright holders of this file 00026 // give you permission to combine this file with free software programs or 00027 // libraries that are released under the GNU LGPL and with code included in 00028 // the standard release of ns-2 under the Apache 2.0 license or under 00029 // otherwise-compatible licenses with advertising requirements (or modified 00030 // versions of such code, with unchanged license). You may copy and 00031 // distribute such a system following the terms of the GNU GPL for this 00032 // file and the licenses of the other code concerned, provided that you 00033 // include the source code of that other code when and as the GNU GPL 00034 // requires distribution of source code. 00035 // 00036 // Note that people who make modified versions of this file are not 00037 // obligated to grant this special exception for their modified versions; 00038 // it is their choice whether to do so. The GNU General Public License 00039 // gives permission to release a modified version without this exception; 00040 // this exception also makes it possible to release a modified version 00041 // which carries forward this exception. 00042 00043 #ifndef _HEADER_HH_ 00044 #define _HEADER_HH_ 00045 00046 #ifdef HAVE_CONFIG_H 00047 #include "config.h" 00048 #endif // HAVE_CONFIG_H 00049 00050 #include "nr/nr.hh" 00051 00052 typedef int *DiffPacket; 00053 00054 #define MAX_PKT_SIZE 8192 00055 #define BROADCAST_ADDR -1 00056 #define LOCALHOST_ADDR -2 00057 #define DIFFUSION_VERSION 3 00058 00059 #ifdef NS_DIFFUSION 00060 #define DEFAULT_DIFFUSION_PORT 255 00061 #else 00062 #define DEFAULT_DIFFUSION_PORT 2000 00063 #endif // NS_DIFFUSION 00064 00065 #define DIFFUSION_PORT DEFAULT_DIFFUSION_PORT 00066 00067 // For accessing fields in the diffusion header 00068 #define LAST_HOP(x) (x)->last_hop 00069 #define NEXT_HOP(x) (x)->next_hop 00070 #define DIFF_VER(x) (x)->version 00071 #define MSG_TYPE(x) (x)->msg_type 00072 #define DATA_LEN(x) (x)->data_len 00073 #define PKT_NUM(x) (x)->pkt_num 00074 #define RDM_ID(x) (x)->rdm_id 00075 #define NUM_ATTR(x) (x)->num_attr 00076 #define SRC_PORT(x) (x)->src_port 00077 00078 // Message types 00079 typedef enum msg_t_ { 00080 INTEREST, 00081 POSITIVE_REINFORCEMENT, 00082 NEGATIVE_REINFORCEMENT, 00083 DATA, 00084 EXPLORATORY_DATA, 00085 PUSH_EXPLORATORY_DATA, 00086 CONTROL, 00087 REDIRECT 00088 } diff_msg_t; 00089 00090 // Header structure 00091 struct hdr_diff { 00092 int32_t last_hop; // forwarder node id 00093 int32_t next_hop; // next hop node id 00094 int8_t version; // protocol version 00095 int8_t msg_type; // message type 00096 int16_t data_len; // data length 00097 int32_t pkt_num; // packet number 00098 int32_t rdm_id; // random id 00099 int16_t num_attr; // number of attributes 00100 int16_t src_port; // sender port id 00101 }; 00102 00103 #define HDR_DIFF(x) (struct hdr_diff *)(x) 00104 00105 #endif // !_HEADER_HH_