summaryrefslogtreecommitdiff
path: root/cleopatre/devkit/plcd/inc/plcd_ctx.h
blob: 793bfe8293bb191db754b68ecf67a118aabe6836 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#ifndef INC_PLCD_CTX_H
#define INC_PLCD_CTX_H
/* Cleopatre project {{{
 *
 * Copyright (C) 2009 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    devkit/plcd/inc/plcd_ctx.h
 * \brief   context structures of plc daemon
 * \ingroup plcd
 */

/* FIXME: This include <net/ethernet.h> cannot be moved,
 * there is a compilation error with lib*.h . */
#include <net/ethernet.h>

#include "libmme.h"
#include "libspid.h"
#include "mmtypes.h"

#include <sys/types.h>
#include <sys/socket.h>
#include <stdint.h>
#include <linux/netlink.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

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
{
    /** Pointer on the program name (argv[0]). */
    const char *my_name;
    /** PID of plcd. */
    pid_t pid;
    /** full path of HPAV info file */
    const char *hpav_info_path;
    /** full path of HPAV config file */
    const char *hpav_conf_path;
    /** full path of PHY config file */
    const char *phy_conf_path;
    /** full path of internal config file */
    const 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;

#endif /* INC_PLCD_CTX_H */