/*
 * simco_client_ext.c
 *
 * Copyright (C) 2005, Ranch Networks, Inc.
 *
 * 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
 * the Free Software Foundation.
 *
 * 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
 *
 * Author : Srivatsa Chivukula <srivatsa@ranchnetworks.com>
 *
 */

#include "simco_core_ext.h"
#include "simco_client_ext.h"
#include "simco_b_ext.h"
#include "simco_nb_ext.h"


/**
 * Send firewall rule create request and get response on the
 * connection corresponding to the index \a i.
 * \a sep->action  \a sep->syslog, \a sep->srcZoneId, \a sep->dstZoneId,
 * \a sep->lifetime have to be passed in \a sep.
 * \a sep->ruleid, \a sep->lifetime will be returned on success.
 * @param i connection index.
 * @param sep pointer to the extended simco packet structure.
 * @return -1 if communication failed, 0 on success, or error code set by server.
 */
int simco_frc_b(int i, simcoExtPacket_t *sep)
{
  return b_mcAgentTCPFirewallRuleCreate(&conn[i], sep);
}

/**
 * Send firewall rule delete request and get response on the
 * connection corresponding to the index \a i.
 * \a sep->ruleid has to be passed in \a sep.
 * \a sep->ruleid will be returned on success.
 * @param i connection index.
 * @param sep pointer to the extended simco packet structure.
 * @return -1 if communication failed, 0 on success, or error code set by server.
 */
int simco_frd_b(int i, simcoExtPacket_t *sep)
{
  return b_mcAgentTCPFirewallRuleDelete(&conn[i], sep);
}



/**
 * Send firewall rule status request and get response on the
 * connection corresponding to the index \a i.
 * \a sep->ruleid has to be passed in \a sep.
 * The fields set for the rule on the midlebox will be returned in
 * the \a sep structure.
 * @param i connection index.
 * @param sep pointer to the extended simco packet structure.
 * @return -1 if communication failed, 0 on success, or error code set by server.
 */
int simco_frs_b(int i, simcoExtPacket_t *sep)
{
  return b_mcAgentTCPFirewallRuleStatus(&conn[i], sep);
}

/**
 * Send policy rule list request and get response on the
 * connection corresponding to the index \a i.
 * @param i connection index.
 * @param rules pointer to the rules array returned.
 * @param numrules pointer ot the number of rules returned
 * @return -1 if communication failed, 0 on success, or error code set by server.
 */
int simco_frl_b(int i, int **rules, int *numrules)
{
  return b_mcAgentTCPFirewallRuleList(&conn[i], rules, numrules);
}


/**
 * Send firewall rule create request on the
 * connection corresponding to the index \a i.
 * \a sep->action  \a sep->syslog, \a sep->srcZoneId, \a sep->dstZoneId,
 * \a sep->lifetime have to be passed in \a sep.
 * @param i connection index.
 * @param sep pointer to the extended simco packet structure.
 * @return -1 if communication failed, 0 on success.
 */
int simco_frc_nb(int i, simcoExtPacket_t *sep)
{
  return nb_mcAgentTCPFirewallRuleCreate(&conn[i], sep);
}

/**
 * Send firewall rule delete request on the
 * connection corresponding to the index \a i.
 * \a sep->ruleid has to be passed in \a sep.
 * @param i connection index.
 * @param sep pointer to the extended simco packet structure.
 * @return -1 if communication failed, 0 on success.
 */
int simco_frd_nb(int i, simcoExtPacket_t *sep)
{
  return nb_mcAgentTCPFirewallRuleDelete(&conn[i], sep);
}

/**
 * Send firewall rule status request on the
 * connection corresponding to the index \a i.
 * \a sp->ruleid has to be passed in \a sp.
 * @param i connection index.
 * @param sep pointer to the extended simco packet structure.
 * @return -1 if communication failed, 0 on success.
 */
int simco_frs_nb(int i, simcoExtPacket_t *sep)
{
  return nb_mcAgentTCPFirewallRuleStatus(&conn[i], sep);
}

/**
 * Send policy rule list request on the
 * connection corresponding to the index \a i.
 * @param i connection index.
 * @return -1 if communication failed, 0 on success.
 */
int simco_frl_nb(int i)
{
  return nb_mcAgentTCPFirewallRuleList(&conn[i]);
}
