summaryrefslogtreecommitdiff
path: root/cleopatre/devkit/p1905_managerd/inc/p1905_managerd.h
blob: 66b031109c905d8778a043e45216e0b6bf6e9802 (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
143
144
145
146
147
148
149
150
151
152
153
/*
 * cleopatre/application/p1905_managerd/inc/p1905_managerd.h
 *
 * (C) Copyright 2013 MSsar Semiconductor, Inc.
 */
#ifndef P1905_MANAGERD_H
#define P1905_MANAGERD_H

#include <linux/if_packet.h>
#include <netinet/in.h>
#include <net/if.h>
#include <linux/if_ether.h>
#include "p1905_database.h"
#include "../../linux/gpio.h"
#ifdef SUPPORT_WIFI
#include "wifi_utils.h"
#ifdef SUPPORT_AP_AUTO_CONFIG
#include "wsc_attr_tlv.h"
#include "p1905_ap_autoconfig.h"
#endif
#endif

#ifdef SUPPORT_ALME
#include "libalme.h"
#include "alme.h"
#endif

/** Define packet max length */
#define MAX_PKT_LEN     1524

/*define time_to_live of topology discovery database*/
#define TOPOLOGY_DISCOVERY_TTL 70 //70 seconds

/*for vendor specific*/
#define OUI_SPIDCOM     "\x00\x13\xd7"
#define OUI_LEN 3

/* for push button join notify, we must record the current stations
 * information to compare. although in PLC there can be 256 stations, but
 * we use 32 to reduce memory usage.
 */
#define MAX_STATIONS 32

/* HPAV station information, we use this structure to maintain
 * the information gotton from MME(CC_DISCOVER_LIST_CNF)
 */
typedef struct
{
    unsigned char station_num;
    unsigned char station_mac_list[MAX_STATIONS][ETH_ALEN];
    unsigned char new_station[ETH_ALEN];
} hpav_info;

#ifdef SUPPORT_WIFI
typedef struct
{
    unsigned char no_need_start_pbc;
    unsigned char station_num;
    unsigned char station_mac_list[WIFI_MAX_STATION_NUM][ETH_ALEN];
    unsigned char new_station[ETH_ALEN];

} iee802_11_info;
#endif

/* for 1905.1 push button join notification use. */
typedef struct
{
    /*store the al id from push button event notification*/
    unsigned char al_id[ETH_ALEN];
    /*strore the message id from push button event notification*/
    unsigned short mid;
    /*is_sc: 1 ==> simple connect on-going*/
    unsigned char is_sc;
    /*store the information of PLC*/
    hpav_info info;

#ifdef SUPPORT_WIFI
    /*store the information of WIFI*/
    iee802_11_info wifi_info; 
#endif
} push_button_param;

/** Context structure */
struct p1905_managerd_ctx {
    int sock_br0;   /* br0 socket */
    int sock_lldp;  /* lldp socket*/
    /*push button use*/
    int gpio_fd;

    struct sockaddr_ll br0_sll;
    struct sockaddr_ll lldp_sll;

    uint8_t p1905_al_mac_addr[ETH_ALEN];
    uint8_t br0_mac_addr[ETH_ALEN];
    uint8_t plc0_mac_addr[ETH_ALEN];
    uint8_t eth0_mac_addr[ETH_ALEN];
#ifdef SUPPORT_WIFI
    uint8_t wifi0_mac_addr[ETH_ALEN];
#ifdef SUPPORT_AP_AUTO_CONFIG
    ap_config_para *ap_config;
    unsigned char uuid[16];
#ifdef SUPPORT_AP_REGISTRAR
    unsigned char *last_rx_data;
    unsigned short last_rx_length;
#endif
#ifdef SUPPORT_AP_ENROLLE
    unsigned char *last_tx_data;
    unsigned short last_tx_length;
    unsigned char *current_rx_data;
    unsigned short current_rx_length;
    unsigned char is_authenticator_exist_in_M2;
    unsigned char is_in_encrypt_settings;
    unsigned char get_config_attr_kind;
    enrolle_config_stage enrolle_state;
    unsigned short autoconfig_search_mid;
    WSC_CONFIG *ap_config_data;
    unsigned char ap_config_timeout_cnt;
#endif
    unsigned char need_ap_config;
#endif
#endif

#ifdef SUPPORT_ALME
    int sock_alme;
    int almefd;
    unsigned short link_metric_query_mid;
    ALME_STATE alme_state;
    unsigned char alme_wait_4_link_metrics_cnt;
    int semid;
#endif

    /*push button use*/
    union gpio_info sc_it;
    push_button_param pbc_param;
    int push_button_event_notify_by_msg;


    unsigned short mid;
    unsigned char need_relay;

    /*for link metric query/response use*/
    link_metrics_query link_metric_query_para;
    link_metrics_rep link_metric_response_para;

    struct p1905_interface itf[ITF_NUM];
    struct bridge_capabiltiy br_cap[BRIDGE_NUM];
    struct non_p1905_neighbor non_p1905_neighbor_dev[ITF_NUM];
    struct p1905_neighbor p1905_neighbor_dev[ITF_NUM];

    struct p1905_topology_db topology_entry;
};

#endif /* P1905_MANAGERD_H */