205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
}
/* Log a message */
#ifdef FILED_DONT_LOG
# define filed_logging_thread_init(x) 0
# define filed_log_msg_debug(x, ...) /**/
# define filed_log_msg(x, ...) /**/
#else
#ifdef FILED_DEBUG
# define filed_log_msg_debug(x, ...) { fprintf(stderr, x, __VA_ARGS__); fprintf(stderr, "\n"); fflush(stderr); }
#else
# define filed_log_msg_debug(x, ...) /**/
#endif
|
>
|
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
}
/* Log a message */
#ifdef FILED_DONT_LOG
# define filed_logging_thread_init(x) 0
# define filed_log_msg_debug(x, ...) /**/
# define filed_log_msg(x, ...) /**/
# define filed_log_ip(x, ...) "<unknown>"
#else
#ifdef FILED_DEBUG
# define filed_log_msg_debug(x, ...) { fprintf(stderr, x, __VA_ARGS__); fprintf(stderr, "\n"); fflush(stderr); }
#else
# define filed_log_msg_debug(x, ...) /**/
#endif
|
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
pthread_mutex_unlock(&filed_log_msg_list_mutex);
pthread_cond_signal(&filed_log_msg_list_ready);
return;
}
#endif
/* Format time per RFC2616 */
static char *filed_format_time(char *buffer, size_t buffer_len, const time_t timeinfo) {
struct tm timeinfo_tm, *timeinfo_tm_p;
timeinfo_tm_p = gmtime_r(&timeinfo, &timeinfo_tm);
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
pthread_mutex_unlock(&filed_log_msg_list_mutex);
pthread_cond_signal(&filed_log_msg_list_ready);
return;
}
static const char *filed_log_ip(struct sockaddr *addr, char *buffer, size_t bufferlen) {
struct sockaddr_in *addr_v4;
struct sockaddr_in6 *addr_v6;
const char *retval = NULL;
addr_v6 = (struct sockaddr_in6 *) addr;
switch (addr_v6->sin6_family) {
case AF_INET:
addr_v4 = (struct sockaddr_in *) addr;
retval = inet_ntop(AF_INET, &addr_v4->sin_addr, buffer, bufferlen);
break;
case AF_INET6:
retval = inet_ntop(AF_INET6, &addr_v6->sin6_addr, buffer, bufferlen);
break;
}
if (retval == NULL) {
retval = "<unknown>";
}
return(retval);
}
#endif
/* Format time per RFC2616 */
static char *filed_format_time(char *buffer, size_t buffer_len, const time_t timeinfo) {
struct tm timeinfo_tm, *timeinfo_tm_p;
timeinfo_tm_p = gmtime_r(&timeinfo, &timeinfo_tm);
|
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
|
failure_count++;
continue;
}
/* Log the new connection */
filed_log_msg("NEW_CONNECTION SRC_ADDR=%s SRC_PORT=%lu FD=%i",
inet_ntop(AF_INET6, &addr.sin6_addr, logbuf_ip, sizeof(logbuf_ip)) ? logbuf_ip : "<unknown>",
(unsigned long) addr.sin6_port,
fd
);
/* Reset failure count*/
failure_count = 0;
|
|
|
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
|
failure_count++;
continue;
}
/* Log the new connection */
filed_log_msg("NEW_CONNECTION SRC_ADDR=%s SRC_PORT=%lu FD=%i",
filed_log_ip((struct sockaddr *) &addr, logbuf_ip, sizeof(logbuf_ip)),
(unsigned long) addr.sin6_port,
fd
);
/* Reset failure count*/
failure_count = 0;
|