/* * cleopatre/application/managerd/inc/vs_mme.h * * (C) Copyright 2009 SPiDCOM Technologies * * 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 of * the License, 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #ifndef VS_MME_H #define VS_MME_H #include "libmme.h" #include "managerd.h" #include "bridge.h" #define SPC300_ID 0x0001 #define PLC_VERSION_PATH "/proc/net/plc/version" #define FIRMWARE_LABEL "PLC Firmware" #define MME_RESULT_SUCCESS 0 #define MME_RESULT_FAILURE 1 #define MME_RESULT_TIMEOUT 2 #define MME_RESULT_BAD_IDX 2 #define MAX_NVRAM_BLK 64 /** if function fwrite failed during update, retry flash write */ #define FLASH_RETRY_COUNT 2 /** tftp update action **/ #define TFTP_UPDATE_ACTION_NONE "0" /** tftp update status **/ #define TFTP_UPDATE_SUCCESS "2" #define TFTP_UPDATE_FAILED "3" typedef struct { uint8_t oui[3]; uint8_t result; uint16_t device_id; uint8_t current_image_index; uint8_t applicative_version[16]; uint8_t av_stack_version[64]; uint8_t applicative_alternate[16]; } __attribute__ ((__packed__)) vs_get_version_cnf_t; typedef enum { ETH_STATS_COMMAND_GET = 0, ETH_STATS_COMMAND_RESET, ETH_STATS_COMMAND_NB } vs_eth_stats_command_t; typedef struct { uint8_t oui[3]; uint8_t command; } __attribute__ ((__packed__)) vs_eth_stats_req_t; typedef struct { uint8_t oui[3]; uint8_t result; } __attribute__ ((__packed__)) vs_reset_cnf_t; typedef struct { uint8_t oui[3]; uint8_t result; } __attribute__ ((__packed__)) vs_factory_cnf_t; typedef struct { uint8_t oui[3]; uint8_t result; uint32_t rx_bytes_low; uint32_t rx_bytes_high; uint32_t rx_packets_low; uint32_t rx_packets_high; uint32_t rx_errors; uint32_t rx_dropped; uint32_t rx_overruns; uint32_t rx_frames; uint32_t tx_bytes_low; uint32_t tx_bytes_high; uint32_t tx_packets_low; uint32_t tx_packets_high; uint32_t tx_errors; uint32_t tx_dropped; uint32_t tx_fifo; uint32_t tx_collisions; uint32_t tx_carrier; } __attribute__ ((__packed__)) vs_eth_stats_cnf_t; typedef struct { uint8_t oui[3]; uint8_t index; } __attribute__ ((__packed__)) vs_get_nvram_req_t; typedef struct { uint8_t oui[3]; uint8_t result; uint8_t index; uint8_t data[1024]; } __attribute__ ((__packed__)) vs_get_nvram_cnf_t; typedef struct { uint8_t oui[3]; uint8_t protocol; uint8_t version_id[16]; uint32_t arch; uint32_t type; uint8_t board_type[32]; uint8_t file[LIBSPID_UPDATE_FILE_STR_MAX_LEN]; uint8_t server_ip[LIBSPID_IP_STR_MAX_LEN]; uint8_t server_port[LIBSPID_UPDATE_PORT_STR_MAX_LEN]; uint8_t md5_sum[MD5_DIGEST_LENGTH]; } __attribute__ ((__packed__)) vs_update_start_req_t; typedef struct { uint8_t oui[3]; uint8_t status; } __attribute__ ((__packed__)) vs_update_start_cnf_t; typedef struct { uint8_t oui[3]; uint32_t id; uint32_t len; uint8_t data[LIBSPID_TRANSFER_MAX_SLICE]; } __attribute__ ((__packed__)) vs_update_transfer_req_t; typedef struct { uint8_t oui[3]; uint8_t status; uint32_t id; } __attribute__ ((__packed__)) vs_update_transfer_cnf_t; typedef struct { uint8_t oui[3]; uint8_t md5_sum[MD5_DIGEST_LENGTH]; } __attribute__ ((__packed__)) vs_update_end_req_t; typedef struct { uint8_t oui[3]; uint8_t status; } __attribute__ ((__packed__)) vs_update_end_cnf_t; typedef struct { uint8_t oui[3]; uint8_t status; } __attribute__ ((__packed__)) vs_update_end_ind_t; struct firmware_slice { uint8_t slice[LIBSPID_TRANSFER_MAX_SLICE]; uint32_t size; struct firmware_slice *next; }; typedef struct firmware_slice firmware_slice_t; typedef struct { int lock; int next_blk_id; int bsize; long fsize; int flash_sector; FILE *fp; firmware_slice_t *head; firmware_slice_t *curr; char mtd_name[32]; pthread_t timer; pthread_t writer; pthread_mutex_t mutex; int exit_timer; int exit_writer; int nb_img; unsigned char mac[ETH_ALEN]; int protocol; int tftp_write; } __attribute__ ((__packed__)) update_ctx_t; extern enum bridge_status vs_mme_get_version (struct managerd_ctx *ctx, MME_t *request, MME_t * confirm, int len); extern enum bridge_status vs_mme_eth_stats (struct managerd_ctx *ctx, MME_t *request, MME_t * confirm, int len); extern enum bridge_status vs_mme_reset (struct managerd_ctx *ctx, MME_t *request, MME_t *confirm, int len); extern enum bridge_status vs_mme_reset_handler (struct managerd_ctx *ctx, MME_t *request, MME_t * confirm, int len); extern enum bridge_status vs_mme_factory (struct managerd_ctx *ctx, MME_t *request, MME_t *confirm, int len); extern enum bridge_status vs_mme_update_start (struct managerd_ctx *ctx, MME_t *request, MME_t *confirm, int len); extern enum bridge_status vs_mme_update_transfer (struct managerd_ctx *ctx, MME_t *request, MME_t *confirm, int len); extern enum bridge_status vs_mme_update_end (struct managerd_ctx *ctx, MME_t *request, MME_t *confirm, int len); extern enum bridge_status vs_mme_tftp_update_end_recv_indication (struct managerd_ctx *ctx, MME_t *request, MME_t *confirm, int len); enum bridge_status vs_mme_get_nvram (struct managerd_ctx *ctx, MME_t *request, MME_t *confirm, int len); #endif /* VS_MME_H */