Check-in [2a36924161]
Overview
Comment:Updated to correctly display IPv4 address if bound to IPv4 addresses
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2a36924161d93af0871843b0d506dd6c0ff7d066
User & Date: rkeene on 2014-02-08 06:55:33
Other Links: manifest | tags
Context
2014-02-08
06:57
Filed 1.0 check-in: 235573fe1c user: rkeene tags: trunk, 1.0
06:55
Updated to correctly display IPv4 address if bound to IPv4 addresses check-in: 2a36924161 user: rkeene tags: trunk
06:43
Moved more file size variables to correct type and started reporting on completion of files check-in: 521131f382 user: rkeene tags: trunk
Changes

Modified filed.c from [99eaeee2ab] to [1f0badde9e].

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;