introduce dns for syslog too

This commit is contained in:
Wolfgang Hottgenroth 2020-11-27 12:49:03 +01:00
parent 7aded82145
commit b4ef9d29f9
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F

View File

@ -69,16 +69,28 @@ int logExec() {
void syslog(char *msg) {
static uint8_t state = 0;
int8_t res8 = 0;
int32_t res32 = 0;
if (isNetworkAvailable()) {
switch (state) {
case 0:
res8 = socket(SYSLOG_SOCK, Sn_MR_UDP, 514, SF_IO_NONBLOCK);
if (res8 == SYSLOG_SOCK) {
state = 1;
if (res8 != SYSLOG_SOCK) {
break;
}
break;
state = 1;
// no break
case 1:
sendto(SYSLOG_SOCK, (uint8_t*)msg, strlen(msg), syslogAddr, 514);
if (! wizDnsQuery("syslogserver", syslogAddr)) {
disconnect(SYSLOG_SOCK);
state = 0;
break;
}
res32 = sendto(SYSLOG_SOCK, (uint8_t*)msg, strlen(msg), syslogAddr, 514);
if (res32 != strlen(msg)) {
disconnect(SYSLOG_SOCK);
state = 0;
}
break;
}
}