summaryrefslogtreecommitdiff
path: root/cesar/cp/sta/action/inc/context.h
blob: fba7e34d5d745ea83511841459b81cf3690d3be7 (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
#ifndef cp_sta_action_inc_context_h
#define cp_sta_action_inc_context_h
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    cp/sta/action/inc/context.h
 * \brief   STA action context.
 * \ingroup cp_sta_action
 */
#include "cp/secu/secu.h"
#include "cp/sta/mgr/net.h"
#include "cp/sta/core/core.h"
#include "cp/msg/inc/drv_sta_set_key.h"

/** STA action/assoc sub-context. */
struct cp_sta_action_assoc_t
{
    /** CCo peer structure to which association is pending. */
    cp_mme_peer_t peer;
    /** CCo's snid for association. */
    cp_snid_t snid;
    /** Retry count left for association. */
    uint retry;
    /** Protocol run used for authentication. */
    cp_secu_protocol_run_t prun;
    /** Association or leave timer. */
    cp_sta_core_timed_event_def_t timer;
    /** Lease renewal timer. */
    cp_sta_core_timed_event_def_t lease_timer;
    /** Number of lost central beacons since the last beacon reception. */
    uint beacon_loss;
    /** Retry TEI lease timeout, only used to program an event timer to resent
     * the renew request in case the first request has not been confirmed. */
    uint tei_renew_retry_timeout_ms;
};


/** nmk and nid set at poweron enter. */
struct cp_sta_action_poweron_enter_t
{
    /** nid and nmk need to be set. */
    bool need_set;
    /** The new nmk. */
    cp_key_t nmk;
    /** The key type. */
    cp_msg_drv_sta_set_key_type_t type;
    /** The new nid. */
    cp_nid_t nid;
};

typedef struct cp_sta_action_poweron_enter_t cp_sta_action_poweron_enter_t;

/** STA action/poweron sub-context. */
struct cp_sta_action_poweron_t
{
    /** nmk and nid set at poweron enter. */
    cp_sta_action_poweron_enter_t enter;
    /** BTT timer. */
    cp_sta_core_timed_event_def_t btt_timer;
    /** USTT timer. */
    cp_sta_core_timed_event_def_t ustt_timer;
    /** Join timer, to leave CCo state if no STA joined. */
    cp_sta_core_timed_event_def_t join_timer;
};

/** STA action/bridge sub-context. */
struct cp_sta_action_bridge_t
{
    /** Minimum time to wait before sending a new bridge table after an
     * update. Must be less than wait_time_without_update_s. */
    uint min_time_send_new_s;
    /** Time to wait before sending the bridge table when there is no
     * update. Must be more than min_time_send_new_s. */
    uint wait_time_without_update_s;
    /** Count of cycle since last emission of the bridge table. This cycle
     * count will be rounded to wait_time_without_update_s! So it does not
     * count cycle after a certain period of time (this is to prevent
     * overflow). */
    uint cycle_count_since_last_emission;
};

/**
 * STA action/simple connect sub context.
 */
struct cp_sta_action_sc_t
{
    /** Timeout timer. This timer is for the whole SC procedure, not just for
     * an MME. */
    cp_sta_core_timed_event_def_t timeout_timer;
    /** Timer for the SC_JOIN_REQ periodic broadcast. */
    cp_sta_core_timed_event_def_t timer_sc_join_req_broadcast;
    /** SC peer with witch we are doing the SC procedure. */
    cp_mme_peer_t peer;
    /** Hash key generated for TEK. */
    u32 hash_key[CP_HASH_KEY_SIZE / sizeof (u32)];
    /** CP Secu Protocol Run. */
    cp_secu_protocol_run_t prun;
    /** TEK generated. */
    cp_key_t tek;
};

/** STA action context */
struct cp_sta_action_t
{
    /** WHO_RU.REQ timeout. */
    cp_sta_core_timed_event_def_t whoru_timer;
    /** Peer to whom answer the cm_hfid.req when we get who_ru reply. */
    cp_mme_peer_t cm_hfid_reply_peer;
    /** Driver peer. */
    cp_mme_peer_t drv_peer;
    /** Assoc part. */
    struct cp_sta_action_assoc_t assoc;
    /** Power-on part. */
    struct cp_sta_action_poweron_t poweron;
    /** Bridge part. */
    struct cp_sta_action_bridge_t bridge;
    /** Simple Connect part. */
    struct cp_sta_action_sc_t sc;
    /** Protocol run for exchange NEK. */
    cp_secu_protocol_run_t nek_prun;
};
typedef struct cp_sta_action_t cp_sta_action_t;

#endif /* cp_sta_action_inc_context_h */