Browse code

core: more comments about data lump structure fields and options

Daniel-Constantin Mierla authored on 09/09/2020 13:32:33
Showing 1 changed files
... ...
@@ -16,8 +16,8 @@
16 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 17
  * GNU General Public License for more details.
18 18
  *
19
- * You should have received a copy of the GNU General Public License 
20
- * along with this program; if not, write to the Free Software 
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program; if not, write to the Free Software
21 21
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 22
  */
23 23
 /*!
... ...
@@ -35,20 +35,21 @@
35 35
 
36 36
 
37 37
 enum lump_op { LUMP_NOP=0, LUMP_DEL, LUMP_ADD, LUMP_ADD_SUBST, LUMP_ADD_OPT };
38
-enum lump_subst{ SUBST_NOP=0,                       /* do nothing */
39
-				 SUBST_RCV_IP,     SUBST_SND_IP,    /* add ip address */
40
-				 SUBST_RCV_PORT,   SUBST_SND_PORT,  /* add port no */
41
-				 SUBST_RCV_PROTO,  SUBST_SND_PROTO, /* add protocol(udp,tcp,tls)*/
42
-				 SUBST_RCV_ALL,    SUBST_SND_ALL,   /* ip:port;transport=proto */
43
-				 SUBST_RCV_ALL_EX, SUBST_SND_ALL_EX /* ip:port;transport=proto;sn=xyz */
44
-				};
38
+
39
+enum lump_subst{ SUBST_NOP=0,                  /* do nothing */
40
+			SUBST_RCV_IP,     SUBST_SND_IP,    /* add ip address */
41
+			SUBST_RCV_PORT,   SUBST_SND_PORT,  /* add port no */
42
+			SUBST_RCV_PROTO,  SUBST_SND_PROTO, /* add protocol(udp,tcp,tls)*/
43
+			SUBST_RCV_ALL,    SUBST_SND_ALL,   /* ip:port;transport=proto */
44
+			SUBST_RCV_ALL_EX, SUBST_SND_ALL_EX /* ip:port;transport=proto;sn=xyz */
45
+		};
45 46
 				/* Where:
46
-				   SND = sending, e.g the src ip of the outgoing message
47
-				   RCV = received e.g the dst ip of the original incoming msg,
48
-				    or the ip of the ser socket on which the msg was received
49
-				   For SUBST_{RCV,SND}_ALL, :port is added only if port!=5060
50
-				    and transport=proto only if proto!=udp
51
-					*/
47
+				 * SND = sending, e.g the src ip of the outgoing message
48
+				 * RCV = received e.g the dst ip of the original incoming msg,
49
+				 *  or the ip of the ser socket on which the msg was received
50
+				 * For SUBST_{RCV,SND}_ALL, :port is added only if port!=5060
51
+				 * and transport=proto only if proto!=udp
52
+				 */
52 53
 
53 54
 enum lump_conditions {	COND_FALSE,         /* always false */
54 55
 						COND_TRUE,          /* always true */
... ...
@@ -59,14 +60,20 @@ enum lump_conditions {	COND_FALSE,         /* always false */
59 60
 						COND_IF_DIFF_IP,    /* true if RCV ip != SND ip */
60 61
 						COND_IF_RAND        /* 50-50 random prob.of being true*/
61 62
 						};
62
-						/* Where: 
63
-						   REALM= ip_addr:port:proto
64
-						   af   = address family (ipv4 or ipv6)
65
-						   proto = protocol (tcp, udp, tls)
63
+						/* Where:
64
+						 * REALM= ip_addr:port:proto
65
+						 * af   = address family (ipv4 or ipv6)
66
+						 * proto = protocol (tcp, udp, tls)
66 67
 						*/
67 68
 
68
-enum lump_flag { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2,
69
-	LUMPFLAG_BRANCH=4, LUMPFLAG_COND_TRUE=8 };
69
+enum lump_flag { LUMPFLAG_NONE=0,  /* */
70
+	LUMPFLAG_DUPED=1,              /* lump struct duplicated in pkg, with value
71
+									* pointing to initial lump structure
72
+									* - e.g., used for branch_route execution */
73
+	LUMPFLAG_SHMEM=2,              /* lump stored in shared memory (e.g., tm) */
74
+	LUMPFLAG_BRANCH=4,             /* not in use ?!? */
75
+	LUMPFLAG_COND_TRUE=8           /* conditional lump processing */
76
+};
70 77
 
71 78
 #define LUMP_SET_COND_TRUE(_lump)	 (_lump)->flags |= LUMPFLAG_COND_TRUE
72 79
 #define LUMP_IS_COND_TRUE(_lump)	 ((_lump)->flags & LUMPFLAG_COND_TRUE)
... ...
@@ -74,7 +81,7 @@ enum lump_flag { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2,
74 81
 typedef struct lump{
75 82
 	enum _hdr_types_t type; /* HDR_VIA_T, HDR_OTHER_T (0), ... */
76 83
 	enum lump_op op;   /* DEL, ADD, NOP, UNSPEC(=0) */
77
-	
84
+
78 85
 	union{
79 86
 		int offset; /* used for DEL, MODIFY */
80 87
 		enum lump_subst subst; /*what to subst: ip addr, port, proto*/
... ...
@@ -82,13 +89,13 @@ typedef struct lump{
82 89
 		char * value; /* used for ADD */
83 90
 	}u;
84 91
 	int len; /* length of this header field */
85
-	
86
-	
92
+
93
+
87 94
 	struct lump* before; /* list of headers to be inserted in front of the
88 95
 								current one */
89
-	struct lump* after; /* list of headers to be inserted immediately after
90
-							  the current one */
91
-	
96
+	struct lump* after;    /* list of headers to be inserted immediately after
97
+							* the current one */
98
+
92 99
 	struct lump* next;
93 100
 
94 101
 	enum lump_flag flags; /* additional hints for use from TM's shmem */
... ...
@@ -98,7 +105,7 @@ typedef struct lump{
98 105
 /*
99 106
  * hdrs must be kept sorted after their offset (DEL, NOP, UNSPEC)
100 107
  * and/or their position (ADD). E.g.:
101
- *  - to delete header Z insert it in to the list according to its offset 
108
+ *  - to delete header Z insert it in to the list according to its offset
102 109
  *   and with op=DELETE
103 110
  * - if you want to add a new header X after a  header Y, insert Y in the list
104 111
  *   with op NOP and after it X (op ADD).
... ...
@@ -107,11 +114,11 @@ typedef struct lump{
107 114
  *  -if you want to replace Y with X, insert Y with op=DELETE and then X with
108 115
  *  op=ADD.
109 116
  * before and after must contain only ADD ops!
110
- * 
117
+ *
111 118
  * Difference between "after" & "next" when Adding:
112 119
  * "after" forces the new header immediately after the current one while
113 120
  * "next" means another header can be inserted between them.
114
- * 
121
+ *
115 122
  */
116 123
 
117 124
 /* frees the content of a lump struct */