263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
struct sockaddr_in addr_v4;
struct sockaddr *addr;
socklen_t addr_len;
int pton_ret, bind_ret, listen_ret;
int family;
int fd;
family = AF_INET6;
pton_ret = inet_pton(family, address, &addr_v6.sin6_addr.s6_addr);
if (pton_ret != 1) {
family = AF_INET;
pton_ret = inet_pton(family, address, &addr_v4.sin_addr.s_addr);
if (pton_ret != 1) {
return(-1);
|
<
|
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
struct sockaddr_in addr_v4;
struct sockaddr *addr;
socklen_t addr_len;
int pton_ret, bind_ret, listen_ret;
int family;
int fd;
family = AF_INET6;
pton_ret = inet_pton(family, address, &addr_v6.sin6_addr.s6_addr);
if (pton_ret != 1) {
family = AF_INET;
pton_ret = inet_pton(family, address, &addr_v4.sin_addr.s_addr);
if (pton_ret != 1) {
return(-1);
|
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
#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_entry(x) /**/
# define filed_log_ip(x, ...) NULL
# define filed_log_new(x) &local_dummy_log
# define filed_log_open(x) stdout
#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
/* Initialize logging thread */
|
|
>
>
>
>
>
>
>
|
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
#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_entry(x) /**/
# define filed_log_ip(x, ...) NULL
# define filed_log_new(x) &local_dummy_log
# define filed_log_free(x) /**/
/* Return logging handle */
static FILE *filed_log_open(const char *file) {
return(stdout);
file = file;
}
#else
# define filed_log_free(x) free(x)
# 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
/* Initialize logging thread */
|
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
|
*/
if (fd < 0) {
/* Log the new connection */
filed_log_msg("ACCEPT_FAILED");
failure_count++;
free(log);
continue;
}
/* Fill in log structure */
if (filed_log_ip((struct sockaddr *) &addr, log->ip, sizeof(log->ip)) == NULL) {
log->ip[0] = '\0';
|
|
|
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
|
*/
if (fd < 0) {
/* Log the new connection */
filed_log_msg("ACCEPT_FAILED");
failure_count++;
filed_log_free(log);
continue;
}
/* Fill in log structure */
if (filed_log_ip((struct sockaddr *) &addr, log->ip, sizeof(log->ip)) == NULL) {
log->ip[0] = '\0';
|