char sipstr[INET6_ADDRSTRLEN];
char dipstr[INET6_ADDRSTRLEN];
- info.set(*constraints);
+ info = *constraints;
info.sip.ntop(sipstr, sizeof(sipstr));
info.dip.ntop(dipstr, sizeof(dipstr));
LogMessage("Debugging %s with %s-%hu and %s-%hu %hhu\n", desc,
struct AppIdDebugSessionConstraints
{
snort::SfIp sip;
- int sip_flag = 0;
+ bool sip_flag = false;
snort::SfIp dip;
- int dip_flag = 0;
+ bool dip_flag = false;
uint16_t sport;
uint16_t dport;
IpProtocol protocol = IpProtocol::PROTO_NOT_SET;
((!sip_flag or !memcmp(sip.get_ip6_ptr(), ip1, sizeof(snort::ip::snort_in6_addr))) and
(!dip_flag or !memcmp(dip.get_ip6_ptr(), ip2, sizeof(snort::ip::snort_in6_addr))));
}
- void set(const AppIdDebugSessionConstraints& src);
};
-inline void AppIdDebugSessionConstraints::set(const AppIdDebugSessionConstraints& src)
-{
- if ((sip_flag = src.sip_flag))
- sip = src.sip;
- if ((dip_flag = src.dip_flag))
- dip = src.dip;
- sport = src.sport;
- dport = src.dport;
- protocol = src.protocol;
-}
-
class AppIdDebug
{
public:
#include "main/swapper.h"
#include "managers/inspector_manager.h"
#include "profiler/profiler.h"
+#include "pub_sub/appid_debug_log_event.h"
#include "src/main.h"
#include "target_based/host_attributes.h"
#include "trace/trace.h"
{
if (cs)
{
- constraints.set(*cs);
+ constraints = *cs;
enable = true;
}
}
constraints.sport = sport;
constraints.dport = dport;
+ AppIdDebugLogEvent event(&constraints, "AppIdDbg");
+ DataBus::publish(APPID_DEBUG_LOG_EVENT, event);
+
main_broadcast_command(new AcAppIdDebug(&constraints), true);
return 0;
static int disable_debug(lua_State*)
{
+ AppIdDebugLogEvent event(nullptr, "");
+ DataBus::publish(APPID_DEBUG_LOG_EVENT, event);
main_broadcast_command(new AcAppIdDebug(nullptr), true);
return 0;
}
--- /dev/null
+//--------------------------------------------------------------------------
+// Copyright (C) 2021-2021 Cisco and/or its affiliates. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License Version 2 as published
+// by the Free Software Foundation. You may not use, modify or distribute
+// this program under any other version of the GNU General Public License.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//--------------------------------------------------------------------------
+// appid_debug_log_event.h author Cliff Judge <cljudge@cisco.com>
+
+#ifndef APPID_DEBUG_LOG_EVENT_H
+#define APPID_DEBUG_LOG_EVENT_H
+
+#include <string>
+
+#include "framework/data_bus.h"
+#include "network_inspectors/appid/appid_debug.h"
+
+#define APPID_DEBUG_LOG_EVENT "appid_debug_log_event"
+
+class AppIdDebugLogEvent : public snort::DataEvent
+{
+public:
+ AppIdDebugLogEvent(const AppIdDebugSessionConstraints* constraints, const char* dbg_str) :
+ cs(constraints), debug_str(dbg_str) { }
+
+ const AppIdDebugSessionConstraints* get_appid_debug_constraints() const
+ {
+ return cs;
+ }
+
+ const std::string& get_debug_string() const
+ {
+ return debug_str;
+ }
+private:
+ const AppIdDebugSessionConstraints* cs = nullptr;
+ std::string debug_str;
+};
+
+#endif