summaryrefslogtreecommitdiff
path: root/cleopatre/devkit/plcd
diff options
context:
space:
mode:
authorThierry Carré2013-03-08 18:13:15 +0100
committerThierry Carré2013-03-19 15:02:34 +0100
commit29de707c6a58886b087a80b89a3238e31c52510c (patch)
tree1c12d1d32b54ef6894cc5420370153c9f2122cba /cleopatre/devkit/plcd
parentcdfb613785192ffb090abf24d3a8b3115cb036c4 (diff)
cleo/devkit/plcd: declare prototypes of plcd_stack
Diffstat (limited to 'cleopatre/devkit/plcd')
-rw-r--r--cleopatre/devkit/plcd/inc/plcd.h12
-rw-r--r--cleopatre/devkit/plcd/inc/plcd_stack.h176
-rw-r--r--cleopatre/devkit/plcd/src/plcd_main.c5
-rw-r--r--cleopatre/devkit/plcd/src/plcd_multicast.c1
-rw-r--r--cleopatre/devkit/plcd/src/plcd_process.c1
-rw-r--r--cleopatre/devkit/plcd/src/plcd_stack.c138
6 files changed, 186 insertions, 147 deletions
diff --git a/cleopatre/devkit/plcd/inc/plcd.h b/cleopatre/devkit/plcd/inc/plcd.h
index cd4738d30b..2b4224f54a 100644
--- a/cleopatre/devkit/plcd/inc/plcd.h
+++ b/cleopatre/devkit/plcd/inc/plcd.h
@@ -15,15 +15,20 @@
#ifndef PLCD_H
#define PLCD_H
+/* FIXME: This include <net/ethernet.h> cannot be moved,
+ * there is a compilation error with lib*.h . */
#include <net/ethernet.h>
+
+#include "libmme.h"
+#include "libspid.h"
+#include "mmtypes.h"
+
#include <sys/types.h>
#include <sys/socket.h>
#include <stdint.h>
#include <time.h>
#include <linux/netlink.h>
-#include "mmtypes.h"
-
#define PLCD_ASSERT(condition) \
{ \
if (!(condition)) \
@@ -149,9 +154,6 @@ extern int autoswitch_timer_alive;
void plcd_autoswitch_timer_init (void);
void plcd_autoswitch_image_update (void);
-int plcd_send_recv_drv_mme (const plcd_ctx_t *ctx, const mme_ctx_t *request_ctx,
- mme_ctx_t *confirm_ctx, mme_ctx_t *indication_ctx);
-
/**
* Tell whether the multicast info file was updated since last check.
* \param ctx The context;
diff --git a/cleopatre/devkit/plcd/inc/plcd_stack.h b/cleopatre/devkit/plcd/inc/plcd_stack.h
index cbd472742f..9d844610bd 100644
--- a/cleopatre/devkit/plcd/inc/plcd_stack.h
+++ b/cleopatre/devkit/plcd/inc/plcd_stack.h
@@ -11,5 +11,181 @@
* \file devkit/plcd/inc/plcd_stack.h
* \ingroup plcd
*/
+#include "plcd.h"
+#include "libmme.h"
+#include "libspid.h"
+
+/**
+ * Send all DRV MME-s for initialization process.
+ *
+ * \param ctx plcd context
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_stack_init (const plcd_ctx_t *ctx);
+
+/**
+ * Receive DRV MME-s from PLC driver,
+ * i.e. events coming from AV / EoC stack, and to dispatch them.
+ *
+ * \param ctx plcd context
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_stack_event_dispatch (plcd_ctx_t *ctx);
+
+/**
+ * Transmit a DRV MME to PLC driver.
+ * Send the given MME and,
+ * depending on given confirmation and indication contexts,
+ * wait - or not (if they are NULL) - for corresponding .CNF / .IND DRV MME-s.
+ *
+ * \param ctx plcd context
+ * \param request_ctx mme context for .REQ
+ * \param confirm_ctx mme context for .CNF
+ * \param indication_ctx mme context for .IND
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_send_recv_drv_mme (
+ const plcd_ctx_t *ctx, const mme_ctx_t *request_ctx,
+ mme_ctx_t *confirm_ctx, mme_ctx_t *indication_ctx);
+
+/**
+ * Send a DRV MME in which there is only one data field (maximum).
+ * If value is NULL, then MME data is empty.
+ * This helper function is used to send almost all initialization DRV MME-s.
+ *
+ * \param ctx plcd context
+ * \param mmtype mmtype of mme to send
+ * \param value mme data
+ * \param length length of mme data
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_send_recv_single_value (
+ const plcd_ctx_t *ctx, unsigned int mmtype,
+ const void *value, unsigned int length);
+
+/**
+ * Send DRV_STA_MAC_ADDR.REQ and receive DRV_STA_MAC_ADDR.CNF.
+ *
+ * \param ctx plcd context
+ * \param mac_addr data to send in mme
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_stack_set_mac_address (
+ const plcd_ctx_t *ctx, const unsigned char *mac_addr);
+
+/**
+ * Send DRV_STA_SET_CCO_PREF.REQ and receive DRV_STA_SET_CCO_PREF.CNF.
+ *
+ * \param ctx plcd context
+ * \param is_cco_preferred data to send in mme
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_stack_set_cco_preferred (
+ const plcd_ctx_t *ctx, libspid_boolean_t is_cco_preferred);
+
+/**
+ * Send DRV_STA_SET_WAS_CCO.REQ and receive DRV_STA_SET_WAS_CCO.CNF.
+ *
+ * \param ctx plcd context
+ * \param was_cco data to send in mme
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_stack_set_was_cco (
+ const plcd_ctx_t *ctx, libspid_boolean_t was_cco);
+
+/**
+ * Send DRV_STA_SET_KEY.REQ and receive DRV_STA_SET_KEY.CNF.
+ *
+ * \param ctx plcd context
+ * \param nmk_str data to send in mme
+ * \param nid_str data to possibly send in mme (data contain nid xor sl)
+ * \param sl_str data to possibly send in mme (data contain nid xor sl)
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_stack_set_key (
+ const plcd_ctx_t *ctx, const char *nmk_str,
+ const char *nid_str, const char *sl_str);
+
+/**
+ * Send DRV_STA_SET_DAK.REQ and receive DRV_STA_SET_DAK.CNF.
+ *
+ * \param ctx plcd context
+ * \param dpw device passwork used to generate device access key to send in mme
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_stack_set_dak (
+ const plcd_ctx_t *ctx, const char *dpw);
+
+/**
+ * Send DRV_STA_SET_M_STA_HFID.REQ and receive DRV_STA_SET_M_STA_HFID.CNF.
+ *
+ * \param ctx plcd context
+ * \param manu_hfid data to send in mme
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_stack_set_manu_hfid (
+ const plcd_ctx_t *ctx, const char *manu_hfid);
+
+/**
+ * Send DRV_STA_SET_U_STA_HFID.REQ and receive DRV_STA_SET_U_STA_HFID.CNF.
+ *
+ * \param ctx plcd context
+ * \param user_hfid data to send in mme
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_stack_set_user_hfid (
+ const plcd_ctx_t *ctx, const char *user_hfid);
+
+/**
+ * Send DRV_STA_SET_AVLN_HFID.REQ and receive DRV_STA_SET_AVLN_HFID.CNF.
+ *
+ * \param ctx plcd context
+ * \param avln_hfid data to send in mme
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_stack_set_avln_hfid (
+ const plcd_ctx_t *ctx, const char *avln_hfid);
+/**
+ * Send DRV_STA_SET_TONEMASK.REQ and receive DRV_STA_SET_TONEMASK.CNF.
+ *
+ * \param ctx plcd context
+ * \param tonemask data to send in mme
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_stack_set_tonemask (
+ const plcd_ctx_t *ctx, const unsigned char *tonemask);
+
+/**
+ * Send DRV_STA_SET_CONFIG.REQ with contents of internal.conf file,
+ * and receive DRV_STA_SET_CONFIG.CNF.
+ *
+ * \param ctx plcd context
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_stack_set_internal (const plcd_ctx_t *ctx);
+
+/**
+ * Send DRV_STA_MAC_START.REQ and receive DRV_STA_MAC_START.CNF.
+ *
+ * \param ctx plcd context
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_stack_start (const plcd_ctx_t *ctx);
+
#endif /* INC_PLCD_STACK_H */
diff --git a/cleopatre/devkit/plcd/src/plcd_main.c b/cleopatre/devkit/plcd/src/plcd_main.c
index 8ee23bbf41..d417d268d7 100644
--- a/cleopatre/devkit/plcd/src/plcd_main.c
+++ b/cleopatre/devkit/plcd/src/plcd_main.c
@@ -17,6 +17,7 @@
*
*/
#include "plcd_main.h"
+#include "plcd_stack.h"
#include <stdio.h>
#include <stdlib.h>
@@ -30,11 +31,7 @@
#include <errno.h>
#include "ioctl.h"
-
-#include "libmme.h"
-#include "libspid.h"
#include "nvram_utils.h"
-#include "plcd.h"
static plcd_nvram_t g_nvram;
diff --git a/cleopatre/devkit/plcd/src/plcd_multicast.c b/cleopatre/devkit/plcd/src/plcd_multicast.c
index 95f60f127d..3568e7a0d8 100644
--- a/cleopatre/devkit/plcd/src/plcd_multicast.c
+++ b/cleopatre/devkit/plcd/src/plcd_multicast.c
@@ -11,6 +11,7 @@
* \ingroup plcd
*/
#include "plcd_multicast.h"
+#include "plcd_stack.h"
#include <errno.h>
#include <syslog.h>
diff --git a/cleopatre/devkit/plcd/src/plcd_process.c b/cleopatre/devkit/plcd/src/plcd_process.c
index 14332b9eb9..f31a791bd6 100644
--- a/cleopatre/devkit/plcd/src/plcd_process.c
+++ b/cleopatre/devkit/plcd/src/plcd_process.c
@@ -15,6 +15,7 @@
* or user actions.
*/
#include "plcd_process.h"
+#include "plcd_stack.h"
#include <stdlib.h>
#include <stdio.h>
diff --git a/cleopatre/devkit/plcd/src/plcd_stack.c b/cleopatre/devkit/plcd/src/plcd_stack.c
index b37358ab48..c7bfe95c98 100644
--- a/cleopatre/devkit/plcd/src/plcd_stack.c
+++ b/cleopatre/devkit/plcd/src/plcd_stack.c
@@ -24,10 +24,6 @@
#include <errno.h>
#include <arpa/inet.h> /* for htons() */
-#include "libmme.h"
-#include "libspid.h"
-#include "plcd.h"
-
/******************************************************************************/
/* DEBUG FUNCTION */
/******************************************************************************/
@@ -71,18 +67,6 @@ plcd_log_packet (const char *packet, int len)
syslog (LOG_INFO, trace_buffer);
}
-
-/******************************************************************************/
-/* DISPATCH EVENTS COMING FROM AV / EOC STACK VIA DRV MME */
-/******************************************************************************/
-
-/**
- * Receive DRV MME-s from PLC driver,
- * i.e. events coming from AV / EoC stack, and to dispatch them.
- *
- * \param ctx plcd context
- * \return -1 on error, 0 otherwise
- */
int
plcd_stack_event_dispatch (plcd_ctx_t *ctx)
{
@@ -251,23 +235,6 @@ plcd_stack_event_dispatch (plcd_ctx_t *ctx)
return 0;
}
-
-/******************************************************************************/
-/* GENERIC FUNCTIONS TO SEND AND RECEIVE DRV MME */
-/******************************************************************************/
-
-/**
- * Transmit a DRV MME to PLC driver.
- * Send the given MME and,
- * depending on given confirmation and indication contexts,
- * wait - or not (if they are NULL) - for corresponding .CNF / .IND DRV MME-s.
- *
- * \param ctx plcd context
- * \param request_ctx mme context for .REQ
- * \param confirm_ctx mme context for .CNF
- * \param indication_ctx mme context for .IND
- * \return -1 on error, 0 otherwise
- */
int
plcd_send_recv_drv_mme (const plcd_ctx_t *ctx, const mme_ctx_t *request_ctx,
mme_ctx_t *confirm_ctx, mme_ctx_t *indication_ctx)
@@ -441,17 +408,6 @@ plcd_send_recv_drv_mme (const plcd_ctx_t *ctx, const mme_ctx_t *request_ctx,
return 0;
}
-/**
- * Send a DRV MME in which there is only one data field (maximum).
- * If value is NULL, then MME data is empty.
- * This helper function is used to send almost all initialization DRV MME-s.
- *
- * \param ctx plcd context
- * \param mmtype mmtype of mme to send
- * \param value mme data
- * \param length length of mme data
- * \return -1 on error, 0 otherwise
- */
int
plcd_send_recv_single_value (const plcd_ctx_t *ctx,
unsigned int mmtype,
@@ -486,18 +442,6 @@ plcd_send_recv_single_value (const plcd_ctx_t *ctx,
return 0;
}
-
-/******************************************************************************/
-/* SPECIFIC FUNCTIONS TO SEND AND RECEIVE DRV MME MANIPULATED DURING INIT */
-/******************************************************************************/
-
-/**
- * Send DRV_STA_MAC_ADDR.REQ and receive DRV_STA_MAC_ADDR.CNF.
- *
- * \param ctx plcd context
- * \param mac_addr data to send in mme
- * \return -1 on error, 0 otherwise
- */
int
plcd_stack_set_mac_address (const plcd_ctx_t *ctx, const unsigned char *mac_addr)
{
@@ -508,13 +452,6 @@ plcd_stack_set_mac_address (const plcd_ctx_t *ctx, const unsigned char *mac_addr
mac_addr, ETH_ALEN);
}
-/**
- * Send DRV_STA_SET_CCO_PREF.REQ and receive DRV_STA_SET_CCO_PREF.CNF.
- *
- * \param ctx plcd context
- * \param is_cco_preferred data to send in mme
- * \return -1 on error, 0 otherwise
- */
int
plcd_stack_set_cco_preferred (const plcd_ctx_t *ctx,
libspid_boolean_t is_cco_preferred)
@@ -527,13 +464,6 @@ plcd_stack_set_cco_preferred (const plcd_ctx_t *ctx,
sizeof (value));
}
-/**
- * Send DRV_STA_SET_WAS_CCO.REQ and receive DRV_STA_SET_WAS_CCO.CNF.
- *
- * \param ctx plcd context
- * \param was_cco data to send in mme
- * \return -1 on error, 0 otherwise
- */
int
plcd_stack_set_was_cco (const plcd_ctx_t *ctx, libspid_boolean_t was_cco)
{
@@ -545,15 +475,6 @@ plcd_stack_set_was_cco (const plcd_ctx_t *ctx, libspid_boolean_t was_cco)
&value, sizeof (value));
}
-/**
- * Send DRV_STA_SET_KEY.REQ and receive DRV_STA_SET_KEY.CNF.
- *
- * \param ctx plcd context
- * \param nmk_str data to send in mme
- * \param nid_str data to possibly send in mme (data contain nid xor sl)
- * \param sl_str data to possibly send in mme (data contain nid xor sl)
- * \return -1 on error, 0 otherwise
- */
int
plcd_stack_set_key (const plcd_ctx_t *ctx, const char *nmk_str,
const char *nid_str, const char *sl_str)
@@ -650,13 +571,6 @@ plcd_stack_set_key (const plcd_ctx_t *ctx, const char *nmk_str,
return 0;
}
-/**
- * Send DRV_STA_SET_DAK.REQ and receive DRV_STA_SET_DAK.CNF.
- *
- * \param ctx plcd context
- * \param dpw device passwork used to generate device access key to send in mme
- * \return -1 on error, 0 otherwise
- */
int
plcd_stack_set_dak (const plcd_ctx_t *ctx, const char *dpw)
{
@@ -679,13 +593,6 @@ plcd_stack_set_dak (const plcd_ctx_t *ctx, const char *dpw)
LIBSPID_SECU_OUTPUT_KEY_SIZE);
}
-/**
- * Send DRV_STA_SET_M_STA_HFID.REQ and receive DRV_STA_SET_M_STA_HFID.CNF.
- *
- * \param ctx plcd context
- * \param manu_hfid data to send in mme
- * \return -1 on error, 0 otherwise
- */
int
plcd_stack_set_manu_hfid (const plcd_ctx_t *ctx, const char *manu_hfid)
{
@@ -697,13 +604,6 @@ plcd_stack_set_manu_hfid (const plcd_ctx_t *ctx, const char *manu_hfid)
LIBSPID_HPAV_CONF_HFID_MAX_LEN);
}
-/**
- * Send DRV_STA_SET_U_STA_HFID.REQ and receive DRV_STA_SET_U_STA_HFID.CNF.
- *
- * \param ctx plcd context
- * \param user_hfid data to send in mme
- * \return -1 on error, 0 otherwise
- */
int
plcd_stack_set_user_hfid (const plcd_ctx_t *ctx, const char *user_hfid)
{
@@ -715,13 +615,6 @@ plcd_stack_set_user_hfid (const plcd_ctx_t *ctx, const char *user_hfid)
LIBSPID_HPAV_CONF_HFID_MAX_LEN);
}
-/**
- * Send DRV_STA_SET_AVLN_HFID.REQ and receive DRV_STA_SET_AVLN_HFID.CNF.
- *
- * \param ctx plcd context
- * \param avln_hfid data to send in mme
- * \return -1 on error, 0 otherwise
- */
int
plcd_stack_set_avln_hfid (const plcd_ctx_t *ctx, const char *avln_hfid)
{
@@ -733,13 +626,6 @@ plcd_stack_set_avln_hfid (const plcd_ctx_t *ctx, const char *avln_hfid)
LIBSPID_HPAV_CONF_HFID_MAX_LEN);
}
-/**
- * Send DRV_STA_SET_TONEMASK.REQ and receive DRV_STA_SET_TONEMASK.CNF.
- *
- * \param ctx plcd context
- * \param tonemask data to send in mme
- * \return -1 on error, 0 otherwise
- */
int
plcd_stack_set_tonemask (const plcd_ctx_t *ctx, const unsigned char *tonemask)
{
@@ -750,13 +636,6 @@ plcd_stack_set_tonemask (const plcd_ctx_t *ctx, const unsigned char *tonemask)
tonemask, 192);
}
-/**
- * Send DRV_STA_SET_CONFIG.REQ with contents of internal.conf file,
- * and receive DRV_STA_SET_CONFIG.CNF.
- *
- * \param ctx plcd context
- * \return -1 on error, 0 otherwise
- */
int
plcd_stack_set_internal (const plcd_ctx_t *ctx)
{
@@ -835,12 +714,6 @@ plcd_stack_set_internal (const plcd_ctx_t *ctx)
mme_buffer, strlen (mme_buffer) + 1);
}
-/**
- * Send DRV_STA_MAC_START.REQ and receive DRV_STA_MAC_START.CNF.
- *
- * \param ctx plcd context
- * \return -1 on error, 0 otherwise
- */
int
plcd_stack_start (const plcd_ctx_t *ctx)
{
@@ -849,17 +722,6 @@ plcd_stack_start (const plcd_ctx_t *ctx)
return plcd_send_recv_single_value (ctx, DRV_STA_MAC_START, NULL, 0);
}
-
-/******************************************************************************/
-/* FUNCTION TO SEND AND RECEIVE DRV MME NEEDED FOR AV / EOC STACK INIT */
-/******************************************************************************/
-
-/**
- * Send all DRV MME-s for initialization process.
- *
- * \param ctx plcd context
- * \return -1 on error, 0 otherwise
- */
int
plcd_stack_init (const plcd_ctx_t *ctx)
{