Show wl_i.h syntax highlighted
/*
* Copyright (c) 2004 The Regents of the University of California. All
* rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Neither the name of the University nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <libmisc/misc.h>
#include <libdev/status_client.h>
#include <devel/state/ssync.h>
#ifndef __WL_I_H__
#define __WL_I_H__
/*
* node record
*/
typedef struct wl_node {
node_id_t id;
ssync_sub_t *ssync_sub;
struct wl_state *parent;
/* pending records for this node */
QUEUE_DECL(updates,struct pending_update);
int next_key;
/* queue pointers */
QUEUE_ELEMENT_DECL(_,struct wl_node);
} wl_node_t;
typedef struct wl_node_list {
QUEUE_DECL(list,struct wl_node);
} wl_node_list_t;
QUEUE_INLINE_INSTANTIATIONS(wl_nodes,_,list,struct wl_node,struct wl_node_list);
/*
* pending transaction record
*/
typedef struct arrival {
wl_node_t *node;
int latency; /* in us.. zero means hasn't arrived yet */
int removal_latency; /* in us.. zero means hasn't arrived yet */
int hops_away;
} arrival_t;
typedef struct pending_update {
int64_t admission_time; /* time of data admission */
int64_t removal_time; /* time of data retraction */
uint16_t key; /* the element we're monitoring */
uint16_t app_seq;
char *entry;
int entry_len;
arrival_t *arrivals; /* vector of arrivals */
/* source node */
wl_node_t *source;
int deleted:1; /* flag indicates this has been removed from the source */
int to_stamp:1; /* */
int mark:1;
int reserved:29; /* add'l flags */
/* queue pointers */
QUEUE_ELEMENT_DECL(pending,struct pending_update);
QUEUE_ELEMENT_DECL(per_node,struct pending_update);
} pending_update_t;
typedef struct pending_list {
QUEUE_DECL(list,pending_update_t);
} pending_list_t;
QUEUE_INLINE_INSTANTIATIONS(wl_pending,pending,list,struct pending_update,struct pending_list);
QUEUE_INLINE_INSTANTIATIONS(wl_pending_node,per_node,updates,struct pending_update,struct wl_node);
/*
* stats recording
*/
typedef struct wl_stats {
FILE *stat_logfile;
char *prefix;
ssync_stats_t latest;
ssync_stats_t totals;
int total_pushed;
int total_pushed_bytes;
} wl_stats_t;
/*
* workload common state
*/
typedef struct wl_state {
buf_t *usage_buf;
FILE *logfile;
FILE *cdf_logfile;
FILE *traf_logfile;
/* common arguments */
int interval;
int max_keys;
int hops;
int iface;
int refresh;
int entry_size;
int halt_sim;
int do_csync_stats;
int stats_only;
int local;
int delay;
char *base_link;
char *prefix;
char *typename;
void *plugin_state;
wl_node_list_t nodes;
pending_list_t pending;
wl_stats_t main_stats;
wl_stats_t csync_stats;
wl_stats_t comb_stats;
} wl_state_t;
#define DEFAULT_INTERVAL 10000
#define DEFAULT_MAX_KEYS 16
#define DEFAULT_REFRESH 10000
#define DEFAULT_HOPS 10
#define DEFAULT_VALUE_LEN 15
#define WL_KEY_LEN 2
#define WL_TYPENAME "wlvar"
#define WL_STATS_INTERVAL 1000
/* wl_structs.c */
int wl_push_data(wl_state_t *wl, wl_node_t *node);
wl_node_t *wl_node_lookup(wl_node_list_t *list, node_id_t id);
wl_node_t *wl_node_register(wl_state_t *wl, node_id_t id);
void wl_scan_for_complete(wl_state_t *wl, int shutdown);
int wl_count_entries(wl_node_t *node);
/* key and size auto-assign if -1 */
int wl_admit_random_data(wl_state_t *wl, wl_node_t *node,
int key, int size);
int wl_admit_data(wl_state_t *wl, wl_node_t *node, int key,
char *entry, int size);
void wl_node_become(wl_node_t *nid);
void wl_node_unbecome();
/* plugin API */
void wl_force_shutdown();
/* plugins */
void wl_plugin_random_rate(wl_state_t *wl, char *load, int *argc, char **argv);
void wl_plugin_scenario_file(wl_state_t *wl, char *load, int *argc, char **argv);
#endif
See more files for this project here
EmStar is a software system for developing and deploying wireless sensor networks involving Linux-based platforms. As the wireless sensor network community has attempted to deploy more complex designs---large-scale, long-lived systems that need self-organization and adaptivity---a number of difficult software design issues have arisen. Advances in software design have not kept pace with the capabilities of hardware. This is because designing for an adaptive, efficient, and useful sensor network has turned out to be surprisingly complex and difficult. EmStar is a Linux-based software framework, whose goal is to dramatically reduce this complexity, enabling work to be shared and reused, and simplifying and speeding the design of new sensor network applications.
Project homepage:
http://cvs.cens.ucla.edu/emstar/
Programming language(s): C,Shell Script
License: other
generate.c
wl_i.h
wl_main.c
wl_plugin_random_rate.c
wl_plugin_scenario_file.c
wl_structs.c