@@ -59,10 +59,11 @@ is_var(const char * const var, const char * const cmd_str)
59
59
}
60
60
61
61
static int
62
- build_cmd (spa_data_t * spadat , const char * const cmd_cycle_str )
62
+ build_cmd (spa_data_t * spadat , const char * const cmd_cycle_str , int timer )
63
63
{
64
64
char port_str [MAX_PORT_STR_LEN + 1 ] = {0 };
65
65
char proto_str [MAX_PROTO_STR_LEN + 1 ] = {0 };
66
+ char timestamp_str [20 ] = {0 };
66
67
acc_port_list_t * port_list = NULL ;
67
68
int i = 0 , buf_idx = 0 ;
68
69
@@ -137,6 +138,14 @@ build_cmd(spa_data_t *spadat, const char * const cmd_cycle_str)
137
138
i += strlen ("PROTO" );
138
139
buf_idx += strlen (proto_str );
139
140
}
141
+ else if (is_var ("TIMEOUT" , (cmd_cycle_str + i + 1 )))
142
+ {
143
+ snprintf (timestamp_str , sizeof (timestamp_str ), "%lli" , (long long )spadat -> timestamp +
144
+ (spadat -> client_timeout == 0 ? timer : spadat -> client_timeout ));
145
+ strlcat (cmd_buf , timestamp_str , CMD_CYCLE_BUFSIZE );
146
+ i += strlen ("TIMEOUT" );
147
+ buf_idx += strlen (timestamp_str );
148
+ }
140
149
continue ;
141
150
}
142
151
if (cmd_cycle_str [i ] != '\0' )
@@ -159,7 +168,7 @@ cmd_open(fko_srv_options_t *opts, acc_stanza_t *acc,
159
168
/* CMD_CYCLE_OPEN: Build the open command by taking care of variable
160
169
* substitutions if necessary.
161
170
*/
162
- if (build_cmd (spadat , acc -> cmd_cycle_open ))
171
+ if (build_cmd (spadat , acc -> cmd_cycle_open , acc -> cmd_cycle_timer ))
163
172
{
164
173
log_msg (LOG_INFO , "[%s] (stanza #%d) Running CMD_CYCLE_OPEN command: %s" ,
165
174
spadat -> pkt_source_ip , stanza_num , cmd_buf );
@@ -191,15 +200,15 @@ add_cmd_close(fko_srv_options_t *opts, acc_stanza_t *acc,
191
200
/* CMD_CYCLE_CLOSE: Build the close command, but don't execute it until
192
201
* the expiration timer has passed.
193
202
*/
194
- if (build_cmd (spadat , acc -> cmd_cycle_close ))
203
+ if (build_cmd (spadat , acc -> cmd_cycle_close , acc -> cmd_cycle_timer ))
195
204
{
196
205
/* Now the corresponding close command is now in cmd_buf
197
206
* for later execution when the timer expires.
198
207
*/
199
208
cmd_close_len = strnlen (cmd_buf , CMD_CYCLE_BUFSIZE - 1 )+ 1 ;
200
209
log_msg (LOG_INFO ,
201
210
"[%s] (stanza #%d) Running CMD_CYCLE_CLOSE command in %d seconds: %s" ,
202
- spadat -> pkt_source_ip , stanza_num , acc -> cmd_cycle_timer , cmd_buf );
211
+ spadat -> pkt_source_ip , stanza_num , ( spadat -> client_timeout == 0 ? acc -> cmd_cycle_timer : spadat -> client_timeout ) , cmd_buf );
203
212
}
204
213
else
205
214
{
@@ -244,7 +253,7 @@ add_cmd_close(fko_srv_options_t *opts, acc_stanza_t *acc,
244
253
/* Set the expiration timer
245
254
*/
246
255
time (& now );
247
- new_clist -> expire = now + acc -> cmd_cycle_timer ;
256
+ new_clist -> expire = now + ( spadat -> client_timeout == 0 ? acc -> cmd_cycle_timer : spadat -> client_timeout ) ;
248
257
249
258
/* Set the close command
250
259
*/
0 commit comments