/*
 * simco_client.c -- Header file
 *
 * 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>
 *
 */

#ifndef SIMCO_CLIENT_H
#define SIMCO_CLIENT_H


#ifdef  __cplusplus
extern "C" {
#endif

//#define MAX_PORT_LIST_RANGE 10

  typedef struct _simcoPacket {
    int ruleId;
    int groupId;
    char internal_ip[16];     /* source IP of the flow*/
    char external_ip[16];     /* dest IP of the flow*/
    char inside_ip[16]; /* NAPTed dest IP of the flow (twice NAT)*/
    char outside_ip[16]; /* NAPTed source IP of the flow*/
    unsigned int internal_ip_mask; /* source IP mask*/
    unsigned int external_ip_mask;
    unsigned int inside_ip_mask;
    unsigned int outside_ip_mask;
    unsigned short internal_port; /* src port of the flow*/
    unsigned short external_port; /* the start src port range of the flow*/
    unsigned short inside_port; /* the start src port range of the flow*/
    unsigned short outside_port; /* the start src port range of the flow*/
    unsigned short internal_port_range; /* number of contiguous ports */
    unsigned short external_port_range;
    unsigned short inside_port_range;
    unsigned short outside_port_range;
    unsigned short nat_port_range;
    int protocol;/* IANA defined protocol number */
    int codec;
    int lifetime;
    int status;
  } simcoPacket_t;

#define MAX_CON 100

  extern int debug_midbox;

  extern int mc_init(char *cert);

  extern int mc_comm_connect(char *host);
  extern void mc_comm_disconnect(int i);

  extern int mc_notif_connect(char *host);
  extern void mc_notif_disconnect(int i);

  extern int simco_ne_b(int i);
  extern int simco_na_b(int i, char *username, char *password);
  extern int simco_nt_b(int i);

  extern int simco_se_b(int con);
  extern int simco_sa_b(int con, char *username, char *password);
  extern int simco_st_b(int i);
  extern int simco_prr_b(int i, simcoPacket_t *sp);
  extern int simco_per_b(int i, simcoPacket_t *sp);
  extern int simco_pea_b(int i, simcoPacket_t *sp);
  extern int simco_pba_b(int i, simcoPacket_t *sp);
  extern int simco_plc_b(int i, simcoPacket_t *sp);
  extern int simco_prs_b(int i, simcoPacket_t *sp);
  extern int simco_prl_b(int i, int **rules, int *numrules);
  extern int simco_ping_b(int i);

  extern void mc_close(void);

  extern int simco_ne_nb(int i);
  extern int simco_na_nb(int i, char *username, char *password);
  extern int simco_nt_nb(int i);

  extern int simco_se_nb(int con);
  extern int simco_sa_nb(int con, char *username, char *password);
  extern int simco_st_nb(int i);
  extern int simco_prr_nb(int i, simcoPacket_t *sp);
  extern int simco_per_nb(int i, simcoPacket_t *sp);
  extern int simco_pea_nb(int i, simcoPacket_t *sp);
  extern int simco_pba_nb(int i, simcoPacket_t *sp);
  extern int simco_plc_nb(int i, simcoPacket_t *sp);
  extern int simco_prs_nb(int i, simcoPacket_t *sp);
  extern int simco_prl_nb(int i);
  extern int simco_ping_nb(int i);

  extern int simco_notif_read(int i, simcoPacket_t *np);

  extern void mc_add_con_to_pool(int i);
  extern void mc_rem_con_from_pool(int i);

  extern void reg_se_callback(int (*fn)(int con, int status));
  extern void reg_sa_callback(int (*fn)(int con, int status));
  extern void reg_st_callback(int (*fn)(int con, int status));
  extern void reg_prr_callback(int (*fn)(int con, simcoPacket_t *sp));
  extern void reg_per_callback(int (*fn)(int con, simcoPacket_t *sp));
  extern void reg_pea_callback(int (*fn)(int con, simcoPacket_t *sp));
  extern void reg_pba_callback(int (*fn)(int con, simcoPacket_t *sp));
  extern void reg_pdr_callback(int (*fn)(int con, simcoPacket_t *sp));
  extern void reg_plc_callback(int (*fn)(int con, simcoPacket_t *sp));
  extern void reg_prs_callback(int (*fn)(int con, simcoPacket_t *sp));
  extern void reg_prl_callback(int (*fn)(int con, int *rlist, int size));
  extern void reg_ping_callback(int (*fn)(int con, int status));
  extern void reg_notif_callback(int i, int (*fn)(simcoPacket_t *sp));

  extern int simco_get_error(int i);

#ifdef  __cplusplus
}
#endif


#endif /* !SIMCO_CLIENT_H */

