summaryrefslogtreecommitdiff
path: root/cesar/cp2/msg
diff options
context:
space:
mode:
authorlaranjeiro2008-08-26 15:55:56 +0000
committerlaranjeiro2008-08-26 15:55:56 +0000
commit569cce541edc49d75dccc3d7afa6cd24111f07a5 (patch)
tree00fae8ab8b6f32c48785dc82e12b9030733aa795 /cesar/cp2/msg
parentfad218bd5e8449fcdc7b2afec364066b4a2b9b9a (diff)
cp2/msg: Added the function to get the PID from CM_GET_KEY_CNF and CM_SET_KEY.
* The PID in the set key is at the same offset in the req and cnf. * Tested it in the unit test. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2762 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp2/msg')
-rw-r--r--cesar/cp2/msg/inc/msg_cm.h19
-rw-r--r--cesar/cp2/msg/src/msg_cm.c58
-rw-r--r--cesar/cp2/msg/test/src/msg_cm.c210
3 files changed, 285 insertions, 2 deletions
diff --git a/cesar/cp2/msg/inc/msg_cm.h b/cesar/cp2/msg/inc/msg_cm.h
index 017f436949..7e76eac688 100644
--- a/cesar/cp2/msg/inc/msg_cm.h
+++ b/cesar/cp2/msg/inc/msg_cm.h
@@ -43,6 +43,15 @@ cp_msg_cm_unassociated_sta_ind_receive (cp_t *ctx, cp_mme_rx_t *mme,
cp_nid_t *nid, u8 *cco_cap);
/**
+ * Get the PID of the CM_SET_KEY.CNF.
+ * \param ctx the Control plane context.
+ * \param mme the MME handle.
+ * \return pid the pid of the MME.
+ */
+uint
+cp_msg_cm_set_key_get_pid (cp_t *ctx, cp_mme_rx_t *mme);
+
+/**
* Send a CM_SET_KEY.REQ.
* \param ctx control plane context
* \param peer peer information
@@ -70,6 +79,16 @@ cp_msg_cm_set_key_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
cp_msg_cm_set_key_req_t *data);
/**
+ * Get the PID of the CM_GET_KEY.CNF.
+ * \param ctx the Control plane context.
+ * \param mme the MME handle.
+ * \return pid the pid of the MME.
+ */
+uint
+cp_msg_cm_get_key_cnf_get_pid (cp_t *ctx, cp_mme_rx_t *mme);
+
+
+/**
* Send a CM_SET_KEY.CNF.
* \param ctx control plane context
* \param peer peer information
diff --git a/cesar/cp2/msg/src/msg_cm.c b/cesar/cp2/msg/src/msg_cm.c
index 6d60fed3fc..d446a152a0 100644
--- a/cesar/cp2/msg/src/msg_cm.c
+++ b/cesar/cp2/msg/src/msg_cm.c
@@ -78,6 +78,33 @@ cp_msg_cm_set_key_req_access (bitstream_t *stream,
}
/**
+ * Get the PID of the CM_SET_KEY.CNF.
+ * \param ctx the Control plane context.
+ * \param mme the MME handle.
+ * \return pid the pid of the MME.
+ */
+uint
+cp_msg_cm_set_key_get_pid (cp_t *ctx, cp_mme_rx_t *mme)
+{
+ uint offset;
+ uint pid;
+
+ dbg_assert (ctx);
+ dbg_assert (mme);
+ dbg_assert (mme->peks == CP_MME_PEKS_SPC_NOT_EMBEDDED);
+
+
+ if (mme->peer.vlan_tag)
+ offset = HPAV_MME_HEADER_LEN_WITH_VLAN;
+ else
+ offset = HPAV_MME_HEADER;
+
+ pid = read_u8_from_word (mme->p_mme + offset + 9);
+
+ return pid;
+}
+
+/**
* Send a CM_SET_KEY.REQ.
* \param ctx control plane context
* \param peer peer information
@@ -238,7 +265,7 @@ cp_msg_cm_set_key_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme,
* \param mme the MME handle.
* \return pid the pid of the MME.
*/
-cp_mme_peks_t
+uint
cp_msg_cm_get_key_req_get_pid (cp_t *ctx, cp_mme_rx_t *mme)
{
uint offset;
@@ -256,7 +283,6 @@ cp_msg_cm_get_key_req_get_pid (cp_t *ctx, cp_mme_rx_t *mme)
pid = read_u8_from_word (mme->p_mme + offset + 13);
- dbg_assert (pid < 0x5);
return pid;
}
@@ -399,6 +425,34 @@ cp_msg_cm_get_key_cnf_access (bitstream_t *stream,
}
/**
+ * Get the PID of the CM_GET_KEY.CNF.
+ * \param ctx the Control plane context.
+ * \param mme the MME handle.
+ * \return pid the pid of the MME.
+ */
+uint
+cp_msg_cm_get_key_cnf_get_pid (cp_t *ctx, cp_mme_rx_t *mme)
+{
+ uint offset;
+ uint pid;
+
+ dbg_assert (ctx);
+ dbg_assert (mme);
+ dbg_assert (mme->peks == CP_MME_PEKS_SPC_NOT_EMBEDDED);
+
+
+ if (mme->peer.vlan_tag)
+ offset = HPAV_MME_HEADER_LEN_WITH_VLAN;
+ else
+ offset = HPAV_MME_HEADER;
+
+ pid = read_u8_from_word (mme->p_mme + offset + 18);
+
+ return pid;
+}
+
+
+/**
* Send a CM_GET_KEY.CNF.
* \param ctx control plane context
* \param peer peer information
diff --git a/cesar/cp2/msg/test/src/msg_cm.c b/cesar/cp2/msg/test/src/msg_cm.c
index 42fc9eb992..221c54b929 100644
--- a/cesar/cp2/msg/test/src/msg_cm.c
+++ b/cesar/cp2/msg/test/src/msg_cm.c
@@ -367,6 +367,214 @@ test_case_cm_get_key_get_pid (void)
}
+void
+test_case_cm_get_key_cnf_get_pid (void)
+{
+ bitstream_t bitstream;
+ cp_mme_rx_t mme_rx;
+ u8 buffer[1024];
+ u64 data;
+
+ bitstream_init (&bitstream, buffer, 60, BITSTREAM_WRITE);
+ /* ODA. */
+ data = 0x123456789ABCull;
+ bitstream_access (&bitstream, &data, 48);
+ /* OSA. */
+ data = 0x23456789ABCDull;
+ bitstream_access (&bitstream, &data, 48);
+ /* Mtype. */
+ data = swap16(HPAV_MTYPE_MME);
+ bitstream_access (&bitstream, &data, 16);
+ /* MMV. */
+ data = HPAV_MMV;
+ bitstream_access (&bitstream, &data, 8);
+ /* MMTYPE. */
+ data = CM_GET_KEY_CNF;
+ bitstream_access (&bitstream, &data, 16);
+ /* FMI. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 16);
+ /* Result. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 8);
+ /* Requested key type. */
+ data = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
+ bitstream_access (&bitstream, &data, 8);
+ /* my nonce. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 32);
+ /* your nonce. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 32);
+ /* NID. */
+ data = 0x123456789ABCDEFull;
+ bitstream_access (&bitstream, &data, 56);
+ /* EKS. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 8);
+ /* PID. */
+ data = 0x2;
+ bitstream_access (&bitstream, &data, 8);
+ bitstream_finalise (&bitstream);
+
+ mme_rx.p_mme = buffer;
+ mme_rx.peks = CP_MME_PEKS_SPC_NOT_EMBEDDED;
+
+ test_case_begin (test, "Get PID");
+
+ test_begin (test, "PID = 0x2")
+ {
+ test_fail_if (cp_msg_cm_get_key_cnf_get_pid (&cp, &mme_rx) != 0x2);
+ }
+ test_end;
+
+ bitstream_init (&bitstream, buffer, 60, BITSTREAM_WRITE);
+ /* ODA. */
+ data = 0x123456789ABCull;
+ bitstream_access (&bitstream, &data, 48);
+ /* OSA. */
+ data = 0x23456789ABCDull;
+ bitstream_access (&bitstream, &data, 48);
+ /* Mtype. */
+ data = swap16(HPAV_MTYPE_MME);
+ bitstream_access (&bitstream, &data, 16);
+ /* MMV. */
+ data = HPAV_MMV;
+ bitstream_access (&bitstream, &data, 8);
+ /* MMTYPE. */
+ data = CM_GET_KEY_CNF;
+ bitstream_access (&bitstream, &data, 16);
+ /* FMI. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 16);
+ /* Result. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 8);
+ /* Requested key type. */
+ data = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
+ bitstream_access (&bitstream, &data, 8);
+ /* my nonce. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 32);
+ /* your nonce. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 32);
+ /* NID. */
+ data = 0x123456789ABCDEFull;
+ bitstream_access (&bitstream, &data, 56);
+ /* EKS. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 8);
+ /* PID. */
+ data = 0x3;
+ bitstream_access (&bitstream, &data, 8);
+ bitstream_finalise (&bitstream);
+
+ mme_rx.p_mme = buffer;
+ mme_rx.peks = CP_MME_PEKS_SPC_NOT_EMBEDDED;
+
+ test_begin (test, "PID = 0x3")
+ {
+ test_fail_if (cp_msg_cm_get_key_cnf_get_pid (&cp, &mme_rx) != 0x3);
+ }
+ test_end;
+}
+
+void
+test_case_cm_set_key_get_pid (void)
+{
+ bitstream_t bitstream;
+ cp_mme_rx_t mme_rx;
+ u8 buffer[1024];
+ u64 data;
+
+ bitstream_init (&bitstream, buffer, 60, BITSTREAM_WRITE);
+ /* ODA. */
+ data = 0x123456789ABCull;
+ bitstream_access (&bitstream, &data, 48);
+ /* OSA. */
+ data = 0x23456789ABCDull;
+ bitstream_access (&bitstream, &data, 48);
+ /* Mtype. */
+ data = swap16(HPAV_MTYPE_MME);
+ bitstream_access (&bitstream, &data, 16);
+ /* MMV. */
+ data = HPAV_MMV;
+ bitstream_access (&bitstream, &data, 8);
+ /* MMTYPE. */
+ data = CM_GET_KEY_CNF;
+ bitstream_access (&bitstream, &data, 16);
+ /* FMI. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 16);
+ /* Result. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 8);
+ /* my nonce. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 32);
+ /* your nonce. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 32);
+ /* PID. */
+ data = 0x2;
+ bitstream_access (&bitstream, &data, 8);
+ bitstream_finalise (&bitstream);
+
+ mme_rx.p_mme = buffer;
+ mme_rx.peks = CP_MME_PEKS_SPC_NOT_EMBEDDED;
+
+ test_case_begin (test, "Get PID");
+
+ test_begin (test, "PID = 0x2")
+ {
+ test_fail_if (cp_msg_cm_set_key_get_pid (&cp, &mme_rx) != 0x2);
+ }
+ test_end;
+
+ bitstream_init (&bitstream, buffer, 60, BITSTREAM_WRITE);
+ /* ODA. */
+ data = 0x123456789ABCull;
+ bitstream_access (&bitstream, &data, 48);
+ /* OSA. */
+ data = 0x23456789ABCDull;
+ bitstream_access (&bitstream, &data, 48);
+ /* Mtype. */
+ data = swap16(HPAV_MTYPE_MME);
+ bitstream_access (&bitstream, &data, 16);
+ /* MMV. */
+ data = HPAV_MMV;
+ bitstream_access (&bitstream, &data, 8);
+ /* MMTYPE. */
+ data = CM_GET_KEY_CNF;
+ bitstream_access (&bitstream, &data, 16);
+ /* FMI. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 16);
+ /* Result. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 8);
+ /* my nonce. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 32);
+ /* your nonce. */
+ data = 0x0;
+ bitstream_access (&bitstream, &data, 32);
+ /* PID. */
+ data = 0x3;
+ bitstream_access (&bitstream, &data, 8);
+ bitstream_finalise (&bitstream);
+
+ mme_rx.p_mme = buffer;
+ mme_rx.peks = CP_MME_PEKS_SPC_NOT_EMBEDDED;
+
+ test_begin (test, "PID = 0x3")
+ {
+ test_fail_if (cp_msg_cm_set_key_get_pid (&cp, &mme_rx) != 0x3);
+ }
+ test_end;
+}
+
int
main (void)
{
@@ -386,6 +594,8 @@ main (void)
test_case_cm_set_key ();
test_case_cm_get_key ();
test_case_cm_get_key_get_pid ();
+ test_case_cm_get_key_cnf_get_pid ();
+ test_case_cm_set_key_get_pid ();
test_case_begin (test, "Memory allocation");
test_begin (test, "memory leaks")