/* * refclock_report - note the occurance of an event * * This routine presently just remembers the report and logs it, but * does nothing heroic for the trap handler. It tries to be a good * citizen and bothers the system log only if things change. */ void refclock_report( struct peer *peer, int code ) { struct refclockproc *pp; if (!(pp = peer->procptr)) return; if (code == CEVNT_BADREPLY) pp->badformat++; if (code == CEVNT_BADTIME) pp->baddata++; if (code == CEVNT_TIMEOUT) pp->noreply++; if (pp->currentstatus != code) { pp->currentstatus = code; pp->lastevent = code; if (code == CEVNT_FAULT) msyslog(LOG_ERR, "clock %s event '%s' (0x%02x)", refnumtoa(peer->srcadr.sin_addr.s_addr), ceventstr(code), code); else { NLOG(NLOG_CLOCKEVENT) msyslog(LOG_INFO, "clock %s event '%s' (0x%02x)", refnumtoa(peer->srcadr.sin_addr.s_addr), ceventstr(code), code); } } #ifdef DEBUG if (debug) printf("clock %s event '%s' (0x%02x)\n", refnumtoa(peer->srcadr.sin_addr.s_addr), ceventstr(code), code); #endif }
/* * refclock_report - note the occurance of an event * * This routine presently just remembers the report and logs it, but * does nothing heroic for the trap handler. It tries to be a good * citizen and bothers the system log only if things change. */ void refclock_report( struct peer *peer, int code ) { struct refclockproc *pp; pp = peer->procptr; if (pp == NULL) return; switch (code) { case CEVNT_TIMEOUT: pp->noreply++; break; case CEVNT_BADREPLY: pp->badformat++; break; case CEVNT_FAULT: break; case CEVNT_BADDATE: case CEVNT_BADTIME: pp->baddata++; break; default: /* ignore others */ break; } if (pp->lastevent < 15) pp->lastevent++; if (pp->currentstatus != code) { pp->currentstatus = (u_char)code; report_event(PEVNT_CLOCK, peer, ceventstr(code)); } }
TEST(statestr, ClockCodeUnknown) { TEST_ASSERT_EQUAL_STRING("clk_-1", ceventstr(-1)); }
/* * refclock_report - note the occurance of an event * * This routine presently just remembers the report and logs it, but * does nothing heroic for the trap handler. It tries to be a good * citizen and bothers the system log only if things change. */ void refclock_report( struct peer *peer, int code ) { struct refclockproc *pp; pp = peer->procptr; if (pp == NULL) return; switch (code) { case CEVNT_NOMINAL: break; case CEVNT_TIMEOUT: pp->noreply++; break; case CEVNT_BADREPLY: pp->badformat++; break; case CEVNT_FAULT: break; case CEVNT_PROP: break; case CEVNT_BADDATE: case CEVNT_BADTIME: pp->baddata++; break; default: /* shouldn't happen */ break; } if (pp->currentstatus != code) { pp->currentstatus = (u_char)code; /* RFC1305: copy only iff not CEVNT_NOMINAL */ if (code != CEVNT_NOMINAL) pp->lastevent = (u_char)code; if (code == CEVNT_FAULT) msyslog(LOG_ERR, "clock %s event '%s' (0x%02x)", refnumtoa(&peer->srcadr), ceventstr(code), code); else { NLOG(NLOG_CLOCKEVENT) msyslog(LOG_INFO, "clock %s event '%s' (0x%02x)", refnumtoa(&peer->srcadr), ceventstr(code), code); } /* RFC1305: post peer clock event */ report_event(EVNT_PEERCLOCK, peer); } }
// ceventstr() TEST(statestr, ClockCodeExists) { TEST_ASSERT_EQUAL_STRING("clk_unspec", ceventstr(CTL_CLK_OKAY)); }