summaryrefslogtreecommitdiff
path: root/cleopatre/application/managerd/src
diff options
context:
space:
mode:
authorlefranc2010-01-07 16:11:07 +0000
committerlefranc2010-01-07 16:11:07 +0000
commit3d1cc3cc9a756e54c427260b61e4999dd81b3772 (patch)
treeceab55f16bb385bf71f6e9dda1186281771c870f /cleopatre/application/managerd/src
parenta738187b11c0c014700db4d6fdc53916b307b6a0 (diff)
cleo/appli/managerd: add VS_GET_VERSION processing
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6596 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cleopatre/application/managerd/src')
-rw-r--r--cleopatre/application/managerd/src/bridge.c14
-rw-r--r--cleopatre/application/managerd/src/vs_mme.c100
2 files changed, 113 insertions, 1 deletions
diff --git a/cleopatre/application/managerd/src/bridge.c b/cleopatre/application/managerd/src/bridge.c
index be6626f190..0bea560395 100644
--- a/cleopatre/application/managerd/src/bridge.c
+++ b/cleopatre/application/managerd/src/bridge.c
@@ -50,6 +50,8 @@
enum bridge_status bridge_processing(struct managerd_ctx *ctx, uint8_t *buffer, int *len, int max_len)
{
MME_t *mmehdr;
+ uint8_t confirm_buffer[MAX_PKT_LEN];
+ MME_t *confirm;
//Check arguments
assert(ctx != NULL);
@@ -57,7 +59,17 @@ enum bridge_status bridge_processing(struct managerd_ctx *ctx, uint8_t *buffer,
assert(len != NULL);
assert((*len > 0) && (*len <= max_len));
- mmehdr = (MME_t *)buffer;
+ mmehdr = (MME_t *) buffer;
+ confirm = (MME_t *) confirm_buffer;
+
+ /* check if this MME needs to be internally processed */
+ switch(mmehdr->mmtype)
+ {
+ case MME_TYPE_VS_GET_VERSION | MME_TYPE_REQ:
+ return vs_mme_get_version (ctx, mmehdr, confirm, MAX_PKT_LEN);
+ default:
+ break;
+ }
/* is MME is for our PLC interface ? */
if(!memcmp (mmehdr->mme_dest, ctx->plc_mac_addr, ETH_ALEN))
diff --git a/cleopatre/application/managerd/src/vs_mme.c b/cleopatre/application/managerd/src/vs_mme.c
new file mode 100644
index 0000000000..7a4a4886c0
--- /dev/null
+++ b/cleopatre/application/managerd/src/vs_mme.c
@@ -0,0 +1,100 @@
+/*
+ * cleopatre/application/managerd/src/vs_mme.c
+ *
+ * (C) Copyright 2009 SPiDCOM Technologies
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "bridge.h"
+#include "vs_mme.h"
+
+#define FIRMWARE_LABEL "irmware"
+
+/**
+ * Send a VS_GET_VERSION MME to BR interface.
+ *
+ * \param ctx managerd context.
+ * \param request MME containg VS_GET_VERSION request.
+ * \param confirm MME buffer to put VS_GET_VERSION confirm.
+ * \param len confirm buffer length.
+ * \return error code.
+ */
+enum bridge_status vs_mme_get_version (struct managerd_ctx *ctx, MME_t *request, MME_t *confirm, int len)
+{
+ vs_get_version_t *get_version;
+ spidcom_image_desc_t desc;
+ char mtd_name[32];
+ FILE *fp;
+ char tmp_buffer[256];
+ char label[64], version[64];
+
+ assert (NULL != ctx);
+ assert (NULL != request);
+ assert (NULL != confirm);
+ assert (len >= sizeof(vs_get_version_t) + sizeof(MME_t));
+
+ /* prepare ethernet header */
+ memset (confirm, '\0', len);
+ memcpy (confirm->mme_dest, request->mme_src, ETH_ALEN);
+ memcpy (confirm->mme_src, ctx->br_mac_addr, ETH_ALEN);
+ confirm->mtype = request->mtype;
+ confirm->mmv = request->mmv;
+ confirm->mmtype = MME_TYPE_VS_GET_VERSION | MME_TYPE_CNF;
+ confirm->fmi = 0;
+
+ /* set get_version inside confirm buffer */
+ get_version = (vs_get_version_t *)((unsigned char*)confirm + sizeof(MME_t));
+ /* fill get_version */
+ memcpy (get_version->oui, OUI_SPIDCOM, 3);
+ get_version->result = 0;
+ get_version->device_id = SPC300_ID;
+ // TODO: find the right index value
+ get_version->current_image_index = 0;
+
+ /* get image description */
+ memset (&desc, '\0', sizeof(desc));
+ if(LIBSPID_SUCCESS == libspid_image_get_desc (LIBSPID_IMAGE_DESC_TYPE_CURRENT, &desc, mtd_name))
+ {
+ memcpy (get_version->applicative_version, desc.version, sizeof(desc.version));
+ }
+
+ if((fp = fopen (PLC_VERSION_PATH, "r")) != NULL)
+ {
+ while(fgets (tmp_buffer, 256, fp))
+ {
+ memset (version, '\0', sizeof(version));
+ if(sscanf (tmp_buffer, "%[^:] %*s %s", label, version) == 2)
+ {
+ if(strstr (label, FIRMWARE_LABEL))
+ {
+ strncpy ((char *)get_version->av_stack_version, version, sizeof(get_version->av_stack_version));
+ break;
+ }
+ }
+ }
+ fclose (fp);
+ }
+
+ // TODO: fill alternate image info with firmware !!!
+
+ /* send confirm MME */
+ bridge_send_to_br (ctx, (uint8_t *)confirm, sizeof(MME_t) + sizeof(vs_get_version_t));
+ return TO_DROP;
+}