File: cgr.h

package info (click to toggle)
ion 3.2.1%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 23,768 kB
  • ctags: 11,049
  • sloc: ansic: 141,798; sh: 22,848; makefile: 7,818; python: 1,638; sql: 311; perl: 197; awk: 178; xml: 50; java: 19
file content (144 lines) | stat: -rw-r--r-- 3,832 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
 	cgr.h:	definitions supporting the utilization of Contact
		Graph Routing in forwarding infrastructure.

	Author: Scott Burleigh, JPL

	Modification History:
	Date      Who   What

	Copyright (c) 2011, California Institute of Technology.
	ALL RIGHTS RESERVED.  U.S. Government Sponsorship
	acknowledged.
 									*/
#ifndef _CGR_H_
#define _CGR_H_

#include "bpP.h"

#ifdef __cplusplus
extern "C" {
#endif

// A CGR tracepoint
typedef enum {
	// CgrBuildRoutes(uvast stationNode, unsigned int payloadLength,
	//                unsigned int atTime)
	CgrBuildRoutes,
	// CgrInvalidStationNode(void)
	CgrInvalidStationNode,

	// CgrBeginRoute(int payloadClass)
	CgrBeginRoute,
	// CgrConsiderRoot(uvast fromNode, uvast toNode)
	CgrConsiderRoot,
	// CgrConsiderContact(uvast fromNode, uvast toNode)
	CgrConsiderContact,
	// CgrIgnoreContact(CgrReason reason)
	CgrIgnoreContact,

	// CgrCost(unsigned int transmitTime, unsigned int owlt,
	//         unsigned int arrivalTime)
	CgrCost,
	// CgrHop(uvast fromNode, uvast toNode)
	CgrHop,

	// CgrAcceptRoute(uvast firstHop, unsigned int fromTime,
	//                unsigned int deliveryTime, uvast maxCapacity,
	//                int payloadClass)
	CgrAcceptRoute,
	// CgrDiscardRoute(void)
	CgrDiscardRoute,

	// CgrIdentifyProximateNodes(unsigned int deadline)
	CgrIdentifyProximateNodes,
	// CgrCheckRoute(int payloadClass, uvast firstHop, unsigned int fromTime,
	//               unsigned int deliveryTime)
	CgrCheckRoute,
	// CgrRecomputeRoute(void)
	CgrRecomputeRoute,
	// CgrIgnoreRoute(CgrReason reason)
	CgrIgnoreRoute,
	// CgrAddProximateNode(void)
	CgrAddProximateNode,
	// CgrUpdateProximateNode(CgrReason reason)
	CgrUpdateProximateNode,

	// CgrSelectProximateNodes(void)
	CgrSelectProximateNodes,
	// CgrUseAllProximateNodes(void)
	CgrUseAllProximateNodes,
	// CgrConsiderProximateNode(uvast proxNode)
	CgrConsiderProximateNode,
	// CgrSelectProximateNode(void)
	CgrSelectProximateNode,
	// CgrIgnoreProximateNode(CgrReason reason)
	CgrIgnoreProximateNode,
	// CgrUseProximateNode(uvast proxNode)
	CgrUseProximateNode,
	// CgrNoProximateNode(void)
	CgrNoProximateNode,

	// End of valid trace types
	CgrTraceTypeMax,
} CgrTraceType;

// Describes the reason CGR made a certain decision
typedef enum {
	// Reasons to ignore a contact (CgrIgnoreContact)
	CgrContactEndsEarly,
	CgrSuppressed,
	CgrVisited,
	CgrCapacityTooSmall,
	CgrNoRange,

	// Reasons to ignore a route (CgrIgnoreRoute)
	CgrRouteViaSelf,
	CgrRouteCapacityTooSmall,
	CgrInitialContactExcluded,
	CgrRouteTooSlow,
	CgrNoApplicableDirective,
	CgrBlockedOutduct,
	CgrMaxPayloadTooSmall,
	CgrNoResidualCapacity,
	CgrResidualCapacityTooSmall,

	// Reasons to ignore a proximate node (CgrIgnoreRoute,
	// CgrIgnoreProximateNode) or reasons a previously-selected proximate
	// node was ignored (CgrUpdateProximateNode)
	CgrMoreHops,
	CgrIdentical,
	CgrLaterDeliveryTime,
	CgrLargerNodeNbr,

	CgrReasonMax,
} CgrReason;

typedef int		(*CgrLookupFn)(uvast nodeNbr, Object plans,
				Bundle *bundle, FwdDirective *directive);
typedef void		(*CgrTraceFn)(void *data, unsigned int lineNbr,
				CgrTraceType traceType, ...);

typedef struct {
  // Callback function to call at tracepoints
  CgrTraceFn fn;
  // Data to pass into the callback function
  void *data;
} CgrTrace;

extern void		cgr_start();
extern int		cgr_forward(Bundle *bundle, Object bundleObj,
				uvast stationNodeNbr, Object plans,
				CgrLookupFn getDirective, CgrTrace *trace);
extern int		cgr_preview_forward(Bundle *bundle, Object bundleObj,
				uvast stationNodeNbr, Object plans,
				CgrLookupFn getDirective, time_t atTime,
				CgrTrace *trace);
extern const char	*cgr_tracepoint_text(CgrTraceType traceType);
extern const char	*cgr_reason_text(CgrReason reason);
extern void		cgr_stop();
#ifdef __cplusplus
}
#endif

#endif  /* _CGR_H_ */