Show emproxy_i.h syntax highlighted
/*
*
* Copyright (c) 2003 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.
*
*/
/*
* Private structs of emProxy
*
* $Id: emproxy_i.h,v 1.10 2006/07/15 22:25:19 girod Exp $
*/
#include <emproxy/emproxy.h>
#include <libdev/status_client.h>
#include <libdev/packet_dev.h>
#include <libdev/status_dev.h>
#include <link/link.h>
#include <link/link_multi.h>
#ifndef __EMPROXY_I_H__
#define __EMPROXY_I_H__
/* client message header */
struct client_message {
int request_type;
int seq_no;
int dest_node;
int src;
};
struct emp_command {
/* parameters */
struct client_message msg;
char *command;
int command_length;
/* when started */
int time_started;
int time_ended;
/* response event */
g_event_t *response_event;
int output_fd;
pid_t child_pid;
buf_t *response;
int exited;
int exit_status;
/* command list pointers */
QUEUE_ELEMENT_DECL(_, struct emp_command);
struct emp_client *parent;
};
struct emp_request {
/* device parameters */
status_client_opts_t client_opts;
/* add'l request params */
int dst_node;
/* data ID */
int data_id;
/* mark */
int mark;
/* last heard time */
int last_heard;
/* the event */
status_client_context_t *event;
/* parent */
struct emp_client *parent;
/* request list pointers */
QUEUE_ELEMENT_DECL(_, struct emp_request);
};
typedef struct cached_emp_node {
buf_t* emview_cmd;
node_id_t node_id;
QUEUE_ELEMENT_DECL(_, struct cached_emp_node);
} cached_emp_node_t;
struct emp_client {
/* return address */
struct sockaddr_in src_addr;
int addr_len;
int src_proto;
int src_iface;
/* last heard time */
int last_heard;
/* session nonce, to prevent port number reuse */
int session;
/* outgoing message (no longer just for udp) */
char udp_buf[EMPROXY_UDP_THRESHOLD];
int udp_len;
g_event_t *send_timer;
/* request list for this client */
QUEUE_DECL(requests, struct emp_request);
/* pending commands for this client */
QUEUE_DECL(commands, struct emp_command);
/* client list pointers */
QUEUE_ELEMENT_DECL(_, struct emp_client);
struct emp_state *parent;
};
struct emp_state {
QUEUE_DECL(clients, struct emp_client);
QUEUE_DECL(nodes, struct cached_emp_node);
/* UDP state */
int server_fd;
/* link state */
lu_multi_context_t *link_ref;
int sim_demux;
int gw_only;
/* don't process looped commands */
int ignore_local_cmds;
/* status device */
status_context_t *proxy_status;
/* gateway device */
status_context_t *proxy_gw;
/* optional demux device */
pd_context_t *proxy_demux;
};
/* emproxy.c */
int emproxy_push_data(struct emp_client *client, struct emproxy_reply_hdr *reply);
int emproxy_send_data(struct emp_client *client, char *buf, size_t len);
/* emproxy_gw.c */
void emproxy_gw_init(struct emp_state *es);
void emproxy_update_nodes(struct emp_state* es, struct emp_client* client, int data_id);
/* emproxy_cmd.c */
void emproxy_process_command(struct emp_state *es, struct emp_client *client,
struct client_message *msg, char *request, int req_len);
void emproxy_command_cancel(struct emp_command *cmd);
void emproxy_command_gc_now(struct emp_client *client);
void emproxy_command_handler_init(struct emp_state *e);
/* queue template */
QUEUE_INLINE_INSTANTIATIONS(emproxy_client, _, clients, struct emp_client, struct emp_state);
QUEUE_INLINE_INSTANTIATIONS(emproxy_request, _, requests, struct emp_request, struct emp_client);
QUEUE_INLINE_INSTANTIATIONS(emproxy_command, _, commands, struct emp_command, struct emp_client);
QUEUE_INLINE_INSTANTIATIONS(emproxy_cached_node, _, nodes, struct cached_emp_node, struct emp_state);
/* constants */
#define EMPROXY_GC_INTERVAL 1000 /* ms */
#define EMPROXY_CLIENT_TIMEOUT 35 /* sec */
#define EMPROXY_COMMAND_LINGER 10 /* sec */
#define EMPROXY_COMMAND_MAXWAIT 20 /* sec */
#define EMPROXY_COMMAND_MAXRESP 1024 /* bytes */
/* request types */
#define EMPROXY_REQ_REQUEST 1
#define EMPROXY_REQ_COMMAND 2
/* Defined in emproxy_gw.c */
void emproxy_gw_update_client(struct emp_client* ptr, struct emp_state* es);
#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
emproxy.c
emproxy_cmd.c
emproxy_gw.c
emproxy_i.h