summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschodet2008-04-03 12:43:34 +0000
committerschodet2008-04-03 12:43:34 +0000
commit93df0c08a6af55d84089bfdd03b0b6dcbe99cc00 (patch)
treea236619eb3340adce8d9755a299a4af6fc058da1
parenta7495e984b3bb30953aaa80e1f30d485c7ac7fdb (diff)
* cp2/sta/action:
- splitted functions by features. - added doc. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1746 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cp2/sta/action/action.h275
-rw-r--r--cp2/sta/action/assoc.h190
-rw-r--r--cp2/sta/action/doc/Makefile47
-rw-r--r--cp2/sta/action/doc/assoc.sdl21
-rw-r--r--cp2/sta/action/doc/cp_sta_action.odtbin0 -> 146879 bytes
-rw-r--r--cp2/sta/action/key.h165
-rw-r--r--cp2/sta/action/misc.h117
7 files changed, 543 insertions, 272 deletions
diff --git a/cp2/sta/action/action.h b/cp2/sta/action/action.h
index a390fa3435..6182b65964 100644
--- a/cp2/sta/action/action.h
+++ b/cp2/sta/action/action.h
@@ -15,145 +15,13 @@
* This module implements actions defined in the FSM and actions corresponding
* to MME reception.
*/
+#include "cp/sta/action/assoc.h"
+#include "cp/sta/action/key.h"
+#include "cp/sta/action/misc.h"
BEGIN_DECLS
/**
- * Process a CC_WHO_RU.REQ, 11.2.26.
- * \param ctx control plane context
- * \param mme received MME handle
- * \param nid NID of network being queried
- *
- * Provide AVLN identity and CCo MAC address. If the NID correspond to our
- * NID, send a CC_WHO_RU.CNF. In other cases, drop.
- *
- * Need:
- * - our CCo MAC address.
- * - our AVLN HFID.
- */
-void
-cp_sta_action_process_cc_who_ru_req (cp_t *ctx, cp_mme_t *mme, cp_nid_t nid);
-
-/**
- * Process a CC_ASSOC.CNF, 11.2.29.
- * \param ctx control plane context
- * \param mme received MME handle
- * \param result association result
- * \param nid NID of the sender network
- * \param snid SNID of the sender network
- * \param tei new TEI to use, valid if association is successful
- * \param lease_time_min period of time of TEI validity
- *
- * Confirmation from the CCo on association request. If this does not
- * correspond to a previously sent request, drop. If the CCo accepted our
- * association, update TEI and lease time. Post an event according to
- * association result.
- *
- * Need:
- * - whether a association is pending and its characteristics.
- *
- * Update:
- * - our TEI.
- * - our TEI lease time (update lease timer).
- */
-void
-cp_sta_action_process_cc_assoc_cnf (cp_t *ctx, cp_mme_t *mme,
- cp_msg_cc_assoc_cnf_result_t result,
- cp_nid_t nid, cp_snid_t snid,
- cp_tei_t tei, uint lease_time_min);
-
-/**
- * Process a CC_LEAVE.CNF, 11.2.31.
- * \param ctx control plane context
- * \param mme received MME handle
- *
- * Confirmation from the CCo on leave request. If this does not correspond to
- * a previously sent request, drop. Else, post an event to leave the AVLN.
- *
- * Need:
- * - whether a leave is pending and its characteristics.
- */
-void
-cp_sta_action_process_cc_leave_cnf (cp_t *ctx, cp_mme_t *mme);
-
-/**
- * Process a CC_LEAVE.IND, 11.2.32.
- * \param ctx control plane context
- * \param mme received MME handle
- * \param reason reason for the disassociation
- * \param nid NID
- *
- * The CCo ask us to leave the AVLN. Send a CC_LEAVE.RSP, and post an event
- * to leave the AVLN.
- *
- * Need:
- * - our AVLN NID (to check message).
- */
-void
-cp_sta_action_process_cc_leave_ind (cp_t *ctx, cp_mme_t *mme,
- cp_msg_cc_leave_ind_reason_t reason,
- nid_t nid);
-
-/**
- * Process a CC_SET_TEI_MAP.IND, 11.2.35.
- * \param ctx control plane context
- * \param mme received MME handle
- * \param mode update, add or remove
- *
- * The CCo send an update of the AVLN list of STA. According to the mode,
- * update the whole list, add or remove a STA.
- *
- * Need:
- * - use a cp_msg function to read the rest of the message.
- *
- * Update:
- * - STA mgr.
- */
-void
-cp_sta_action_process_cc_set_tei_map_ind_update (
- cp_t *ctx, cp_mme_t *mme, cp_msg_cc_set_tei_map_ind_mode_t mode);
-
-/**
- * Process a CC_RELAY.REQ, 11.2.36.
- * \param ctx control plane context
- * \param mme received MME handle
- * \param fda final destination address
- * \param ftei final destination TEI
- * \param len payload size
- *
- * Extract the payload from the MME, and encapsulate it in a CC_RELAY.IND to
- * the final destination.
- *
- * There is special behaviour depending on the contained payload. If the
- * relay request is not encrypted, only relay MME which are permitted to be
- * unencrypted. If the relay request is not encrypted and contains a
- * CM_ENCRYPTED_PAYLOAD.IND, the CC_RELAY.IND should be sent broadcast. This
- * could be done by the cp_msg module.
- *
- * - What to do with the MAC address?
- */
-void
-cp_sta_action_process_cc_relay_req (cp_t *ctx, cp_mme_t *mme, mac_t fda,
- cp_tei_t ftei, uint len);
-
-/**
- * Process a CC_RELAY.IND, 11.2.37.
- * \param ctx control plane context
- * \param mme received MME handle
- * \param osa original source address
- * \param otei original source TEI
- * \param len payload size
- *
- * Extract the payload and insert the message back.
- *
- * Relay station is trusted as long as it is authenticated. It should have
- * filtered unauthorised payload.
- */
-void
-cp_sta_action_process_cc_relay_ind (cp_t *ctx, cp_mme_t *mme, mac_t osa,
- cp_tei_t otei, uint len);
-
-/**
* Process a CM_UNASSOCIATED_STA.IND, 11.5.1.
* \param ctx control plane context
* \param mme received MME handle
@@ -173,143 +41,6 @@ cp_sta_action_process_cm_unassociated_sta_ind (cp_t *ctx, cp_mme_t *mme,
cp_nid_t nid,
cp_cco_cap_t cco_cap);
-/**
- * Process a CM_SET_KEY.REQ, 11.5.4.
- * \param ctx control plane context
- * \param mme received MME handle
- * \param key_type key type being set
- * \param my_nounce to be used in next message
- * \param your_nounce used in previous message
- * \param pid protocol identifier
- * \param prn protocol run number
- * \param pmn protocol message number
- * \param cco_cap CCo capabilities of the sending STA
- * \param nid NID of the sender network, associated with the NMK
- * \param new_eks EKS of the key being set
- * \param new_key new key, or NULL if none.
- *
- * This message is used in several protocol. First check that this message is
- * legitimate, then depending of the protocol, generated the corresponding
- * events.
- *
- * \todo List all the possible usages in order to split this message handling.
- */
-void
-cp_sta_action_process_cm_set_key_req (cp_t *ctx, cp_mme_t *mme,
- cp_key_type_t key_type,
- u32 my_nounce, u32 your_nounce,
- cp_pid_t pid,
- u16 prn, u8 pmn,
- cp_cco_cap_t cco_cap,
- cp_nid_t nid,
- u8 new_eks,
- cp_key_t *new_key);
-
-/**
- * Process a CM_SET_KEY.CNF, 11.5.5.
- * \param ctx control plane context
- * \param mme received MME handle
- * \param result transaction result
- * \param my_nounce to be used in next message
- * \param your_nounce used in previous message
- * \param pid protocol identifier
- * \param prn protocol run number
- * \param pmn protocol message number
- * \param cco_cap CCo capabilities of the sending STA
- *
- * Response from a preceding CM_SET_KEY.REQ. First check that this message is
- * legitimate and that it correspond to a sent request.
- *
- * This message can be forwarded to the CCo module.
- *
- * \todo List all the possible usages in order to split this message handling.
- */
-void
-cp_sta_action_process_cm_set_key_cnf (cp_t *ctx, cp_mme_t *mme,
- cp_msg_cm_set_key_cnf_result_t result,
- u32 my_nounce, u32 your_nounce,
- cp_pid_t pid,
- u16 prn, u8 pmn,
- cp_cco_cap_t cco_cap);
-
-/**
- * Process a CM_GET_KEY.REQ, 11.5.6.
- * \param ctx control plane context
- * \param mme received MME handle
- * \param req_type request type (relayed or not)
- * \param key_type requested key type
- * \param nid NID of the network of the sender, or the sender want to join
- * \param my_nounce to be used in next message
- * \param pid protocol identifier
- * \param prn protocol run number
- * \param pmn protocol message number
- * \param hash HASH key, used to generate a TEK, or NULL if not present
- *
- * Can only be sent unencrypted for UKE to derive a TEK from HASH exchange.
- *
- * If requested key is the NEK, forward to CCo module.
- *
- * If requested key is the NMK, this is a NMK provisioning.
- *
- * \todo List all the possible usages in order to split this message handling.
- */
-void
-cp_sta_action_process_cm_get_key_req (cp_t *ctx, cp_mme_t *mme,
- cp_msg_cm_get_key_req_type_t req_type,
- cp_key_type_t key_type,
- cp_nid_t nid,
- u32 my_nounce,
- cp_pid_t pid,
- u16 prn, u8 pmn,
- u8 *hash);
-
-/**
- * Process a CM_GET_KEY.CNF, 11.5.7.
- * \param ctx control plane context
- * \param mme received MME handle
- * \param result transaction result
- * \param key_type requested key type
- * \param my_nounce to be used in next message
- * \param your_nounce used in previous message
- * \param nid NID of the sender network
- * \param eks EKS of the received key
- * \param pid protocol identifier
- * \param prn protocol run number
- * \param pmn protocol message number
- * \param hash HASH key, used to generate a TEK, or NULL if not present
- * \param key received key, or NULL if not present
- *
- * Response from a CM_GET_KEY.REQ.
- *
- * \todo List all the possible usages in order to split this message handling.
- */
-void
-cp_sta_action_process_cm_get_key_cnf (cp_t *ctx, cp_mme_t *mme,
- cp_msg_cm_get_key_cnd_result_t result,
- cp_key_type_t key_type,
- u32 my_nounce, u32 your_nounce,
- cp_nid_t nid,
- u8 eks,
- cp_pid_t pid,
- u16 prn, u8 pmn,
- u8 *hash, cp_key_t *key);
-
-/**
- * Process a CM_MME_ERROR.IND, 11.5.32.
- * \param ctx control plane context
- * \param mme received MME handle
- * \param reason reason of the error
- * \param rx_mmv MMV of the erroneous MME
- * \param rx_mmtype MMTYPE of the erroneous MME
- * \param invalid_byte_offset offset in the MME of the error
- *
- * Used for debug. Trace the error.
- */
-void
-cp_sta_action_process_cm_mme_error_ind (
- cp_t *ctx, cp_mme_t *mme, cp_msg_cm_mme_error_ind_reason_t reason,
- u8 rx_mmv, u16 rx_mmtype, u16 invalid_byte_offset);
-
END_DECLS
#endif /* cp_sta_action_action_h */
diff --git a/cp2/sta/action/assoc.h b/cp2/sta/action/assoc.h
new file mode 100644
index 0000000000..2e8a872133
--- /dev/null
+++ b/cp2/sta/action/assoc.h
@@ -0,0 +1,190 @@
+#ifndef cp_sta_action_assoc_h
+#define cp_sta_action_assoc_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/sta/action/assoc.h
+ * \brief STA action, association related definitions.
+ * \ingroup cp_sta
+ *
+ * Association/disassociation
+ * ==========================
+ *
+ * This part relates to association and disassociation for a STA. A state
+ * machine is used to handle the association status of the station:
+ *
+ * \image html assoc.png "Association state machine"
+ *
+ * - (1) send CC_ASSOC.REQ
+ * - (2) send CM_GET_KEY.REQ
+ * - (3) send CC_ASSOC.REQ for renewal
+ * - (4) send CM_SET_KEY.CNF
+ * - (5) send CC_LEAVE.REQ
+ * - (6) send CC_LEAVE.RSP
+ * - (7) cleanup data plane
+ *
+ * For the moment, only one association scheme is supported: association with
+ * matching NID, without proxy network.
+ *
+ * Related: 7.3.2, 7.3.3, 7.3.4.1, 7.3.5.1, 7.3.6.
+ *
+ *
+ * Association
+ * -----------
+ *
+ * When the station wants to associate, it set the association parameters and
+ * trigger the "to assoc" event. This will send the CC_ASSOC.REQ message to
+ * the CCo and wait for response.
+ *
+ * If no response is received, retry. Retry is needed because we are not
+ * associated and broadcast is used.
+ *
+ * If a negative response is received, association has failed, this is
+ * remembered in order not to try to associate too often to the same CCo.
+ *
+ * If a positive response is received, go to associated state.
+ *
+ *
+ * Authentication
+ * --------------
+ *
+ * When entering this state, send a payload encrypted CM_GET_KEY.REQ to
+ * request the NEK.
+ *
+ * Once the station is authenticated, CC_SET_TEI_MAP.IND messages can be
+ * received.
+ *
+ * As unicast transmissions are used, a timeout will directly break the
+ * association sequence.
+ *
+ * If a negative response is received, association has failed, the CCo is
+ * using a different NMK. This is remembered in order not to associate with
+ * this CCo again (until keys are changed).
+ *
+ * If a positive response is received, the station is authenticated.
+ *
+ * Once authenticated, the CCo can change the NEK periodically.
+ *
+ * Lease renewal
+ * -------------
+ *
+ * Association is granted for a given time. When the station is associated,
+ * program a timer to renew the association. When this timer expires, send a
+ * CC_ASSOC.REQ for renewal and set the timer for a second chance.
+ *
+ * The station will not leave the AVLN by itself due to lease expiration. It
+ * will wait an eventual CC_LEAVE.IND message to do so.
+ *
+ * When the CCo confirms the renewal, the renew timer is reset to the value
+ * given in its confirmation message. Ignore renewal failure, will wait for
+ * the CC_LEAVE.IND message.
+ *
+ *
+ * Leaving
+ * -------
+ *
+ * If the request comes from the sta, trigger the "leave" event. This will
+ * send the CC_LEAVE.REQ message to the CCo and wait for response. If no
+ * response cames for three beacon periods, resend and go to the "leave wait"
+ * state.
+ *
+ * If the request comes from the CCo (CC_LEAVE.IND), send a response and go to
+ * the "leave wait" state.
+ *
+ * The "leave wait" state is there to give time to the data plane to send the
+ * MME. After a fixed timer, go back to unassociated state and cleanup the
+ * data plane from all AVLN related parameters.
+ */
+
+BEGIN_DECLS
+
+/**
+ * Start a association procedure.
+ * \param ctx control plane context
+ * \param cco CCo to associate with
+ *
+ * Send a CC_ASSOC.REQ to the CCo and trigger TO_ASSOC event.
+ *
+ * Need:
+ * - CCo to associate to (MAC, TEI, NID).
+ * - our CCo cap and proxy network cap.
+ */
+void
+cp_sta_action_assoc_start (cp_t *ctx, cp_sta_t *cco);
+
+/**
+ * Process a CC_ASSOC.CNF, 11.2.29.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ * \param result association result
+ * \param nid NID of the sender network
+ * \param snid SNID of the sender network
+ * \param tei new TEI to use, valid if association is successful
+ * \param lease_time_min period of time of TEI validity
+ *
+ * Confirmation from the CCo on association request. If this does not
+ * correspond to a previously sent request, drop.
+ *
+ * If we were associating and if the CCo accepted our association, update
+ * association information, send the CC_GET_KEY.REQ, and post a TO_SUCCESS
+ * event. If the CCo refused, post a TO_FAILURE and update the CCo
+ * information to remember the failure.
+ *
+ * If we were renewing, just update the lease time.
+ *
+ * Need:
+ * - whether a association is pending and its characteristics.
+ *
+ * Update:
+ * - our TEI.
+ * - our TEI lease time (update lease timer).
+ * - our AVLN.
+ * - our AVLN SNID.
+ * - CCo failure info.
+ */
+void
+cp_sta_action_process_cc_assoc_cnf (cp_t *ctx, cp_mme_t *mme,
+ cp_msg_cc_assoc_cnf_result_t result,
+ cp_nid_t nid, cp_snid_t snid,
+ cp_tei_t tei, uint lease_time_min);
+
+/**
+ * Process a CC_LEAVE.CNF, 11.2.31.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ *
+ * Confirmation from the CCo on leave request. If this does not correspond to
+ * a previously sent request, drop. Else, post an event to leave the AVLN.
+ *
+ * Need:
+ * - whether a leave is pending and its characteristics.
+ */
+void
+cp_sta_action_process_cc_leave_cnf (cp_t *ctx, cp_mme_t *mme);
+
+/**
+ * Process a CC_LEAVE.IND, 11.2.32.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ * \param reason reason for the disassociation
+ * \param nid NID
+ *
+ * The CCo ask us to leave the AVLN. Send a CC_LEAVE.RSP, and post an event
+ * to leave the AVLN.
+ *
+ * Need:
+ * - our AVLN NID (to check message).
+ */
+void
+cp_sta_action_process_cc_leave_ind (cp_t *ctx, cp_mme_t *mme,
+ cp_msg_cc_leave_ind_reason_t reason,
+ nid_t nid);
+
+END_DECLS
+
+#endif /* cp_sta_action_assoc_h */
diff --git a/cp2/sta/action/doc/Makefile b/cp2/sta/action/doc/Makefile
new file mode 100644
index 0000000000..44acd4bd16
--- /dev/null
+++ b/cp2/sta/action/doc/Makefile
@@ -0,0 +1,47 @@
+PAGES = assoc key misc
+GRAPHS = assoc
+
+DOTFLAGS = -Gbgcolor='\#f7f7f7' -Nfillcolor=white
+CONVERTFLAGS = -border 1 -bordercolor '\#d7d7d7'
+
+TOOLS_DIR = ../../../../common/tools
+DOC_DIR = ../../../../common/doc
+SDL2DOT = $(TOOLS_DIR)/sdl2dot
+SDLPS = $(TOOLS_DIR)/sdl.ps
+EXTRACT_DOC = $(DOC_DIR)/extractdoc
+DOX2RST = $(DOC_DIR)/dox2rst
+
+all: png rst
+
+png: $(GRAPHS:%=%.png)
+ps: $(GRAPHS:%=%.ps)
+
+%.png: %.ps
+ convert $(CONVERTFLAGS) $< $@
+
+%.ps: %.dot Makefile
+ dot $(DOTFLAGS) -Tps -l $(SDLPS) -o $@ $<
+
+%.dot: %.sdl
+ $(SDL2DOT) $< > $@
+
+rst: top.rst
+html: png top.html
+odt: top.odt
+
+top.rst: $(PAGES:%=%.rst)
+ cat $^ > $@
+
+%.rst: ../%.h
+ $(EXTRACT_DOC) $< | $(DOX2RST) > $@
+
+%.html: %.rst
+ rst2html $< $@
+
+%.odt: %.rst
+ rst2odt.py $< $@
+
+clean:
+ rm -f $(GRAPHS:%=%.ps) $(GRAPHS:%=%.png)
+ rm -f $(PAGES:%=%.rst) $(PAGES:%=%.html)
+ rm -f top.rst top.html top.odt
diff --git a/cp2/sta/action/doc/assoc.sdl b/cp2/sta/action/doc/assoc.sdl
new file mode 100644
index 0000000000..62da4a08c3
--- /dev/null
+++ b/cp2/sta/action/doc/assoc.sdl
@@ -0,0 +1,21 @@
+(unassociated) -to assoc(1)-> (wait assoc cnf)
+
+(wait assoc cnf) -CC_ASSOC.CNF-> <w:ok?> -y(2)-> (associated)
+ <w:ok?> -n-> (unassociated)
+(wait assoc cnf) -timeout-> <retry?> -y(1)-> (wait assoc cnf)
+ <retry?> -n-> (unassociated)
+
+(associated) -CM_GET_KEY.CNF-> <a:ok?> -y-> (authenticated)
+ <a:ok?> -n-> (unassociated)
+(associated) -timeout-> (unassociated)
+
+(authenticated) -renew(3)-> (authenticated)
+(authenticated) -CC_ASSOC.CNF-> (authenticated)
+(authenticated) -CM_SET_KEY.REQ(4)-> (authenticated)
+(authenticated) -leave(5)-> (leaving)
+(authenticated) -CC_LEAVE.IND(6)-> (leave wait)
+
+(leaving) -CC_LEAVE.CNF(7)-> (unassociated)
+(leaving) -timeout(5) (3pb)-> (leave wait)
+
+(leave wait) -timeout(7)-> (unassociated)
diff --git a/cp2/sta/action/doc/cp_sta_action.odt b/cp2/sta/action/doc/cp_sta_action.odt
new file mode 100644
index 0000000000..68dc798f8b
--- /dev/null
+++ b/cp2/sta/action/doc/cp_sta_action.odt
Binary files differ
diff --git a/cp2/sta/action/key.h b/cp2/sta/action/key.h
new file mode 100644
index 0000000000..d55fc824b5
--- /dev/null
+++ b/cp2/sta/action/key.h
@@ -0,0 +1,165 @@
+#ifndef cp_sta_action_key_h
+#define cp_sta_action_key_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/sta/action/key.h
+ * \brief STA action, key exchange messages.
+ * \ingroup cp_sta
+ *
+ * Key exchanges
+ * =============
+ *
+ * This part handle key exchange messages. As theses messages are used for
+ * many unrelated protocol, theses functions will only handle generic
+ * verifications and will then forward the message to the right recipient.
+ */
+
+BEGIN_DECLS
+
+/**
+ * Process a CM_SET_KEY.REQ, 11.5.4.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ * \param key_type key type being set
+ * \param my_nounce to be used in next message
+ * \param your_nounce used in previous message
+ * \param pid protocol identifier
+ * \param prn protocol run number
+ * \param pmn protocol message number
+ * \param cco_cap CCo capabilities of the sending STA
+ * \param nid NID of the sender network, associated with the NMK
+ * \param new_eks EKS of the key being set
+ * \param new_key new key, or NULL if none.
+ *
+ * This message is used in several protocols. First check that this message
+ * is legitimate, then depending of the protocol, call the corresponding
+ * function.
+ *
+ * Used to:
+ * - from STA to STA:
+ * - NMK provisioning using DAK (PID=2):
+ * - set TEK, DAK encrypted (not handled): used to start the protocol
+ * - set NMK, DAK encrypted (not handled)
+ * - NMK provisioning using UKE (PID=3):
+ * - set NMK, TEK encrypted (not handled)
+ * - from CCo to STA:
+ * - set NEK (PID=1), done periodically by the CCo
+ * - from HLE to STA:
+ * - set NMK (not handled)
+ */
+void
+cp_sta_action_process_cm_set_key_req (cp_t *ctx, cp_mme_t *mme,
+ cp_key_type_t key_type,
+ u32 my_nounce, u32 your_nounce,
+ cp_pid_t pid,
+ u16 prn, u8 pmn,
+ cp_cco_cap_t cco_cap,
+ cp_nid_t nid,
+ u8 new_eks,
+ cp_key_t *new_key);
+
+/**
+ * Process a CM_SET_KEY.CNF, 11.5.5.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ * \param result transaction result
+ * \param my_nounce to be used in next message
+ * \param your_nounce used in previous message
+ * \param pid protocol identifier
+ * \param prn protocol run number
+ * \param pmn protocol message number
+ * \param cco_cap CCo capabilities of the sending STA
+ *
+ * Response from a preceding CM_SET_KEY.REQ. First check that this message is
+ * legitimate and that it correspond to a sent request, then call the
+ * corresponding function.
+ *
+ * This message can be forwarded to the CCo module.
+ */
+void
+cp_sta_action_process_cm_set_key_cnf (cp_t *ctx, cp_mme_t *mme,
+ cp_msg_cm_set_key_cnf_result_t result,
+ u32 my_nounce, u32 your_nounce,
+ cp_pid_t pid,
+ u16 prn, u8 pmn,
+ cp_cco_cap_t cco_cap);
+
+/**
+ * Process a CM_GET_KEY.REQ, 11.5.6.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ * \param req_type request type (relayed or not)
+ * \param key_type requested key type
+ * \param nid NID of the network of the sender, or the sender want to join
+ * \param my_nounce to be used in next message
+ * \param pid protocol identifier
+ * \param prn protocol run number
+ * \param pmn protocol message number
+ * \param hash HASH key, used to generate a TEK, or NULL if not present
+ *
+ * This message is used in several protocols. First check that this message
+ * is legitimate, then depending of the protocol, call the corresponding
+ * function.
+ *
+ * This message can be forwarded to the CCo module.
+ *
+ * Used to:
+ * - from STA to STA:
+ * - NMK provisioning using UKE (PID=3):
+ * - get HASH KEY, unencrypted unicast (not handled): used to derive the
+ * TEK
+ * - from STA to CCo:
+ * - get NEK, NMK encrypted (PID=0)
+ * - from HLE to STA:
+ * - get NMK (not handled)
+ */
+void
+cp_sta_action_process_cm_get_key_req (cp_t *ctx, cp_mme_t *mme,
+ cp_msg_cm_get_key_req_type_t req_type,
+ cp_key_type_t key_type,
+ cp_nid_t nid,
+ u32 my_nounce,
+ cp_pid_t pid,
+ u16 prn, u8 pmn,
+ u8 *hash);
+
+/**
+ * Process a CM_GET_KEY.CNF, 11.5.7.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ * \param result transaction result
+ * \param key_type requested key type
+ * \param my_nounce to be used in next message
+ * \param your_nounce used in previous message
+ * \param nid NID of the sender network
+ * \param eks EKS of the received key
+ * \param pid protocol identifier
+ * \param prn protocol run number
+ * \param pmn protocol message number
+ * \param hash HASH key, used to generate a TEK, or NULL if not present
+ * \param key received key, or NULL if not present
+ *
+ * Response from a preceding CM_GET_KEY.REQ. First check that this message is
+ * legitimate and that it correspond to a sent request, then call the
+ * corresponding function.
+ */
+void
+cp_sta_action_process_cm_get_key_cnf (cp_t *ctx, cp_mme_t *mme,
+ cp_msg_cm_get_key_cnd_result_t result,
+ cp_key_type_t key_type,
+ u32 my_nounce, u32 your_nounce,
+ cp_nid_t nid,
+ u8 eks,
+ cp_pid_t pid,
+ u16 prn, u8 pmn,
+ u8 *hash, cp_key_t *key);
+
+END_DECLS
+
+#endif /* cp_sta_action_key_h */
diff --git a/cp2/sta/action/misc.h b/cp2/sta/action/misc.h
new file mode 100644
index 0000000000..8a9b717578
--- /dev/null
+++ b/cp2/sta/action/misc.h
@@ -0,0 +1,117 @@
+#ifndef misc_h
+#define misc_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file misc.h
+ * \brief STA action, miscellaneous definitions.
+ * \ingroup cp_sta
+ *
+ * Miscellaneous
+ * =============
+ *
+ * This part handle other miscellaneous STA function, most of theses are
+ * simple enough to be handled without any remembered state.
+ */
+
+BEGIN_DECLS
+
+/**
+ * Process a CC_WHO_RU.REQ, 11.2.26.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ * \param nid NID of network being queried
+ *
+ * Provide AVLN identity and CCo MAC address. If the NID correspond to our
+ * NID, send a CC_WHO_RU.CNF. In other cases, drop.
+ *
+ * Need:
+ * - our CCo MAC address.
+ * - our AVLN HFID.
+ */
+void
+cp_sta_action_process_cc_who_ru_req (cp_t *ctx, cp_mme_t *mme, cp_nid_t nid);
+
+/**
+ * Process a CC_SET_TEI_MAP.IND, 11.2.35.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ * \param mode update, add or remove
+ *
+ * The CCo send an update of the AVLN list of STA. According to the mode,
+ * update the whole list, add or remove a STA.
+ *
+ * Need:
+ * - use a cp_msg function to read the rest of the message.
+ *
+ * Update:
+ * - STA mgr.
+ */
+void
+cp_sta_action_process_cc_set_tei_map_ind_update (
+ cp_t *ctx, cp_mme_t *mme, cp_msg_cc_set_tei_map_ind_mode_t mode);
+
+/**
+ * Process a CC_RELAY.REQ, 11.2.36.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ * \param fda final destination address
+ * \param ftei final destination TEI
+ * \param len payload size
+ *
+ * Extract the payload from the MME, and encapsulate it in a CC_RELAY.IND to
+ * the final destination.
+ *
+ * There is special behaviour depending on the contained payload. If the
+ * relay request is not encrypted, only relay MME which are permitted to be
+ * unencrypted. If the relay request is not encrypted and contains a
+ * CM_ENCRYPTED_PAYLOAD.IND, the CC_RELAY.IND should be sent broadcast. This
+ * could be done by the cp_msg module.
+ *
+ * - What to do with the MAC address?
+ */
+void
+cp_sta_action_process_cc_relay_req (cp_t *ctx, cp_mme_t *mme, mac_t fda,
+ cp_tei_t ftei, uint len);
+
+/**
+ * Process a CC_RELAY.IND, 11.2.37.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ * \param osa original source address
+ * \param otei original source TEI
+ * \param len payload size
+ *
+ * Extract the payload and insert the message back.
+ *
+ * Relay station is trusted as long as it is authenticated. It should have
+ * filtered unauthorised payload.
+ */
+void
+cp_sta_action_process_cc_relay_ind (cp_t *ctx, cp_mme_t *mme, mac_t osa,
+ cp_tei_t otei, uint len);
+
+/**
+ * Process a CM_MME_ERROR.IND, 11.5.32.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ * \param reason reason of the error
+ * \param rx_mmv MMV of the erroneous MME
+ * \param rx_mmtype MMTYPE of the erroneous MME
+ * \param invalid_byte_offset offset in the MME of the error
+ *
+ * Used for debug. Trace the error.
+ */
+void
+cp_sta_action_process_cm_mme_error_ind (
+ cp_t *ctx, cp_mme_t *mme, cp_msg_cm_mme_error_ind_reason_t reason,
+ u8 rx_mmv, u16 rx_mmtype, u16 invalid_byte_offset);
+
+END_DECLS
+
+#endif /* misc_h */