summaryrefslogtreecommitdiff
path: root/cesar/cp/msg/src/field/msg_field_cid.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/cp/msg/src/field/msg_field_cid.c')
-rw-r--r--cesar/cp/msg/src/field/msg_field_cid.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/cesar/cp/msg/src/field/msg_field_cid.c b/cesar/cp/msg/src/field/msg_field_cid.c
new file mode 100644
index 0000000000..b893e1314c
--- /dev/null
+++ b/cesar/cp/msg/src/field/msg_field_cid.c
@@ -0,0 +1,70 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}}
+ * \file conn_msg_cid.c
+ * \brief This file provides management functions for CID (Connection Identifier) field.
+ * \ingroup cp/msg
+ *
+ */
+
+#include "common/std.h"
+#include "lib/swap.h"
+#include "cp/msg/inc/msg_cm_conn.h"
+
+
+/**
+ * Initialize a CID (Connection Identifier) structure.
+ * \param cid Pointer of the data to be initialized
+ *
+ */
+void
+msg_field_cid_init(cid_t* cid)
+{
+ *cid = 1;
+}
+
+
+
+/**
+ * Read the CID (Connection Identifier) from the stream and put the CID value
+ * on the cid pointer. The function returns the CID length.
+ *
+ * \param stream Data source contening the cid value.
+ * \param cid Pointer of the data to be modified.
+ * \return length of the CID field.
+ *
+ */
+len_t
+msg_field_cid_get_from_stream (u8* stream, cid_t * cid)
+{
+
+ dbg_assert_ptr (stream);
+ dbg_assert_ptr (cid);
+
+
+ *cid = ntohs(*(u16*)stream);
+
+ dbg_assert (*cid != 0);
+
+ return 2;
+}
+
+
+/**
+* Write the CID value on the stream. The function returns the data length written.
+*
+* param stream Data destination of the CID value.
+* param cid Pointer of the data to be written.
+* return Length of the data.
+*
+*/
+len_t
+msg_field_cid_set_on_stream(u8 * stream, cid_t* cid)
+{
+ *(u16*)stream = htons(*cid);
+ return 2;
+}