#include "fwp_conf.h"
-/** IP Address of interface FWP operates */
-#ifndef CONFUGURE_FWP_IF
-#define CONFIGURE_FWP_IF 127.0.0.1
-#endif
-
/** Number of ACs */
#ifndef CONFUGURE_FWP_AC_NUM
#define CONFIGURE_FWP_AC_NUM 4
#define CONFIGURE_FWP_ENDPOINTS_MAXIMUM 50
#endif
+/** IP Address of interface FWP operates on */
+#ifndef CONFIGURE_FWP_MY_ADDR
+#define CONFIGURE_FWP_MY_ADDR "127.0.0.1"
+#endif
+
+#ifndef CONFIGURE_FWP_MY_STREAM_ID
+#define CONFIGURE_FWP_MY_STREAM_ID 0
+#endif
+
+#ifndef CONFIGURE_FWP_MNGR_ADDR
+#define CONFIGURE_FWP_MNGR_ADDR "255.255.255.255"
+#endif
+
+#ifndef CONFIGURE_FWP_MNGR_STREAM_ID
+#define CONFIGURE_FWP_MNGR_STREAM_ID 3000
+#endif
+
fwp_configuration_table_t fwp_configuration = {
CONFIGURE_FWP_VRES_MAXIMUM,
- CONFIGURE_FWP_ENDPOINTS_MAXIMUM
+ CONFIGURE_FWP_ENDPOINTS_MAXIMUM,
+ CONFIGURE_FWP_MY_ADDR,
+ CONFIGURE_FWP_MY_STREAM_ID,
+ CONFIGURE_FWP_MNGR_ADDR,
+ CONFIGURE_FWP_MNGR_STREAM_ID,
+ 0,
+ 0
};
+#include "fwp_conf.h"
#include "fwp_mngt.h"
+#include <stdlib.h>
/*
* Global mngt variables
*/
fwp_msg_type_t msg_type;
+ /* Create discovery endpoint */
+ FWP_DEBUG("Service vres created\n");
+ fwp_mngt_service_vres_create(&fwp_participant_mngr->vresd);
+
+ FWP_DEBUG("Discovery send endpoint created\n");
+ fwp_send_endpoint_create(fwp_participant_mngr->id.node_id,
+ fwp_participant_mngr->stream_id,
+ 0, &fwp_participant_mngr->epointd);
+ fwp_send_endpoint_bind(fwp_participant_mngr->epointd,
+ fwp_participant_mngr->vresd);
+
/* prepare hello message */
msgb = fwp_msgb_alloc(sizeof(struct fwp_msg_header) +
sizeof(struct fwp_msg_hello));
fwp_participant_info_t my_info, mngr_info;
unsigned int node_id;
int flags;
+ char *value;
/* Create fwp_participant_this */
- my_info.id.node_id = inet_addr("127.0.0.1");
+
+ my_info.id.node_id = inet_addr(fwp_configuration.my_addr);
+ if (my_info.id.node_id == inet_addr("127.0.0.1")) {
+ /* if default then check env variable */
+ value = getenv("FWP_MY_ADDR");
+ if (value) {
+ my_info.id.node_id = inet_addr(value);
+ }
+ }
+ fwp_configuration.my_node_id = my_info.id.node_id;
my_info.id.app_id = getpid();
- my_info.stream_id = 0;
+ my_info.stream_id = fwp_configuration.my_stream_id;
fwp_participant_this = fwp_participant_create(&my_info);
- fwp_receive_endpoint_create(0, 0, &fwp_participant_this->epointd);
+ fwp_receive_endpoint_create(my_info.stream_id, 0,
+ &fwp_participant_this->epointd);
/* FIXME
fwp_endpoint_get_params(&(fwp_participant_this->id.node_id),
&fwp_participant_this->stream_id,
fwp_participant_this->stream_id);
/* Create fwp_participant_mngr */
- mngr_info.id.node_id = inet_addr("127.0.0.1");
- /*mngr_info.id.node_id = inet_addr("255.255.255.255");*/
- mngr_info.id.app_id = getpid();
- mngr_info.stream_id = FWP_MNGR_STREAM_ID;
-
- fwp_participant_mngr = fwp_participant_create(&mngr_info);
- /* Create discovery endpoint */
- FWP_DEBUG("Service vres created\n");
- fwp_mngt_service_vres_create(&fwp_participant_mngr->vresd);
+ mngr_info.id.node_id = inet_addr(fwp_configuration.mngr_addr);
+ FWP_DEBUG("mngr node=%s node_id=%d\n",
+ fwp_configuration.mngr_addr,
+ mngr_info.id.node_id);
+ if (mngr_info.id.node_id == inet_addr("255.255.255.255")) {
+ /* if default then check env variable */
+ value = getenv("FWP_MNGR_ADDR");
+ if (value) {
+ mngr_info.id.node_id = inet_addr(value);
+ }
+ }
+ fwp_configuration.mngr_node_id = mngr_info.id.node_id;
+ mngr_info.id.app_id = getpid();
+ mngr_info.stream_id = fwp_configuration.mngr_stream_id;
- FWP_DEBUG("Discovery send endpoint created\n");
- fwp_send_endpoint_create(fwp_participant_mngr->id.node_id,
- fwp_participant_mngr->stream_id,
- 0, &fwp_participant_mngr->epointd);
- fwp_send_endpoint_bind(fwp_participant_mngr->epointd,
- fwp_participant_mngr->vresd);
+ if ((mngr_info.id.node_id == inet_addr("127.0.0.1")) &&
+ (my_info.stream_id == mngr_info.stream_id)) {
+ /* I am a manager */
+ FWP_DEBUG("I am FWP manager\n");
+ fwp_participant_mngr = fwp_participant_this;
+ } else {
+ fwp_participant_mngr = fwp_participant_create(&mngr_info);
+ /* Connet to FWP manager */
+ fwp_mngt_connect();
+ }
return 0;
}