bfdd: constify satostr

Detect modifications to the `sockaddr_any` struct.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
Rafael Zalamena 2020-04-13 15:18:17 -03:00
parent 869dada534
commit 6e10bd9772
2 changed files with 4 additions and 4 deletions

View File

@ -1111,13 +1111,13 @@ static const char *get_diag_str(int diag)
return "N/A"; return "N/A";
} }
const char *satostr(struct sockaddr_any *sa) const char *satostr(const struct sockaddr_any *sa)
{ {
#define INETSTR_BUFCOUNT 8 #define INETSTR_BUFCOUNT 8
static char buf[INETSTR_BUFCOUNT][INET6_ADDRSTRLEN]; static char buf[INETSTR_BUFCOUNT][INET6_ADDRSTRLEN];
static int bufidx; static int bufidx;
struct sockaddr_in *sin = &sa->sa_sin; const struct sockaddr_in *sin = &sa->sa_sin;
struct sockaddr_in6 *sin6 = &sa->sa_sin6; const struct sockaddr_in6 *sin6 = &sa->sa_sin6;
bufidx += (bufidx + 1) % INETSTR_BUFCOUNT; bufidx += (bufidx + 1) % INETSTR_BUFCOUNT;
buf[bufidx][0] = 0; buf[bufidx][0] = 0;

View File

@ -529,7 +529,7 @@ void bs_state_handler(struct bfd_session *bs, int nstate);
void bs_echo_timer_handler(struct bfd_session *bs); void bs_echo_timer_handler(struct bfd_session *bs);
void bs_final_handler(struct bfd_session *bs); void bs_final_handler(struct bfd_session *bs);
void bs_set_slow_timers(struct bfd_session *bs); void bs_set_slow_timers(struct bfd_session *bs);
const char *satostr(struct sockaddr_any *sa); const char *satostr(const struct sockaddr_any *sa);
const char *diag2str(uint8_t diag); const char *diag2str(uint8_t diag);
int strtosa(const char *addr, struct sockaddr_any *sa); int strtosa(const char *addr, struct sockaddr_any *sa);
void integer2timestr(uint64_t time, char *buf, size_t buflen); void integer2timestr(uint64_t time, char *buf, size_t buflen);