Code Search for Developers
 
 
  

link_pass.h from EmStar at Krugle


Show link_pass.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.
 *
 */
 

/*
 * link_pass.h -- Library for defining link-layer passthru devices
 *
 * $Id: link_pass.h,v 1.13 2006/02/28 21:07:30 thanos Exp $
 */

#include <link/link.h>

#ifndef __LINK_PASS_H__
#define __LINK_PASS_H__

typedef struct link_pass_ctx link_pass_ctx_t;

/*
 *  Packets from this callback must be copied and NOT freed.  
 *  (whether from lower OR upper..)
 *  data_len does NOT include header 
 *
 *  The from_upper callback can return LP_BLOCKED to cause blocking.
 */
typedef int (*link_pass_send_cb_t)(link_pass_ctx_t *lp, link_pkt_t *packet, int data_len);
				   

typedef void (*link_pass_notify_cb_t)(link_pass_ctx_t *lp);

/* optional command processing function 
 * system will free parser state.
 * fill any unprocessed commands into cmd_pass */
typedef int (*link_pass_command_cb_t)(link_pass_ctx_t *pass, 
				      parser_state_t *cmd_input, buf_t *cmd_pass);
typedef void (*link_pass_command_usage_cb_t)(link_pass_ctx_t *lp, buf_t *fill_usage);

typedef struct link_pass_opts {

  char *description;     /* the description for this device */

  /* Defines the upper and lower devices */
  /* NOTE: only the data pointer in 'uses' is passed to callbacks */
  link_opts_t uses;      /* the module below */
  link_opts_t provides;  /* the interface to modules above */

  /* callbacks */

  /* receiving packets from above or below */
  link_pass_send_cb_t pkt_from_lower;
  link_pass_send_cb_t pkt_from_upper;

  /* enqueue callback.. reject packets early */
  link_pass_send_cb_t enqueue_pkt_from_upper;

  /* status notify callback.. update upper status */
  link_pass_notify_cb_t status_notify;

  /* notifies that lower link opened, if needs to be configured */
  link_pass_notify_cb_t configure_lower;

  /* enables a passthrough to process coammnds */
  link_pass_command_cb_t process_command;
  link_pass_command_usage_cb_t usage;

  /* common cases: 
   * mtu_adjust: if the MTU is fixed offset from lower
   * new_fixed_mtu: if the MTU is a fixed value */
  int mtu_adjust;
  int new_fixed_mtu;
  
  /* if this is not set, but a packet type filter is, it will auto-forward receipts */ 
  int dont_auto_forward_receipts;
} link_pass_opts_t;

/*
 *  registering and destroying a passthru device
 */

int link_pass_new(link_pass_opts_t *opts, link_pass_ctx_t **ref);
void link_pass_destroy(link_pass_ctx_t *lpt);

/*
 *  passing packets up or down
 *    pass alloc'd buf_t, library will free
 *    pass_to_lower returns LP_BLOCKED if blocked..
 */

int link_pass_to_lower(link_pass_ctx_t *ctx, buf_t *buf);
int link_pass_to_upper(link_pass_ctx_t *ctx, buf_t *buf);

/* flushes any data that is queued to be sent */
void link_pass_abort_queue(link_pass_ctx_t *ctx);

/* get the status for the lower device, */
/* push status struct up to upper */
int link_pass_get_lower_status(link_pass_ctx_t *ctx, link_status_t *status);
void link_pass_push_status_to_upper(link_pass_ctx_t *ctx, link_status_t *status);

/* data accessor */
void *link_pass_data(link_pass_ctx_t *ctx);
char *link_pass_name(link_pass_ctx_t *ctx, char *suffix);

/* enable/disable receiving packets from upper */
void link_pass_block(link_pass_ctx_t *ctx);
void link_pass_unblock(link_pass_ctx_t *ctx);
int link_pass_blocking_requested(link_pass_ctx_t *ctx);
int link_pass_is_blocked(link_pass_ctx_t *ctx);

lu_context_t *link_pass_get_lower(link_pass_ctx_t *ctx);
lp_context_t *link_pass_get_upper(link_pass_ctx_t *ctx);


#endif




See more files for this project here

EmStar

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

  conntest.h
  connview.h
  libmacinfo.h
  link.h
  link.run
  link_headers.h
  link_ioctls.h
  link_multi.h
  link_parse.h
  link_pass.h
  link_structs.h
  linkstats.h
  lqe.h
  neighbor.h
  neighbor_structs.h