Fix the IP address display.

This commit is contained in:
Jonathan Naylor 2021-02-13 15:43:29 +00:00
parent 49824f6a09
commit 4d941e4834
2 changed files with 14 additions and 17 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016,2018,2020 by Jonathan Naylor G4KLX * Copyright (C) 2016,2018,2020,2021 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -214,7 +214,7 @@ void CP25Reflector::run()
if (rpt == NULL) { if (rpt == NULL) {
rpt = new CP25Repeater; rpt = new CP25Repeater;
rpt->m_timer.start(); rpt->m_timer.start();
rpt->m_addr = addr; ::memcpy(&rpt->m_addr, &addr, sizeof(struct sockaddr_storage));
rpt->m_addrLen = addrLen; rpt->m_addrLen = addrLen;
rpt->m_callsign = std::string((char*)(buffer + 1U), 10U); rpt->m_callsign = std::string((char*)(buffer + 1U), 10U);
m_repeaters.push_back(rpt); m_repeaters.push_back(rpt);
@ -232,10 +232,9 @@ void CP25Reflector::run()
LogMessage("Removing %s (%s) unlinked", rpt->m_callsign.c_str(), CUDPSocket::display(addr, buff, 80U)); LogMessage("Removing %s (%s) unlinked", rpt->m_callsign.c_str(), CUDPSocket::display(addr, buff, 80U));
for (std::vector<CP25Repeater*>::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) { for (std::vector<CP25Repeater*>::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
CP25Repeater* itRpt = *it; if (CUDPSocket::match((*it)->m_addr, rpt->m_addr)) {
if (CUDPSocket::match(itRpt->m_addr, rpt->m_addr)) {
m_repeaters.erase(it); m_repeaters.erase(it);
delete itRpt; delete *it;
break; break;
} }
} }
@ -300,13 +299,13 @@ void CP25Reflector::run()
(*it)->m_timer.clock(ms); (*it)->m_timer.clock(ms);
for (std::vector<CP25Repeater*>::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) { for (std::vector<CP25Repeater*>::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
CP25Repeater* itRpt = *it; if ((*it)->m_timer.hasExpired()) {
if (itRpt->m_timer.hasExpired()) {
char buff[80U]; char buff[80U];
LogMessage("Removing %s (%s) disappeared", itRpt->m_callsign.c_str(), CUDPSocket::display(itRpt->m_addr, buff, 80U)); LogMessage("Removing %s (%s) disappeared", (*it)->m_callsign.c_str(),
CUDPSocket::display((*it)->m_addr, buff, 80U));
m_repeaters.erase(it); m_repeaters.erase(it);
delete itRpt; delete *it;
break; break;
} }
} }
@ -355,12 +354,10 @@ void CP25Reflector::dumpRepeaters() const
LogMessage("Currently linked repeaters:"); LogMessage("Currently linked repeaters:");
for (std::vector<CP25Repeater*>::const_iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) { for (std::vector<CP25Repeater*>::const_iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
std::string callsign = (*it)->m_callsign;
sockaddr_storage addr = (*it)->m_addr;
unsigned int timer = (*it)->m_timer.getTimer();
unsigned int timeout = (*it)->m_timer.getTimeout();
char buffer[80U]; char buffer[80U];
LogMessage(" %s: %s %u/%u", callsign.c_str(), CUDPSocket::display(addr, buffer, 80U), timer, timeout); LogMessage(" %s: %s %u/%u", (*it)->m_callsign.c_str(),
CUDPSocket::display((*it)->m_addr, buffer, 80U),
(*it)->m_timer.getTimeout(),
(*it)->m_timer.getTimeout());
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2020,2021 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -19,6 +19,6 @@
#if !defined(VERSION_H) #if !defined(VERSION_H)
#define VERSION_H #define VERSION_H
const char* VERSION = "20201124"; const char* VERSION = "20210213";
#endif #endif