51 #include <sys/socket.h> 52 #include <netinet/in.h> 62 #define RECV_BUF_SZ 1024 67 DLT_STRING(
"dlt-system-syslog, init socket, port: "),
71 struct sockaddr_in syslog_addr;
74 sock = socket(AF_INET6, SOCK_DGRAM, 0);
76 sock = socket(AF_INET, SOCK_DGRAM, 0);
81 DLT_STRING(
"Unable to create socket for SYSLOG."));
86 syslog_addr.sin_family = AF_INET6;
88 syslog_addr.sin_family = AF_INET;
90 syslog_addr.sin_port = htons(opts.
Port);
91 syslog_addr.sin_addr.s_addr = INADDR_ANY;
92 bzero(&(syslog_addr.sin_zero), 8);
94 if (bind(sock, (
struct sockaddr *)&syslog_addr,
95 sizeof(
struct sockaddr)) == -1)
98 DLT_STRING(
"Unable to bind socket for SYSLOG."));
109 DLT_STRING(
"dlt-system-syslog, read socket"));
111 struct sockaddr_in client_addr;
112 socklen_t addr_len =
sizeof(
struct sockaddr_in);
114 int bytes_read = recvfrom(sock, recv_data,
RECV_BUF_SZ, 0,
115 (
struct sockaddr *) &client_addr, &addr_len);
125 DLT_STRING(
"Read from socket failed in SYSLOG."));
130 recv_data[bytes_read] =
'\0';
147 int sock = init_socket(conf->
Syslog);
165 DLT_STRING(
"dlt-system-syslog, start syslog"));
166 static pthread_attr_t t_attr;
DLT_IMPORT_CONTEXT(dltsystem)
int read_socket(int sock)
#define DLT_DECLARE_CONTEXT(CONTEXT)
#define DLT_REGISTER_CONTEXT(CONTEXT, CONTEXTID, DESCRIPTION)
#define DLT_LOG(CONTEXT, LOGLEVEL, ARGS...)
void start_syslog(DltSystemConfiguration *conf)
void syslog_thread(void *v_conf)
pthread_t threads[MAX_THREADS]