Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

parameters.h

Go to the documentation of this file.
00001 /*********************************************************************
00002  *                
00003  * Filename:      parameters.h
00004  * Version:       1.0
00005  * Description:   A more general way to handle (pi,pl,pv) parameters
00006  * Status:        Experimental.
00007  * Author:        Dag Brattli <dagb@cs.uit.no>
00008  * Created at:    Mon Jun  7 08:47:28 1999
00009  * Modified at:   Sun Jan 30 14:05:14 2000
00010  * Modified by:   Dag Brattli <dagb@cs.uit.no>
00011  * 
00012  *     Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved.
00013  *     
00014  *     This program is free software; you can redistribute it and/or 
00015  *     modify it under the terms of the GNU General Public License as 
00016  *     published by the Free Software Foundation; either version 2 of 
00017  *     the License, or (at your option) any later version.
00018  * 
00019  *     This program is distributed in the hope that it will be useful,
00020  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00022  *     GNU General Public License for more details.
00023  * 
00024  *     You should have received a copy of the GNU General Public License 
00025  *     along with this program; if not, write to the Free Software 
00026  *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
00027  *     MA 02111-1307 USA
00028  *     
00029  ********************************************************************/
00030 
00031 #ifndef IRDA_PARAMS_H
00032 #define IRDA_PARAMS_H
00033 
00034 /*
00035  *  The currently supported types. Beware not to change the sequence since
00036  *  it a good reason why the sized integers has a value equal to their size
00037  */
00038 typedef enum {
00039         PV_INTEGER,      /* Integer of any (pl) length */
00040         PV_INT_8_BITS,   /* Integer of 8 bits in length */
00041         PV_INT_16_BITS,  /* Integer of 16 bits in length */
00042         PV_STRING,       /* \0 terminated string */
00043         PV_INT_32_BITS,  /* Integer of 32 bits in length */
00044         PV_OCT_SEQ,      /* Octet sequence */
00045         PV_NO_VALUE      /* Does not contain any value (pl=0) */
00046 } PV_TYPE;
00047 
00048 /* Bit 7 of type field */
00049 #define PV_BIG_ENDIAN    0x80 
00050 #define PV_LITTLE_ENDIAN 0x00
00051 #define PV_MASK          0x7f   /* To mask away endian bit */
00052 
00053 #define PV_PUT 0
00054 #define PV_GET 1
00055 
00056 typedef union {
00057         char   *c;
00058         __u8    b;
00059         __u16   s;
00060         __u32   i;
00061         __u8  *bp;
00062         __u16 *sp;
00063         __u32 *ip;
00064 } irda_pv_t;
00065 
00066 typedef struct {
00067         __u8 pi;
00068         __u8 pl;
00069         irda_pv_t pv;
00070 } irda_param_t;
00071 
00072 typedef int (*PI_HANDLER)(void *self, irda_param_t *param, int get);
00073 typedef int (*PV_HANDLER)(void *self, __u8 *buf, int len, __u8 pi,
00074                           PV_TYPE type, PI_HANDLER func);
00075 
00076 typedef struct {
00077         PI_HANDLER func;  /* Handler for this parameter identifier */
00078         PV_TYPE    type;  /* Data type for this parameter */
00079 } pi_minor_info_t;
00080 
00081 typedef struct {
00082         pi_minor_info_t *pi_minor_call_table;
00083         int len;
00084 } pi_major_info_t;
00085 
00086 typedef struct {
00087         pi_major_info_t *tables;
00088         int              len;
00089         __u8             pi_mask;
00090         int              pi_major_offset;
00091 } pi_param_info_t;
00092 
00093 int irda_param_pack(__u8 *buf, char *fmt, ...);
00094 int irda_param_unpack(__u8 *buf, char *fmt, ...);
00095 
00096 int irda_param_insert(void *self, __u8 pi, __u8 *buf, int len, 
00097                       pi_param_info_t *info);
00098 int irda_param_extract(void *self, __u8 *buf, int len, pi_param_info_t *info);
00099 int irda_param_extract_all(void *self, __u8 *buf, int len, 
00100                            pi_param_info_t *info);
00101 
00102 #define irda_param_insert_byte(buf,pi,pv) irda_param_pack(buf,"bbb",pi,1,pv)
00103 
00104 #endif /* IRDA_PARAMS_H */
00105