/*
 * simco_defs.h
 *
 * 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_DEFS_H_
#define _SIMCO_DEFS_H_

#define SIMCO_MAJOR_VERSION 0x03
#define SIMCO_MINOR_VERSION 0x00

/* SIMCO Header */
/* Basic Message Types */
#define BSC_REQ_MSG         0x01   /* Request Message */
#define BSC_POS_RPL_MSG     0x02   /* Positive Reply Message */
#define BSC_NEG_RPL_MSG     0x03   /* Negative Reply Message */
#define BSC_NTF_MSG         0x04   /* Notification Message */

/* Message sub-types for 0x01 (request) and 0x02 (positive reply) */
#define SUB_SE_MSG      0x01  /*  (SE)  session establishment */
#define SUB_SA_MSG      0x02  /*  (SA)  session authentication */
#define SUB_ST_MSG      0x03  /*  (ST)  session termination */
#define SUB_PRR_MSG     0x11  /*  (PRR) policy reserve rule */
#define SUB_PER_MSG     0x12  /*  (PER) policy enable rule */
#define SUB_PEA_MSG     0x13  /*  (PEA) PER after reservation (request only) */
#define SUB_PDR_MSG     0x14  /*  (PDR) policy disable rule */
#define SUB_PLC_MSG     0x15  /*  (PLC) policy rule lifetime change */
#define SUB_PRD_MSG     0x16  /*  (PRD) policy rule deletion (positive reply only) */
#define SUB_PS_MSG      0x21  /*  (PS)  policy rule status */
#define SUB_PL_MSG      0x22  /*  (PL)  policy rule list */
#define SUB_PBA_MSG     0x23  /*  (PBA) PBR(bridge) after reservation (request only) */
#define SUB_PNG_MSG     0xff  /*  (PNG) SIMCO ping */

/* Message sub-types for 0x03 (negative reply message) */
/*      Replies concerning general message handling */
#define SUB_WBR_MSG     0x10  /*  wrong basic request message type */
#define SUB_WSR_MSG     0x11  /*  wrong request message sub-type */
#define SUB_BFR_MSG     0x12  /*  badly formed request */

/*      Replies concerning sessions */
#define SUB_RNA_MSG     0x20  /*  request not applicable */
#define SUB_LOR_MSG     0x21  /*  lack of resources */
#define SUB_PVM_MSG     0x22  /*  protocol version mismatch */
#define SUB_AUF_MSG     0x23  /*  authentication failed */
#define SUB_NAU_MSG     0x24  /*  no authorization */

/*      Replies concerning policy rules */
#define SUB_TNS_MSG     0x40  /*  transaction not supported */
#define SUB_ANA_MSG     0x41  /*  agent not authorized for this transaction */
#define SUB_NRA_MSG     0x42  /*  no resources available for this transaction */
#define SUB_PDE_MSG     0x43  /*  specified policy rule does not exist */
#define SUB_PGE_MSG     0x44  /*  specified policy rule group does not exist */
#define SUB_NAP_MSG     0x45  /*  not authorized for accessing specified policy */
#define SUB_NAG_MSG     0x46  /*  not authorized for accessing specified group */
#define SUB_ASA_MSG     0x47  /*  requested address space not available */
#define SUB_LIP_MSG     0x48  /*  lack of IP addresses */
#define SUB_LPN_MSG     0x49  /*  lack of port numbers */
#define SUB_MCF_MSG     0x50  /*  middlebox configuration failed */
#define SUB_IRQ_MSG     0x51  /*  inconsistent request */
#define SUB_WNS_MSG     0x52  /*  requested wildcarding not supported */
#define SUB_PTM_MSG     0x53  /*  protocol type doesn't match */
#define SUB_NNS_MSG     0x54  /*  NAT mode not supported */
#define SUB_IVM_MSG     0x55  /*  IP version mismatch */
#define SUB_CER_MSG     0x56  /*  conflict with existing rule */
#define SUB_NAL_MSG     0x57  /*  not authorized to change lifetime */
#define SUB_LCE_MSG     0x58  /*  lifetime can't be extended */
#define SUB_IPA_MSG     0x59  /*  illegal IP Address */
#define SUB_PTS_MSG     0x60  /*  protocol type not supported */
#define SUB_IPN_MSG     0x61  /*  illegal port number */
#define SUB_ISP_MSG     0x62  /*  illegal number of subsequent ports (NOSP) */
#define SUB_AEP_MSG     0x63  /*  already enable PID */
#define SUB_PDM_MSG     0x64  /*  parity doesn't match */

/* Message Sub-types for Notifications */
#define SUB_BFM_MSG     0x01  /*  (BFM) badly formed message received */
#define SUB_AST_MSG     0x02  /*  (AST) asynchronous session termination */
#define SUB_ARE_MSG     0x03  /*  (ARE) asynchronous policy rule event */

/*  The SIMCO Payload Attribute */
#define PAY_PVR_ATT     0x0001  /*  SIMCO protocol version    32 bits */
#define PAY_ACH_ATT     0x0002  /*  authorization challenge   <= 4096 octets */
#define PAY_ACO_ATT     0x0003  /*  authorization code        <= 4096 octets */
#define PAY_MCP_ATT     0x0004  /*  middlebox capabilities    64 bits */
#define PAY_PRI_ATT     0x0005  /*  policy rule identifier    32 bits */
#define PAY_PGI_ATT     0x0006  /*  group identifier          32 bits */
#define PAY_PRL_ATT     0x0007  /*  policy rule lifetime      32 bits */
#define PAY_PRO_ATT     0x0008  /*  policy rule owner         <= 255 octets */
#define PAY_ADD_ATT     0x0009  /*  address tuple             64, 96 or 192 bits */
#define PAY_PRR_ATT     0x000A  /*  PRR parameter set         32 bits */
#define PAY_PER_ATT     0x000B  /*  PER parameter set         32 bits */

/* 4.3.3.  Middlebox Capabilities Attribute */
#define CAP_PFF_FLG     0x80  /*  packet filter firewall */
#define CAP_NAT_FLG     0x40  /*  network address translator */
#define CAP_PDR_FLG     0x10  /*  support of PDR transaction */
#define CAP_POT_FLG     0x01  /*  port translation (requires 0x40 set) */
#define CAP_PRT_FLG     0x02  /*  protocol translation (requires 0x40 set) */
#define CAP_2NT_FLG     0x04  /*  twice NAT support (requires 0x40 set) */

#define CAP_I_FLG       0x80  /*   I     :  internal IP address wildcard support */
#define CAP_E_FLG       0x40  /*   E     :  external IP address wildcard support */
#define CAP_P_FLG       0x20  /*   P     :  port wildcard support */
#define CAP_S_FLG       0x10  /*   S     :  persistent storage of policy rules */
#define CAP_IIV4_FLG    0x04  /*   IIV     :  Internal IP4 version */
#define CAP_IIV6_FLG    0x08  /*   IIV     :  Internal IP6 version */
#define CAP_EIV4_FLG    0x01  /*   EIV     :  external IP4 version */
#define CAP_EIV6_FLG    0x02  /*   EIV     :  external IP6 version */

/* 4.3.8.  Address Tuple Attribute */
#define ATA_FAD_FLG     0x00  /*  full addresses */
#define ATA_PRO_FLG     0x10  /*  protocols only */
#define ATA_IP4_FLG     0x01  /*  IPv4 */
#define ATA_IP6_FLG     0x02  /*  IPv6 */

#define ATA_A0_FLG      0x00  /*  internal (A0) */
#define ATA_A1_FLG      0x01  /*  inside   (A1) */
#define ATA_A2_FLG      0x02  /*  outside  (A2) */
#define ATA_A3_FLG      0x03  /*  external (A3) */

/* 4.3.9.  PRR Parameter Set Attribute */
#define PRR_TRA_FLG     0x40  /*  traditional */
#define PRR_TWI_FLG     0x80  /*  twice */

#define PRR_PRA_FLG     0x00  /*  any */
#define PRR_PRO_FLG     0x10  /*  odd */
#define PRR_PRE_FLG     0x20  /*  even */

#define PRR_IPIA_FLG    0x00  /*  IPi any */
#define PRR_IPI4_FLG    0x04  /*  IPi IPv4 */
#define PRR_IPI6_FLG    0x08  /*  IPi IPv6 */

#define PRR_IPOA_FLG    0x00  /*  IPo any */
#define PRR_IPO4_FLG    0x01  /*  IPo IPv4 */
#define PRR_IPO6_FLG    0x02  /*  IPo IPv6 */

/* 4.3.10.  PER Parameter Set Attribute */
#define PER_PPA_FLG     0x00  /*  any */
#define PER_PPS_FLG     0x03  /*  same */

#define PER_INB_FLG     0x01  /*  inbound */
#define PER_OUT_FLG     0x02  /*  outbound */
#define PER_BID_FLG     0x03  /*  bi-directional */

#endif /* _SIMCO_DEFS_H_ */
