Skip to content

Commit

Permalink
handle main_type_sub_list
Browse files Browse the repository at this point in the history
  • Loading branch information
wwiv committed Mar 18, 2017
1 parent a164d00 commit 279bede
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
22 changes: 19 additions & 3 deletions network2/network2.cpp
Expand Up @@ -126,8 +126,7 @@ static bool handle_ssm(Context& context, Packet& p) {
return true;
}

static bool handle_net_info_file(const net_networks_rec& net, Packet& p) {
auto info = GetNetInfoFileInfo(p);
static bool write_net_received_file(const net_networks_rec& net, Packet& p, NetInfoFileInfo info) {
if (!info.valid) {
LOG(ERROR) << "NetInfoFileInfo is not valid";
return write_wwivnet_packet(DEAD_NET, net, p);
Expand All @@ -154,6 +153,21 @@ static bool handle_net_info_file(const net_networks_rec& net, Packet& p) {
return true;
}

static bool handle_net_info_file(const net_networks_rec& net, Packet& p) {
auto info = GetNetInfoFileInfo(p);
return write_net_received_file(net, p, info);
}

static bool handle_sub_list(const net_networks_rec& net, Packet& p) {
// Handle legacy type 9 main_type_sub_list (SUBS.LST)
NetInfoFileInfo info{};
info.filename = SUBS_LST;
info.data = p.text;
info.valid = true;
info.overwrite = true;
return write_net_received_file(net, p, info);
}

static bool handle_packet(
Context& context, Packet& p) {
LOG(INFO) << "Processing message with type: " << main_type_name(p.nh.main_type)
Expand Down Expand Up @@ -222,6 +236,9 @@ static bool handle_packet(
return handle_sub_list_info_response(context, p);
}

case main_type_sub_list:
return handle_sub_list(context.net, p);

// Legacy numeric only post types.
case main_type_post:
case main_type_pre_post:
Expand All @@ -234,7 +251,6 @@ static bool handle_packet(
case main_type_net_edit:

// *.### support
case main_type_sub_list:
case main_type_group_bbslist:
case main_type_group_connect:
case main_type_group_info:
Expand Down
10 changes: 10 additions & 0 deletions networkb/packets.cpp
Expand Up @@ -23,6 +23,7 @@
#include "core/file.h"
#include "core/log.h"
#include "core/strings.h"
#include "networkb/net_util.h"
#include "sdk/datetime.h"
#include "sdk/filenames.h"

Expand Down Expand Up @@ -170,7 +171,16 @@ static string NetInfoFileName(uint16_t type) {

NetInfoFileInfo GetNetInfoFileInfo(Packet& p) {
NetInfoFileInfo info{};
if (p.nh.main_type != main_type_net_info) {
// Everything else here should be a main_type_net_info
LOG(ERROR) << "GetNetInfoFileInfo can't handle type: "
<< main_type_name(p.nh.main_type) << " (" << p.nh.main_type << ")";
info.valid = false;
return info;
}

if (p.nh.minor_type != net_info_file) {
// Handle the file types we know about using minor_type
info.filename = NetInfoFileName(p.nh.minor_type);
info.data = p.text;
info.valid = true;
Expand Down

0 comments on commit 279bede

Please sign in to comment.