~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
cvs/emstar/link/include/link_pass.h


  1 /*
  2  * Copyright (c) 2003 The Regents of the University of California.  All 
  3  * rights reserved.
  4  *
  5  * Redistribution and use in source and binary forms, with or without
  6  * modification, are permitted provided that the following conditions
  7  * are met:
  8  *
  9  * - Redistributions of source code must retain the above copyright
 10  *   notice, this list of conditions and the following disclaimer.
 11  *
 12  * - Neither the name of the University nor the names of its
 13  *   contributors may be used to endorse or promote products derived
 14  *   from this software without specific prior written permission.
 15  *
 16  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
 17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 18  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 19  * PARTICULAR  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
 20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 24  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 27  *
 28  */
 29  
 30 
 31 /*
 32  * link_pass.h -- Library for defining link-layer passthru devices
 33  *
 34  * $Id: link_pass.h,v 1.13 2006-02-28 21:07:30 thanos Exp $
 35  */
 36 
 37 #include <link/link.h>
 38 
 39 #ifndef __LINK_PASS_H__
 40 #define __LINK_PASS_H__
 41 
 42 typedef struct link_pass_ctx link_pass_ctx_t;
 43 
 44 /*
 45  *  Packets from this callback must be copied and NOT freed.  
 46  *  (whether from lower OR upper..)
 47  *  data_len does NOT include header 
 48  *
 49  *  The from_upper callback can return LP_BLOCKED to cause blocking.
 50  */
 51 typedef int (*link_pass_send_cb_t)(link_pass_ctx_t *lp, link_pkt_t *packet, int data_len);
 52                                    
 53 
 54 typedef void (*link_pass_notify_cb_t)(link_pass_ctx_t *lp);
 55 
 56 /* optional command processing function 
 57  * system will free parser state.
 58  * fill any unprocessed commands into cmd_pass */
 59 typedef int (*link_pass_command_cb_t)(link_pass_ctx_t *pass, 
 60                                       parser_state_t *cmd_input, buf_t *cmd_pass);
 61 typedef void (*link_pass_command_usage_cb_t)(link_pass_ctx_t *lp, buf_t *fill_usage);
 62 
 63 typedef struct link_pass_opts {
 64 
 65   char *description;     /* the description for this device */
 66 
 67   /* Defines the upper and lower devices */
 68   /* NOTE: only the data pointer in 'uses' is passed to callbacks */
 69   link_opts_t uses;      /* the module below */
 70   link_opts_t provides;  /* the interface to modules above */
 71 
 72   /* callbacks */
 73 
 74   /* receiving packets from above or below */
 75   link_pass_send_cb_t pkt_from_lower;
 76   link_pass_send_cb_t pkt_from_upper;
 77 
 78   /* enqueue callback.. reject packets early */
 79   link_pass_send_cb_t enqueue_pkt_from_upper;
 80 
 81   /* status notify callback.. update upper status */
 82   link_pass_notify_cb_t status_notify;
 83 
 84   /* notifies that lower link opened, if needs to be configured */
 85   link_pass_notify_cb_t configure_lower;
 86 
 87   /* enables a passthrough to process coammnds */
 88   link_pass_command_cb_t process_command;
 89   link_pass_command_usage_cb_t usage;
 90 
 91   /* common cases: 
 92    * mtu_adjust: if the MTU is fixed offset from lower
 93    * new_fixed_mtu: if the MTU is a fixed value */
 94   int mtu_adjust;
 95   int new_fixed_mtu;
 96   
 97   /* if this is not set, but a packet type filter is, it will auto-forward receipts */ 
 98   int dont_auto_forward_receipts;
 99 } link_pass_opts_t;
100 
101 /*
102  *  registering and destroying a passthru device
103  */
104 
105 int link_pass_new(link_pass_opts_t *opts, link_pass_ctx_t **ref);
106 void link_pass_destroy(link_pass_ctx_t *lpt);
107 
108 /*
109  *  passing packets up or down
110  *    pass alloc'd buf_t, library will free
111  *    pass_to_lower returns LP_BLOCKED if blocked..
112  */
113 
114 int link_pass_to_lower(link_pass_ctx_t *ctx, buf_t *buf);
115 int link_pass_to_upper(link_pass_ctx_t *ctx, buf_t *buf);
116 
117 /* flushes any data that is queued to be sent */
118 void link_pass_abort_queue(link_pass_ctx_t *ctx);
119 
120 /* get the status for the lower device, */
121 /* push status struct up to upper */
122 int link_pass_get_lower_status(link_pass_ctx_t *ctx, link_status_t *status);
123 void link_pass_push_status_to_upper(link_pass_ctx_t *ctx, link_status_t *status);
124 
125 /* data accessor */
126 void *link_pass_data(link_pass_ctx_t *ctx);
127 char *link_pass_name(link_pass_ctx_t *ctx, char *suffix);
128 
129 /* enable/disable receiving packets from upper */
130 void link_pass_block(link_pass_ctx_t *ctx);
131 void link_pass_unblock(link_pass_ctx_t *ctx);
132 int link_pass_blocking_requested(link_pass_ctx_t *ctx);
133 int link_pass_is_blocked(link_pass_ctx_t *ctx);
134 
135 lu_context_t *link_pass_get_lower(link_pass_ctx_t *ctx);
136 lp_context_t *link_pass_get_upper(link_pass_ctx_t *ctx);
137 
138 
139 #endif
140 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.