/*
   ipmi-lan-cmds.h - IPMI LAN Commands

   Copyright (C) 2003, 2004, 2005 FreeIPMI Core Team

   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; either version 2, or (at your option)
   any later version.

   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.
*/

#ifndef _IPMI_LAN_CMDS_H
#define _IPMI_LAN_CMDS_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <freeipmi/fiid.h>

#define IPMI_AUTHENTICATION_TYPE_SUPPORTED             0x1
#define IPMI_AUTHENTICATION_TYPE_UNSUPPORTED           0x0

#define IPMI_AUTHENTICATION_TYPE_ENABLE                0x1
#define IPMI_AUTHENTICATION_TYPE_DISABLE               0x0

#define IPMI_AUTHENTICATION_TYPE_ENABLE_VALID(__val) \
        (((__val) == IPMI_AUTHENTICATION_TYPE_ENABLE \
         || (__val) == IPMI_AUTHENTICATION_TYPE_DISABLE) ? 1 : 0)

#define IPMI_IP_ADDRESS_SOURCE_UNSPECIFIED                0x0
#define IPMI_IP_ADDRESS_SOURCE_STATIC                     0x1
#define IPMI_IP_ADDRESS_SOURCE_DHCP                       0x2
#define IPMI_IP_ADDRESS_SOURCE_BIOS                       0x3
#define IPMI_IP_ADDRESS_SOURCE_OTHER                      0x4

#define IPMI_IP_ADDRESS_SOURCE_VALID(__val) \
        (((__val) == IPMI_IP_ADDRESS_SOURCE_UNSPECIFIED \
          || (__val) == IPMI_IP_ADDRESS_SOURCE_STATIC \
          || (__val) == IPMI_IP_ADDRESS_SOURCE_DHCP \
          || (__val) == IPMI_IP_ADDRESS_SOURCE_BIOS \
          || (__val) == IPMI_IP_ADDRESS_SOURCE_OTHER) ? 1 : 0)

#define IPMI_BMC_GENERATED_GRATUITOUS_ARPS_ENABLE     0x1
#define IPMI_BMC_GENERATED_GRATUITOUS_ARPS_DISABLE    0x0

#define IPMI_BMC_GENERATED_GRATUITOUS_ARPS_VALID(__val) \
        (((__val) == IPMI_BMC_GENERATED_GRATUITOUS_ARPS_ENABLE \
         || (__val) == IPMI_BMC_GENERATED_GRATUITOUS_ARPS_DISABLE) ? 1 : 0)

#define IPMI_BMC_GENERATED_ARP_RESPONSES_ENABLE       0x1
#define IPMI_BMC_GENERATED_ARP_RESPONSES_DISABLE      0x0

#define IPMI_BMC_GENERATED_ARP_RESPONSES_VALID(__val) \
        (((__val) == IPMI_BMC_GENERATED_ARP_RESPONSES_ENABLE \
         || (__val) == IPMI_BMC_GENERATED_ARP_RESPONSES_DISABLE) ? 1 : 0)

#define IPMI_MAX_COMMUNITY_STRING_LENGTH              18

#define IPMI_DESTINATION_SELECTOR_MIN                 0
#define IPMI_DESTINATION_SELECTOR_MAX                 15

/* To avoid gcc warnings, added +1 and -1 in comparison */
#define IPMI_DESTINATION_SELECTOR_VALID(__val) \
        (((__val + 1) >= (IPMI_DESTINATION_SELECTOR_MIN + 1) \
          || (__val - 1) <= (IPMI_DESTINATION_SELECTOR_MAX - 1))) ? 1 : 0


#define IPMI_DESTINATION_TYPE_PET_TRAP_DESTINATION      0x0
#define IPMI_DESTINATION_TYPE_OEM1                      0x6
#define IPMI_DESTINATION_TYPE_OEM2                      0x7

#define IPMI_DESTINATION_TYPE_VALID(__val) \
        (((__val) == IPMI_DESTINATION_TYPE_PET_TRAP_DESTINATION \
          || (__val) == IPMI_DESTINATION_TYPE_OEM1 \
          || (__val) == IPMI_DESTINATION_TYPE_OEM2) ? 1 : 0)

#define IPMI_ALERT_UNACKNOWLEDGED                       0
#define IPMI_ALERT_ACKNOWLEDGED                         1

#define IPMI_ALERT_VALID(__val) \
        (((__val) ==  IPMI_ALERT_UNACKNOWLEDGED \
          || (__val) == IPMI_ALERT_ACKNOWLEDGED) ? 1 : 0)

#define IPMI_ADDRESS_FORMAT_IPV4                        0

#define IPMI_GATEWAY_SELECTOR_DEFAULT                   0
#define IPMI_GATEWAY_SELECTOR_BACKUP                    1 

#define IPMI_GATEWAY_SELECTOR_VALID(__val) \
        (((__val) ==  IPMI_GATEWAY_SELECTOR_DEFAULT \
          || (__val) == IPMI_GATEWAY_SELECTOR_BACKUP) ? 1 : 0)

/* 3 bit number */
#define IPMI_ALERT_RETRIES_MAX                          7

#define IPMI_VLAN_ID_ENABLE                             0x1
#define IPMI_VLAN_ID_DISABLE                            0x0

#define IPMI_VLAN_ID_ENABLE_VALID(__val) \
        (((__val) ==  IPMI_VLAN_ID_ENABLE \
          || (__val) == IPMI_VLAN_ID_DISABLE) ? 1 : 0)

#define IPMI_BMC_GENERATED_GRATUITOUS_ARP_DO_NOT_SUSPEND    0x0
#define IPMI_BMC_GENERATED_GRATUITOUS_ARP_SUSPEND           0x1

#define IPMI_BMC_GENERATED_GRATUITOUS_ARP_VALID(__val) \
        (((__val) ==  IPMI_BMC_GENERATED_GRATUITOUS_ARP_DO_NOT_SUSPEND \
          || (__val) == IPMI_BMC_GENERATED_GRATUITOUS_ARP_SUSPEND) ? 1 : 0)

#define IPMI_BMC_GENERATED_ARP_RESPONSE_DO_NOT_SUSPEND      0x0
#define IPMI_BMC_GENERATED_ARP_RESPONSE_SUSPEND             0x1

#define IPMI_BMC_GENERATED_ARP_RESPONSE_VALID(__val) \
        (((__val) ==  IPMI_BMC_GENERATED_ARP_RESPONSE_DO_NOT_SUSPEND \
          || (__val) == IPMI_BMC_GENERATED_ARP_RESPONSE_SUSPEND) ? 1 : 0)

#define IPMI_GET_LAN_PARAMETER                          0x0
#define IPMI_GET_LAN_PARAMETER_REVISION_ONLY            0x1

#define IPMI_GET_LAN_PARAMETER_VALID(__val) \
        (((__val) == IPMI_GET_LAN_PARAMETER \
          || (__val) == IPMI_GET_LAN_PARAMETER_REVISION_ONLY) ? 1 : 0)

extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_rs;

extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_authentication_type_enables_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_ip_address_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_ip_address_source_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_mac_address_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_subnet_mask_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_bmc_generated_arp_control_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_gratuitous_arp_interval_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_default_gateway_address_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_default_gateway_mac_address_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_backup_gateway_address_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_backup_gateway_mac_address_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_community_string_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_destination_type_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_destination_addresses_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_vlan_id_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_vlan_priority_rq;
extern fiid_template_t tmpl_cmd_set_lan_configuration_parameters_rmcpplus_messaging_cipher_suite_privilege_levels_rq;

extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_rq;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_rs;

extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_authentication_type_support_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_authentication_type_enables_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_ip_address_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_ip_address_source_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_mac_address_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_subnet_mask_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_bmc_generated_arp_control_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_gratuitous_arp_interval_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_default_gateway_address_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_default_gateway_mac_address_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_backup_gateway_address_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_backup_gateway_mac_address_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_community_string_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_number_of_destinations_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_destination_type_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_destination_addresses_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_vlan_id_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_vlan_priority_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_rmcpplus_messaging_cipher_suite_entry_support_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_rmcpplus_messaging_cipher_suite_entries_rs;
extern fiid_template_t tmpl_cmd_get_lan_configuration_parameters_rmcpplus_messaging_cipher_suite_privilege_levels_rs;

extern fiid_template_t tmpl_cmd_suspend_bmc_arps_rq;
extern fiid_template_t tmpl_cmd_suspend_bmc_arps_rs;

int8_t fill_cmd_set_lan_configuration_parameters (uint8_t channel_number,
                                                  uint8_t parameter_selector,
                                                  uint8_t *configuration_parameter_data,
                                                  uint8_t configuration_parameter_data_len,
						  fiid_obj_t obj_cmd_rq);

int8_t fill_cmd_set_lan_configuration_parameters_authentication_type_enables (uint8_t channel_number,
                                                                              uint8_t callback_level_none,
                                                                              uint8_t callback_level_md2,
                                                                              uint8_t callback_level_md5,
                                                                              uint8_t callback_level_straight_password,
                                                                              uint8_t callback_level_oem_proprietary,
                                                                              uint8_t user_level_none,
                                                                              uint8_t user_level_md2,
                                                                              uint8_t user_level_md5,
                                                                              uint8_t user_level_straight_password,
                                                                              uint8_t user_level_oem_proprietary,
                                                                              uint8_t operator_level_none,
                                                                              uint8_t operator_level_md2,
                                                                              uint8_t operator_level_md5,
                                                                              uint8_t operator_level_straight_password,
                                                                              uint8_t operator_level_oem_proprietary,
                                                                              uint8_t admin_level_none,
                                                                              uint8_t admin_level_md2,
                                                                              uint8_t admin_level_md5,
                                                                              uint8_t admin_level_straight_password,
                                                                              uint8_t admin_level_oem_proprietary,
                                                                              uint8_t oem_level_none,
                                                                              uint8_t oem_level_md2,
                                                                              uint8_t oem_level_md5,
                                                                              uint8_t oem_level_straight_password,
                                                                              uint8_t oem_level_oem_proprietary,
                                                                              fiid_obj_t obj_cmd_rq);
 
int8_t fill_cmd_set_lan_configuration_parameters_ip_address (uint8_t channel_number,
                                                             uint32_t ip_address,
                                                             fiid_obj_t obj_cmd_rq);
   
int8_t fill_cmd_set_lan_configuration_parameters_ip_address_source (uint8_t channel_number,
                                                                    uint8_t ip_address_source,
                                                                    fiid_obj_t obj_cmd_rq);

int8_t fill_cmd_set_lan_configuration_parameters_mac_address (uint8_t channel_number,
                                                              uint64_t mac_address,
                                                              fiid_obj_t obj_cmd_rq);

int8_t fill_cmd_set_lan_configuration_parameters_subnet_mask (uint8_t channel_number,
                                                              uint32_t subnet_mask,
                                                              fiid_obj_t obj_cmd_rq);
  
int8_t fill_cmd_set_lan_configuration_parameters_bmc_generated_arp_control (uint8_t channel_number,
                                                                            uint8_t bmc_generated_gratuitous_arps,
                                                                            uint8_t bmc_generated_arp_responses,
                                                                            fiid_obj_t obj_cmd_rq);

int8_t fill_cmd_set_lan_configuration_parameters_gratuitous_arp_interval (uint8_t channel_number,
                                                                          uint8_t gratuitous_arp_interval,
                                                                          fiid_obj_t obj_cmd_rq);

int8_t fill_cmd_set_lan_configuration_parameters_default_gateway_address (uint8_t channel_number,
                                                                          uint32_t ip_address,
                                                                          fiid_obj_t obj_cmd_rq);

int8_t fill_cmd_set_lan_configuration_parameters_default_gateway_mac_address (uint8_t channel_number,
                                                                              uint64_t mac_address,
                                                                              fiid_obj_t obj_cmd_rq);

int8_t fill_cmd_set_lan_configuration_parameters_backup_gateway_address (uint8_t channel_number,
                                                                         uint32_t ip_address,
                                                                         fiid_obj_t obj_cmd_rq);
  
int8_t fill_cmd_set_lan_configuration_parameters_backup_gateway_mac_address (uint8_t channel_number,
                                                                             uint64_t mac_address,
                                                                             fiid_obj_t obj_cmd_rq);

int8_t fill_cmd_set_lan_configuration_parameters_community_string (uint8_t channel_number,
                                                                   char *community_string,
                                                                   unsigned int community_string_len,
                                                                   fiid_obj_t obj_cmd_rq);

int8_t fill_cmd_set_lan_configuration_parameters_destination_type (uint8_t channel_number,
                                                                   uint8_t destination_selector,
                                                                   uint8_t destination_type,
                                                                   uint8_t alert_acknowledge,
                                                                   uint8_t alert_acknowledge_timeout,
                                                                   uint8_t retries,
                                                                   fiid_obj_t obj_cmd_rq);

int8_t fill_cmd_set_lan_configuration_parameters_destination_addresses (uint8_t channel_number,
                                                                        uint8_t destination_selector,
                                                                        uint8_t gateway_selector,
                                                                        uint32_t alerting_ip_address,
                                                                        uint64_t alerting_mac_address,
                                                                        fiid_obj_t obj_cmd_rq);

int8_t fill_cmd_set_lan_configuration_parameters_vlan_id (uint8_t channel_number,
                                                          uint16_t vlan_id,
                                                          uint8_t vlan_id_enable,
                                                          fiid_obj_t obj_cmd_rq);

int8_t fill_cmd_set_lan_configuration_parameters_vlan_priority (uint8_t channel_number,
                                                                uint8_t vlan_priority,
                                                                fiid_obj_t obj_cmd_rq);
  
int8_t fill_cmd_set_lan_configuration_parameters_rmcpplus_messaging_cipher_suite_privilege_levels(uint8_t channel_number,
												  uint8_t maximum_privilege_for_cipher_suite_1,
												  uint8_t maximum_privilege_for_cipher_suite_2,
												  uint8_t maximum_privilege_for_cipher_suite_3,
												  uint8_t maximum_privilege_for_cipher_suite_4,
												  uint8_t maximum_privilege_for_cipher_suite_5,
												  uint8_t maximum_privilege_for_cipher_suite_6,
												  uint8_t maximum_privilege_for_cipher_suite_7,
												  uint8_t maximum_privilege_for_cipher_suite_8,
												  uint8_t maximum_privilege_for_cipher_suite_9,
												  uint8_t maximum_privilege_for_cipher_suite_10,
												  uint8_t maximum_privilege_for_cipher_suite_11,
												  uint8_t maximum_privilege_for_cipher_suite_12,
												  uint8_t maximum_privilege_for_cipher_suite_13,
												  uint8_t maximum_privilege_for_cipher_suite_14,
												  uint8_t maximum_privilege_for_cipher_suite_15,
												  uint8_t maximum_privilege_for_cipher_suite_16,
												  fiid_obj_t obj_cmd_rq);
  
int8_t fill_cmd_get_lan_configuration_parameters (uint8_t channel_number,
                                                  uint8_t get_parameter,
                                                  uint8_t parameter_selector,
                                                  uint8_t set_selector,
                                                  uint8_t block_selector,
                                                  fiid_obj_t obj_cmd_rq);

int8_t fill_cmd_suspend_bmc_arps (uint8_t channel_number,
                                  uint8_t gratuitous_arp_suspend,
                                  uint8_t arp_response_suspend,
                                  fiid_obj_t obj_cmd_rq);

#ifdef __cplusplus
}
#endif

#endif
