print Devolution phone numbers during startup
This commit is contained in:
+14
-1
@@ -2483,7 +2483,7 @@ Action a_run_server_replay_log(
|
||||
}
|
||||
}
|
||||
|
||||
if (!state->ip_stack_addresses.empty() || !state->ppp_stack_addresses.empty()) {
|
||||
if (!state->ip_stack_addresses.empty() || !state->ppp_stack_addresses.empty() || !state->ppp_raw_addresses.empty()) {
|
||||
config_log.info("Starting IP/PPP stack simulator");
|
||||
ip_stack_simulator = make_shared<IPStackSimulator>(base, state);
|
||||
for (const auto& it : state->ip_stack_addresses) {
|
||||
@@ -2500,6 +2500,19 @@ Action a_run_server_replay_log(
|
||||
auto netloc = parse_netloc(it);
|
||||
string spec = (netloc.second == 0) ? ("T-PPPSR-" + netloc.first) : string_printf("T-PPPSR-%hu", netloc.second);
|
||||
ip_stack_simulator->listen(spec, netloc.first, netloc.second, IPStackSimulator::Protocol::HDLC_RAW);
|
||||
if (netloc.second) {
|
||||
if (state->local_address == state->external_address) {
|
||||
config_log.info(
|
||||
"Note: The Devolution phone number for %s is %" PRIu64,
|
||||
spec.c_str(), devolution_phone_number_for_netloc(state->local_address, netloc.second));
|
||||
} else {
|
||||
config_log.info(
|
||||
"Note: The Devolution phone numbers for %s are %" PRIu64 " (local) and %" PRIu64 " (external)",
|
||||
spec.c_str(),
|
||||
devolution_phone_number_for_netloc(state->local_address, netloc.second),
|
||||
devolution_phone_number_for_netloc(state->external_address, netloc.second));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,3 +88,17 @@ string string_for_address(uint32_t address) {
|
||||
uint32_t address_for_string(const char* address) {
|
||||
return ntohl(inet_addr(address));
|
||||
}
|
||||
|
||||
uint64_t devolution_phone_number_for_netloc(uint32_t addr, uint16_t port) {
|
||||
// It seems the address part of the number is fixed-width, but the port is
|
||||
// not. Why did they do it this way?
|
||||
if (port & 0xF000) {
|
||||
return (static_cast<uint64_t>(addr) << 16) | port;
|
||||
} else if (port & 0x0F00) {
|
||||
return (static_cast<uint64_t>(addr) << 12) | port;
|
||||
} else if (port & 0x00F0) {
|
||||
return (static_cast<uint64_t>(addr) << 8) | port;
|
||||
} else {
|
||||
return (static_cast<uint64_t>(addr) << 4) | port;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,3 +17,5 @@ bool is_local_address(const sockaddr_storage& daddr);
|
||||
|
||||
std::string string_for_address(uint32_t address);
|
||||
uint32_t address_for_string(const char* address);
|
||||
|
||||
uint64_t devolution_phone_number_for_netloc(uint32_t addr, uint16_t port);
|
||||
|
||||
Reference in New Issue
Block a user