/* SPC300 bundle {{{ * * Copyright (C) 2009 Spidcom * * <<>> * * }}} */ /** * \file devkit/plcd/inc/plcd.h * \brief structures and defines of plcd * \ingroup plcd * * */ #ifndef PLCD_H #define PLCD_H #include #include #include #include #include #include #include "mmtypes.h" #define PLCD_ASSERT(condition) \ { \ if (!(condition)) \ { \ syslog (LOG_ERR, "%s: %d: %s: Assertion '%s' failed.", \ __FILE__, __LINE__, __PRETTY_FUNCTION__, __STRING(condition)); \ abort(); \ } \ } #define MME_TYPE_MASK 0x0003 #define MME_RESULT_SUCCESS 0x00 #define PLCD_EVENT_REFRESH_TIMEOUT_MS 1000 #define PLCD_INIT_RETRIES 10 /* Interface name */ #define PLC_IFNAME "plc0" typedef enum { MME_DRV_STATUS_ASSOC_UNASSOCIATED = 0, MME_DRV_STATUS_ASSOC_ASSOCIATED, MME_DRV_STATUS_ASSOC_AUTHENTICATED, MME_DRV_STATUS_ASSOC_NB } mme_drv_status_assoc_t; typedef enum { MME_DRV_STATUS_CCO_STATION = 0, MME_DRV_STATUS_CCO_PROXY, MME_DRV_STATUS_CCO_MAIN, MME_DRV_STATUS_CCO_NB } mme_drv_status_cco_t; typedef enum { MME_DRV_SC_ADD = 0, MME_DRV_SC_JOIN, MME_DRV_SC_NB } mme_drv_sc_t; typedef enum { MME_DRV_KEY_TYPE_NID = 0, MME_DRV_KEY_TYPE_SL, MME_DRV_KEY_TYPE_NB } mme_drv_key_type_t; typedef enum { MME_DRV_KEY_SL_SC = 0, MME_DRV_KEY_SL_HS, MME_DRV_KEY_SL_NB } mme_drv_key_sl_t; /** NVRAM fields needed by plcd */ typedef struct { unsigned char plc_address[6]; char device_password[32]; char product_name[64]; char tonemask[192]; } plcd_nvram_t; /** main context of plc daemon */ typedef struct { /** full path of HPAV info file */ char *hpav_info_path; /** full path of HPAV config file */ char *hpav_conf_path; /** full path of internal config file */ char *internal_conf_path; /** netlink socket descriptor for PLC driver comm */ int plc_sock; /** plcd netlink address descriptor for PLC driver comm */ struct sockaddr_nl plcd_addr; /** NVRAM structure */ plcd_nvram_t *nvram; /** indicates if configuration files have to be saved in flash */ libspid_boolean_t is_save_conf_needed; /** indicates if other processes have to be informed about files modifications */ libspid_boolean_t is_warn_needed; /* hpav.conf last values */ struct { /* CCo preference */ libspid_boolean_t is_cco_preferred; /* CCo status at boot */ libspid_boolean_t was_cco; /* NMK value */ char nmk_str[LIBSPID_HPAV_CONF_NMK_STR_LEN]; /* NID value */ char nid_str[LIBSPID_HPAV_CONF_NID_STR_LEN]; /* SL value */ char sl_str[LIBSPID_HPAV_CONF_SL_STR_MAX_LEN]; /* user HFID value */ char user_hfid[LIBSPID_HPAV_CONF_HFID_MAX_LEN]; /* AVLN HFID value */ char avln_hfid[LIBSPID_HPAV_CONF_HFID_MAX_LEN]; } hpav_conf; /* hpav.info last values */ libspid_hpav_info_t hpav_info; /** Last time the multicast info file was checked. */ struct timespec mcast_last_check; } plcd_ctx_t; /* Global variable indicating if a SIGHUP signal occurred, * has been caught in plcd signal handler, * and has now to be processed. */ extern volatile sig_atomic_t is_process_signal_needed; /* Global handler on autoswitch timer. */ extern timer_t autoswitch_timer; extern int autoswitch_en; extern int autoswitch_timer_alive; #define PLCD_AUTOSWITCH_TIMEOUT_SEC 60 void plcd_autoswitch_timer_init (void); void plcd_autoswitch_image_update (void); int plcd_send_recv_drv_mme (const plcd_ctx_t *ctx, const mme_ctx_t *request_ctx, mme_ctx_t *confirm_ctx, mme_ctx_t *indication_ctx); /** * Tell whether the multicast info file was updated since last check. * \param ctx The context; * \return LIBSPID_TRUE, if the multicast info has been updated. * LIBSPID_FALSE, if no update since last check. */ libspid_boolean_t plcd_multicast_info_updated (plcd_ctx_t *ctx); /** * Process the multicast info. * \param ctx the plcd context. */ void plcd_multicast_process (plcd_ctx_t *ctx); #endif /* PLCD_H */