Debian Codegraph @

protolib/src/sim/ns/nsProtoManetKernel.h

raw
1 /*********************************************************************
2 *
3 * AUTHORIZATION TO USE AND DISTRIBUTE
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that:
7 *
8 * (1) source code distributions retain this paragraph in its entirety,
9 *
10 * (2) distributions including binary code include this paragraph in
11 * its entirety in the documentation or other materials provided
12 * with the distribution, and
13 *
14 * (3) all advertising materials mentioning features or use of this
15 * software display the following acknowledgment:
16 *
17 * "This product includes software written and developed
18 * by Brian Adamson, Joe Macker and Justin Dean of the
19 * Naval Research Laboratory (NRL)."
20 *
21 * The name of NRL, the name(s) of NRL employee(s), or any entity
22 * of the United States Government may not be used to endorse or
23 * promote products derived from this software, nor does the
24 * inclusion of the NRL written and developed software directly or
25 * indirectly suggest NRL or United States Government endorsement
26 * of this product.
27 *
28 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
29 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
30 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
31 ********************************************************************/
32
33 // New router template for adding a protocol to CMU extensions of ns2
34
35 #ifndef __ProtoManetKernel_h__
36 #define __ProtoManetKernel_h__
37
38 #include <cmu-trace.h>
39 #include <priqueue.h>
40 #include <rtqueue.h>
41 #include <rttable.h>
42 #include <classifier/classifier-port.h>
43 //#include <packet.h>
44 #include <red.h>
45 #include "protoDebug.h" // for DMSG()
46
47
48 #define CURRENT_TIME Scheduler::instance().clock()
49 #define INVALID -1 // invalid return value
50
51 class ProtolibMK; // forward decleration
52
53 /**
54 * @class BroadcastID
55 *
56 * @brief Broadcast ID Cache
57 */
58 class BroadcastID {
59 friend class ProtolibMK;
60 public:
61 BroadcastID(nsaddr_t i, u_int32_t b) { src = i; id = b; }
62 protected:
63 LIST_ENTRY(BroadcastID) link;
64 nsaddr_t src;
65 u_int32_t id;
66 double expire; // now + BCAST_ID_SAVE s
67 };
68
69 LIST_HEAD(bcache, BroadcastID);
70
71
72 /**
73 * @class ProtolibMK
74 *
75 * @brief The Routing Agent
76 */
77 class ProtolibMK: public Agent {
78
79 public:
80 ProtolibMK(nsaddr_t id); // constructor
81
82 void recv(Packet *p, Handler *);
83 void rt_failed(Packet *p);
84 int index;
85 void forward(Packet *p, nsaddr_t nexthop);// used to forward packets in entirety
86 bool bcastforward(Packet *p); // used to decied to forward broadcast packets back out interface. returns true if it does.
87
88 protected:
89 int idnumber;
90 int numberofforwards, numberofrecv;
91 int command(int, const char *const *);
92 int initialized() { return 1 && target_; }
93 NsObject* ProtolibMKFind(Packet* p); //used to see if listener is attached to node code modified from Classifier::find
94 Agent* manetpointer;
95 /*
96 * Packet TX Routines
97 */
98 void forward(char *copysh); // used for forwarding the sub header part of the packet
99
100 bcache bihead; // Broadcast ID Cache
101
102 /*
103 * A mechanism for logging the contents of the routing
104 * table.
105 */
106 Trace *logtarget;
107
108 /*
109 * A pointer to the network interface queue that sits
110 * between the "classifier" and the "link layer".
111 */
112 PriQueue *ifqueue;
113 /* for passing packets up to agents */
114 PortClassifier *dmux_;
115
116 };
117
118 #endif /* __ProtoManetKernel_h__ */
119
120
121
122
123
124
125
126
127
128