** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+
// packet_manager.cc author Josh Rosenbaum <jorosenba@cisco.com>
#include "packet_manager.h"
-
#include <list>
#include <vector>
-using namespace std;
-
#include "framework/codec.h"
+#include "packet_manager.h"
#include "snort.h"
#include "thread.h"
#include "log/messages.h"
static const uint16_t max_protocol_id = 65535;
static std::array<Codec*, max_protocol_id> s_protocols;
-static list<const CodecApi*> s_codecs;
+static std::list<const CodecApi*> s_codecs;
static THREAD_LOCAL CdGenPegs pkt_cnt;
static CdGenPegs gpkt_cnt;
void PacketManager::release_plugins()
{
+ for ( auto* p : s_codecs )
+ {
+ p->gterm();
+ p->tterm();
+// p->dtor();
+ }
s_codecs.clear();
}
p->pkt = pkt;
len = pkthdr->caplen;
curr_prot_id = GRINDER_ID;
+ pkt_cnt.total_processed++;
// loop until the protocol id is no longer valid
while(curr_prot_id >= 0 && curr_prot_id < max_protocol_id)
break;
}
-
- // if we have succesfully decoded this layer, push the layer
PacketClass::PushLayer(p, s_protocols[curr_prot_id], pkt, p_hdr_len);
curr_prot_id = next_prot_id;
len -= p_hdr_len;
pkt += p_hdr_len;
-
}
p->dsize = len;
p->data = pkt;
-
PREPROC_PROFILE_END(decodePerfStats);
}
-#if 0
-const CodecApi *PacketManager::get_data_link_type(int dlt)
-{
- vector<int> dlt_vec;
-
- for ( auto* p : s_codecs )
- {
- dlt_vec.clear();
-// p->get_dlt(dlt_vec);
-
- for (auto *it = dlt_vec.begin(); it != dlt_vec.end(); ++it)
- {
- if (*it == dlt)
- return p;
- }
- }
-
- return nullptr;
-}
-
-void PacketManager::set_grinder(void)
-{
- const char* slink = NULL;
- const char* extra = NULL;
-
- // initialize values
-
- int dlt = DAQ_GetBaseProtocol();
- const CodecApi *cd_api = get_data_link_type(dlt);
-
- if(cd_api != nullptr)
- {
- grinder = cd_api->ctor();
-
- if ( !ScReadMode() || ScPcapShow() )
- LogMessage("Decoding %s\n", slink);
- }
-
-
- FatalError("%s(%d) Could not find codec for Data Link Type %d.\n",
- __FILE__, __LINE__, dlt);
-}
-#endif
void PacketManager::set_grinder(void)
{
- vector<uint16_t> proto;
- vector<int> dlt;
+ std::vector<uint16_t> proto;
+ std::vector<int> dlt;
bool codec_registered;
int daq_dlt = DAQ_GetBaseProtocol();
if (!codec_registered)
WarningMessage("The Codec %s is never used\n", cd->get_name());
- // ERRRO: If multiple correct grinders found.
}
+}
+void PacketManager::dump_stats()
+{
+ sum_stats((PegCount*)&gpkt_cnt, (PegCount*)&pkt_cnt, array_size(CdGenPegNames));
-// FatalError("Codec installation checking!!");
-}
+ for ( auto* cd : s_codecs )
+ if (cd->sum != nullptr)
+ cd->sum();
+ std::vector<const char*> pegNames(CdGenPegNames);
+ std::vector<PegCount> pegs;
+ pegs.push_back(gpkt_cnt.total_processed);
+ pegs.push_back(gpkt_cnt.other_codecs);
+ pegs.push_back(gpkt_cnt.discards);
// using two temporary vectors to ensure codecs cannot
// see any other codecs statistics
"codecs");
}
+
bool PacketManager::has_codec(uint16_t cd_id)
{
return s_protocols[cd_id] != 0;
-
set (FILE_LIST
ft_main.cc
ft_main.h
ftpp_return_codes.h
ftpp_si.cc
ftpp_si.h
- ftpp_ui_client_lookup.cc
- ftpp_ui_client_lookup.h
ftpp_ui_config.cc
ftpp_ui_config.h
- ftpp_ui_server_lookup.cc
- ftpp_ui_server_lookup.h
ftpp_util_kmap.h
hi_util_kmap.cc
hi_util_kmap.h
+++ /dev/null
-/*
- * ftpp_ui_client_lookup.c
- *
-** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
- * Copyright (C) 2004-2013 Sourcefire, Inc.
- * Steven A. Sturges <ssturges@sourcefire.com>
- * Daniel J. Roelker <droelker@sourcefire.com>
- * Marc A. Norton <mnorton@sourcefire.com>
- * Kevin Liu <kliu@sourcefire.com>
- *
- * 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.
- *
- * Description:
- *
- * This file contains functions to access the CLIENT_LOOKUP structure.
- *
- * We wrap the access to CLIENT_LOOKUP so changing the lookup algorithms
- * are more modular and independent. This is the only file that would need
- * to be changed to change the algorithmic lookup.
- *
- * NOTES:
- * - 16.09.04: Initial Development. SAS
- *
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "hi_util_kmap.h"
-#include "ftpp_ui_config.h"
-#include "ftpp_return_codes.h"
-#include "ft_main.h"
-#include "sfrt/sfrt.h"
-
-static void clientConfFree(void *pData);
-
-/*
- * Function: ftpp_ui_client_lookup_init(CLIENT_LOOKUP **ClientLookup)
- *
- * Purpose: Initialize the client_lookup structure.
- *
- * We need to initialize the client_lookup structure for
- * the FTP client configuration. Don't want a NULL pointer
- * flying around, when we have to look for FTP clients.
- *
- * Arguments: ClientLookup => pointer to the pointer of the client
- * lookup structure.
- *
- * Returns: int => return code indicating error or success
- *
- */
-#define FTPP_UI_CONFIG_MAX_CLIENTS 20
-int ftpp_ui_client_lookup_init(CLIENT_LOOKUP **ClientLookup)
-{
- *ClientLookup = sfrt_new(DIR_16_4x4_16x5_4x4, IPv6, FTPP_UI_CONFIG_MAX_CLIENTS, 20);
-
- if(*ClientLookup == NULL)
- {
- return FTPP_MEM_ALLOC_FAIL;
- }
-
- return FTPP_SUCCESS;
-}
-
-/*
- * Function: ftpp_ui_client_lookup_cleanup(CLIENT_LOOKUP **ClientLookup)
- *
- * Purpose: Free the client_lookup structure.
- * We need to free the client_lookup structure.
- *
- * Arguments: ClientLookup => pointer to the pointer of the client
- * lookup structure.
- *
- * Returns: int => return code indicating error or success
- *
- */
-int ftpp_ui_client_lookup_cleanup(CLIENT_LOOKUP **ClientLookup)
-{
- if ((ClientLookup == NULL) || (*ClientLookup == NULL))
- return FTPP_INVALID_ARG;
-
- sfrt_cleanup(*ClientLookup, clientConfFree);
- sfrt_free(*ClientLookup);
- *ClientLookup = NULL;
-
- return FTPP_SUCCESS;
-}
-
-/*
- * Function: ftpp_ui_client_lookup_add(CLIENT_LOOKUP *ClientLookup,
- * sfip_t* Ip,
- * FTP_CLIENT_PROTO_CONF *ClientConf)
- *
- * Purpose: Add a client configuration to the list.
- * We add these keys like you would normally think to add
- * them, because on low endian machines the least significant
- * byte is compared first. This is what we want to compare
- * IPs backward, doesn't work on high endian machines, but oh
- * well. Our platform is Intel.
- *
- * Arguments: ClientLookup => a pointer to the lookup structure
- * IP => the ftp client address
- * ClientConf => a pointer to the client configuration structure
- *
- * Returns: int => return code indicating error or success
- *
- */
-int ftpp_ui_client_lookup_add(
- CLIENT_LOOKUP *ClientLookup,
- sfip_t* Ip, FTP_CLIENT_PROTO_CONF *ClientConf)
-{
- int iRet;
-
- if(!ClientLookup || !ClientConf)
- {
- return FTPP_INVALID_ARG;
- }
-
- iRet = sfrt_insert((void *)Ip, (unsigned char)Ip->bits,
- (void *)ClientConf, RT_FAVOR_SPECIFIC, ClientLookup);
-
- if (iRet)
- {
- /*
- * This means the key has already been added.
- */
- if(iRet == 1)
- {
- return FTPP_NONFATAL_ERR;
- }
- else
- {
- return FTPP_MEM_ALLOC_FAIL;
- }
- }
-
- return FTPP_SUCCESS;
-}
-
-/*
- * Function: ftpp_ui_client_lookup_find(CLIENT_LOOKUP *ClientLookup,
- * snort_ip_p ip, int *iError)
- *
- * Purpose: Find a client configuration given a IP.
- * We look up a client configuration given an IP and
- * return a pointer to that client configuration if found.
- *
- * Arguments: ClientLookup => a pointer to the lookup structure
- * IP => the ftp client address
- * iError => a pointer to an error code
- *
- * Returns: int => return code indicating error or success
- *
- * Returns: FTP_CLIENT_PROTO_CONF* => Pointer to client configuration
- * structure matching IP if found, NULL otherwise.
- *
- */
-
-FTP_CLIENT_PROTO_CONF *ftpp_ui_client_lookup_find(CLIENT_LOOKUP *ClientLookup,
- snort_ip_p Ip, int *iError)
-{
- FTP_CLIENT_PROTO_CONF *ClientConf = NULL;
-
- if(!iError)
- {
- return NULL;
- }
-
- if(!ClientLookup)
- {
- *iError = FTPP_INVALID_ARG;
- return NULL;
- }
-
- *iError = FTPP_SUCCESS;
-
- ClientConf = (FTP_CLIENT_PROTO_CONF *)sfrt_lookup((void *)Ip, ClientLookup);
- if (!ClientConf)
- {
- *iError = FTPP_NOT_FOUND;
- }
-
- return ClientConf;
-}
-
-#if 0
-/** Obsoleted. After changing underlying KMAP to SFRT. SFRT provides an iterator with
- * a callback function but does not support getFirst, getNext operations.
- */
-/*
- * Function: ftpp_ui_client_lookup_first(CLIENT_LOOKUP *ClientLookup,
- * int *iError)
- *
- * Purpose: This lookups the first client configuration, so we can
- * iterate through the configurations.
- *
- * Arguments: ClientLookup => pointer to the client lookup structure
- * iError => pointer to the integer to set for errors
- *
- * Returns: FTP_CLIENT_PROTO_CONF* => Pointer to first client configuration
- * structure
- *
- */
-FTP_CLIENT_PROTO_CONF *ftpp_ui_client_lookup_first(CLIENT_LOOKUP *ClientLookup,
- int *iError)
-{
- FTP_CLIENT_PROTO_CONF *ClientConf;
-
- if(!iError)
- {
- return NULL;
- }
-
- if(!ClientLookup)
- {
- *iError = FTPP_INVALID_ARG;
- return NULL;
- }
-
- *iError = FTPP_SUCCESS;
-
- ClientConf = (FTP_CLIENT_PROTO_CONF *)KMapFindFirst(ClientLookup);
- if (!ClientConf)
- {
- *iError = FTPP_NOT_FOUND;
- }
-
- return ClientConf;
-}
-
-/*
- * Function: ftpp_ui_client_lookup_next(CLIENT_LOOKUP *ClientLookup,
- * int *iError)
- *
- * Iterates to the next configuration, like a list it just returns
- * the next config in the config list.
- *
- * Purpose: This lookups the next client configuration, so we can
- * iterate through the configurations.
- *
- * Arguments: ClientLookup => pointer to the client lookup structure
- * iError => pointer to the integer to set for errors
- *
- * Returns: FTP_CLIENT_PROTO_CONF* => Pointer to next client configuration
- * structure
- *
- */
-FTP_CLIENT_PROTO_CONF *ftpp_ui_client_lookup_next(CLIENT_LOOKUP *ClientLookup,
- int *iError)
-{
- FTP_CLIENT_PROTO_CONF *ClientConf;
-
- if(!iError)
- {
- return NULL;
- }
-
- if(!ClientLookup)
- {
- *iError = FTPP_INVALID_ARG;
- return NULL;
- }
-
- *iError = FTPP_SUCCESS;
-
- ClientConf = (FTP_CLIENT_PROTO_CONF *)KMapFindNext(ClientLookup);
- if (!ClientConf)
- {
- *iError = FTPP_NOT_FOUND;
- }
-
- return ClientConf;
-}
-#endif
-
-/**Free pData buffer, which may be referenced multiple times. ReferenceCount
- * is the number of times the buffer is referenced. For freeing the buffer,
- * we just decrement referenceCount till it reaches 0, at which time the
- * buffer is also freed.
- */
-static void clientConfFree(void *pData)
-{
- FTP_CLIENT_PROTO_CONF *clientConf = (FTP_CLIENT_PROTO_CONF *)pData;
-
- if (clientConf)
- {
- clientConf->referenceCount--;
- if (clientConf->referenceCount == 0)
- {
- FTPTelnetCleanupFTPClientConf((void *)clientConf);
- free(clientConf);
- }
- }
-}
-
+++ /dev/null
-/*
- * ftpp_ui_client_lookup.h
- *
-** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
- * Copyright (C) 2004-2013 Sourcefire, Inc.
- * Steven A. Sturges <ssturges@sourcefire.com>
- * Daniel J. Roelker <droelker@sourcefire.com>
- * Marc A. Norton <mnorton@sourcefire.com>
- * Kevin Liu <kliu@sourcefire.com>
- *
- * 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.
- *
- * Description:
- *
- * This file contains function definitions for client lookups.
- *
- * NOTES:
- * - 16.09.04: Initial Development. SAS
- *
- */
-#ifndef FTPP_UI_CLIENT_LOOKUP_H
-#define FTPP_UI_CLIENT_LOOKUP_H
-
-#include "ftpp_include.h"
-#include "ftpp_ui_config.h"
-
-int ftpp_ui_client_lookup_init(CLIENT_LOOKUP **ClientLookup);
-int ftpp_ui_client_lookup_cleanup(CLIENT_LOOKUP **ClientLookup);
-int ftpp_ui_client_lookup_add(CLIENT_LOOKUP *ClientLookup, sfip_t * IP,
- FTP_CLIENT_PROTO_CONF *ClientConf);
-
-FTP_CLIENT_PROTO_CONF *ftpp_ui_client_lookup_find(CLIENT_LOOKUP *ClientLookup,
- snort_ip_p Ip, int *iError);
-FTP_CLIENT_PROTO_CONF *ftpp_ui_client_lookup_first(CLIENT_LOOKUP *ClientLookup,
- int *iError);
-FTP_CLIENT_PROTO_CONF *ftpp_ui_client_lookup_next(CLIENT_LOOKUP *ClientLookup,
- int *iError);
-
-#endif
+++ /dev/null
-/*
- * ftpp_ui_server_lookup.c
- *
-** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
- * Copyright (C) 2004-2013 Sourcefire, Inc.
- * Steven A. Sturges <ssturges@sourcefire.com>
- * Kevin Liu <kliu@sourcefire.com>
- *
- * 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.
- *
- * Description:
- *
- * This file contains functions to access the SERVER_LOOKUP structure.
- *
- * We wrap the access to SERVER_LOOKUP so changing the lookup algorithms
- * are more modular and independent. This is the only file that would need
- * to be changed to change the algorithmic lookup.
- *
- * NOTES:
- * - 16.09.04: Initial Development. SAS
- *
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "hi_util_kmap.h"
-#include "ftpp_ui_config.h"
-#include "ftpp_return_codes.h"
-#include "ft_main.h"
-
-static void serverConfFree(void *pData);
-
-/*
- * Function: ftpp_ui_server_lookup_init(SERVER_LOOKUP **ServerLookup)
- *
- * Purpose: Initialize the server_lookup structure.
- *
- * We need to initialize the server_lookup structure for
- * the FTP server configuration. Don't want a NULL pointer
- * flying around, when we have to look for server configs.
- *
- * Arguments: ServerLookup => pointer to the pointer of the server
- * lookup structure.
- *
- * Returns: int => return code indicating error or success
- *
- */
-#define FTPP_UI_CONFIG_MAX_SERVERS 20
-int ftpp_ui_server_lookup_init(SERVER_LOOKUP **ServerLookup)
-{
- *ServerLookup = sfrt_new(DIR_16_4x4_16x5_4x4, IPv6, FTPP_UI_CONFIG_MAX_SERVERS, 20);
-
- if(*ServerLookup == NULL)
- {
- return FTPP_MEM_ALLOC_FAIL;
- }
-
- return FTPP_SUCCESS;
-}
-
-/*
- * Function: ftpp_ui_server_lookup_cleanup(SERVER_LOOKUP **ServerLookup)
- *
- * Purpose: Free the server_lookup structure.
- * We need to free the server_lookup structure.
- *
- * Arguments: ServerLookup => pointer to the pointer of the server
- * lookup structure.
- *
- * Returns: int => return code indicating error or success
- *
- */
-int ftpp_ui_server_lookup_cleanup(SERVER_LOOKUP **ServerLookup)
-{
- if ((ServerLookup == NULL) || (*ServerLookup == NULL))
- return FTPP_INVALID_ARG;
-
- sfrt_cleanup(*ServerLookup, serverConfFree);
- sfrt_free(*ServerLookup);
- *ServerLookup = NULL;
-
- return FTPP_SUCCESS;
-}
-
-/*
- * Function: ftpp_ui_server_lookup_add(SERVER_LOOKUP *ServerLookup,
- * char *ip, int len,
- * FTP_SERVER_PROTO_CONF *ServerConf)
- *
- * Purpose: Add a server configuration to the list.
- * We add these keys like you would normally think to add
- * them, because on low endian machines the least significant
- * byte is compared first. This is what we want to compare
- * IPs backward, doesn't work on high endian machines, but oh
- * well. Our platform is Intel.
- *
- * Arguments: ServerLookup => a pointer to the lookup structure
- * IP => the ftp server address
- * len => Length of the address
- * ServerConf => a pointer to the server configuration structure
- *
- * Returns: int => return code indicating error or success
- *
- */
-int ftpp_ui_server_lookup_add(
- SERVER_LOOKUP *ServerLookup, sfip_t* Ip, FTP_SERVER_PROTO_CONF *ServerConf )
-{
- int iRet;
-
- if(!ServerLookup || !ServerConf)
- {
- return FTPP_INVALID_ARG;
- }
-
- iRet = sfrt_insert((void *)Ip, (unsigned char)Ip->bits, (void *)ServerConf, RT_FAVOR_SPECIFIC, ServerLookup);
-
- if (iRet)
- {
- return FTPP_MEM_ALLOC_FAIL;
- }
-
- return FTPP_SUCCESS;
-}
-
-/*
- * Function: ftpp_ui_server_lookup_find(SERVER_LOOKUP *ServerLookup,
- * snort_ip_p ip, int *iError)
- *
- * Purpose: Find a server configuration given a IP.
- * We look up a server configuration given an IP and
- * return a pointer to that server configuration if found.
- *
- * Arguments: ServerLookup => a pointer to the lookup structure
- * IP => the ftp server address
- * iError => a pointer to an error code
- *
- * Returns: int => return code indicating error or success
- *
- * Returns: FTP_SERVER_PROTO_CONF* => Pointer to server configuration
- * structure matching IP if found, NULL otherwise.
- *
- */
-FTP_SERVER_PROTO_CONF *ftpp_ui_server_lookup_find(
- SERVER_LOOKUP *ServerLookup, snort_ip_p Ip, int *iError
-)
-{
- FTP_SERVER_PROTO_CONF *ServerConf = NULL;
-
- if(!iError)
- {
- return NULL;
- }
-
- if(!ServerLookup)
- {
- *iError = FTPP_INVALID_ARG;
- return NULL;
- }
-
- *iError = FTPP_SUCCESS;
-
- ServerConf = (FTP_SERVER_PROTO_CONF *)sfrt_lookup((void *)Ip, ServerLookup);
- if (!ServerConf)
- {
- *iError = FTPP_NOT_FOUND;
- }
-
- return ServerConf;
-}
-
-
-/**Iterate over all the stored IP addresses, calling the callback for
- * all elements.
- *
- * @param ServerLookup => a pointer to the lookup structure
- * @param userfunc => user defined callback function
- * @param iError => a pointer to an error code
- *
- * @returns iError => return code indicating error or success
- *
- */
-int ftpp_ui_server_iterate(
- SnortConfig* sc,SERVER_LOOKUP *ServerLookup,
- sfrt_sc_iterator_callback3 userfunc,
- int *iError
- )
-{
- if(!iError)
- {
- return 0;
- }
-
- if(!ServerLookup)
- {
- *iError = FTPP_INVALID_ARG;
- return 0;
- }
-
- *iError = FTPP_SUCCESS;
-
- return sfrt_iterate2_with_snort_config(sc, ServerLookup, userfunc);
-}
-
-#if 0
-/** Obsoleted. After changing underlying KMAP to SFRT. SFRT provides an iterator with
- * a callback function but does not support getFirst, getNext operations.
- */
-
-/*
- * Function: ftpp_ui_server_lookup_first(SERVER_LOOKUP *ServerLookup,
- * int *iError)
- *
- * Purpose: This lookups the first server configuration, so we can
- * iterate through the configurations.
- *
- * Arguments: ServerLookup => pointer to the server lookup structure
- * iError => pointer to the integer to set for errors
- *
- * Returns: FTP_SERVER_PROTO_CONF* => Pointer to first server
- * configuration structure
- *
- */
-FTP_SERVER_PROTO_CONF *ftpp_ui_server_lookup_first(SERVER_LOOKUP *ServerLookup,
- int *iError)
-{
- FTP_SERVER_PROTO_CONF *ServerConf;
-
- if(!iError)
- {
- return NULL;
- }
-
- if(!ServerLookup)
- {
- *iError = FTPP_INVALID_ARG;
- return NULL;
- }
-
- *iError = FTPP_SUCCESS;
-
- ServerConf = (FTP_SERVER_PROTO_CONF *)KMapFindFirst(ServerLookup);
- if (!ServerConf)
- {
- *iError = FTPP_NOT_FOUND;
- }
-
- return ServerConf;
-}
-
-/*
- * Function: ftpp_ui_server_lookup_next(SERVER_LOOKUP *ServerLookup,
- * int *iError)
- *
- * Iterates to the next configuration, like a list it just returns
- * the next config in the config list.
- *
- * Purpose: This lookups the next server configuration, so we can
- * iterate through the configurations.
- *
- * Arguments: ServerLookup => pointer to the server lookup structure
- * iError => pointer to the integer to set for errors
- *
- * Returns: FTP_SERVER_PROTO_CONF* => Pointer to next server configuration
- * structure
- *
- */
-FTP_SERVER_PROTO_CONF *ftpp_ui_server_lookup_next(SERVER_LOOKUP *ServerLookup,
- int *iError)
-{
- FTP_SERVER_PROTO_CONF *ServerConf;
-
- if(!iError)
- {
- return NULL;
- }
-
- if(!ServerLookup)
- {
- *iError = FTPP_INVALID_ARG;
- return NULL;
- }
-
- *iError = FTPP_SUCCESS;
-
- ServerConf = (FTP_SERVER_PROTO_CONF *)KMapFindNext(ServerLookup);
- if (!ServerConf)
- {
- *iError = FTPP_NOT_FOUND;
- }
-
- return ServerConf;
-}
-#endif
-
-/**Free pData buffer, which may be referenced multiple times. ReferenceCount
- * is the number of times the buffer is referenced. For freeing the buffer,
- * we just decrement referenceCount till it reaches 0, at which time the
- * buffer is also freed.
- */
-static void serverConfFree(void *pData)
-{
- FTP_SERVER_PROTO_CONF *serverConf = (FTP_SERVER_PROTO_CONF *)pData;
-
- if (serverConf)
- {
- serverConf->referenceCount--;
- if (serverConf->referenceCount == 0)
- {
- CleanupFTPServerConf((void *)serverConf);
- free(serverConf);
- }
- }
-}
-
+++ /dev/null
-/*
- * ftpp_ui_server_lookup.h
- *
-** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
- * Copyright (C) 2004-2013 Sourcefire, Inc.
- * Steven A. Sturges <ssturges@sourcefire.com>
- * Kevin Liu <kliu@sourcefire.com>
- *
- * 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.
- *
- * Description:
- *
- * This file contains function definitions for server lookups.
- *
- * NOTES:
- * - 16.09.04: Initial Development. SAS
- *
- */
-#ifndef FTPP_UI_SERVER_LOOKUP_H
-#define FTPP_UI_SERVER_LOOKUP_H
-
-#include "ftpp_include.h"
-#include "ftpp_ui_config.h"
-
-int ftpp_ui_server_lookup_init(SERVER_LOOKUP **ServerLookup);
-int ftpp_ui_server_lookup_cleanup(SERVER_LOOKUP **ServerLookup);
-int ftpp_ui_server_lookup_add(SERVER_LOOKUP *ServerLookup, sfip_t *IP,
- FTP_SERVER_PROTO_CONF *ServerConf);
-
-FTP_SERVER_PROTO_CONF *ftpp_ui_server_lookup_find(SERVER_LOOKUP *ServerLookup,
- snort_ip_p Ip, int *iError);
-int ftpp_ui_server_iterate(
- SnortConfig*,SERVER_LOOKUP *ServerLookup,
- sfrt_sc_iterator_callback3 userfunc,
- int *iError
- );
-
-#endif