blob: 2d9cd0007cba6ad984635278c95d57e61576142b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*********************************************************************
2 *
3 * Filename: parameters.h
4 * Version: 1.0
5 * Description: A more general way to handle (pi,pl,pv) parameters
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Mon Jun 7 08:47:28 1999
9 * Modified at: Sun Jan 30 14:05:14 2000
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
11 *
12 * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
Jeff Kirshera6227e22013-12-06 09:13:40 -080025 * along with this program; if not, see <http://www.gnu.org/licenses/>.
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 *
John Anthony Kazos Jr121e70b2007-05-09 08:30:57 +020027 * Michel Dänzer <daenzer@debian.org>, 10/2001
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 * - simplify irda_pv_t to avoid endianness issues
29 *
30 ********************************************************************/
31
32#ifndef IRDA_PARAMS_H
33#define IRDA_PARAMS_H
34
35/*
36 * The currently supported types. Beware not to change the sequence since
37 * it a good reason why the sized integers has a value equal to their size
38 */
39typedef enum {
40 PV_INTEGER, /* Integer of any (pl) length */
41 PV_INT_8_BITS, /* Integer of 8 bits in length */
42 PV_INT_16_BITS, /* Integer of 16 bits in length */
43 PV_STRING, /* \0 terminated string */
44 PV_INT_32_BITS, /* Integer of 32 bits in length */
45 PV_OCT_SEQ, /* Octet sequence */
46 PV_NO_VALUE /* Does not contain any value (pl=0) */
47} PV_TYPE;
48
49/* Bit 7 of type field */
50#define PV_BIG_ENDIAN 0x80
51#define PV_LITTLE_ENDIAN 0x00
52#define PV_MASK 0x7f /* To mask away endian bit */
53
54#define PV_PUT 0
55#define PV_GET 1
56
57typedef union {
58 char *c;
59 __u32 i;
60 __u32 *ip;
61} irda_pv_t;
62
63typedef struct {
64 __u8 pi;
65 __u8 pl;
66 irda_pv_t pv;
67} irda_param_t;
68
69typedef int (*PI_HANDLER)(void *self, irda_param_t *param, int get);
70typedef int (*PV_HANDLER)(void *self, __u8 *buf, int len, __u8 pi,
71 PV_TYPE type, PI_HANDLER func);
72
73typedef struct {
Joe Perches785c20a2014-12-10 10:28:58 -080074 const PI_HANDLER func; /* Handler for this parameter identifier */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 PV_TYPE type; /* Data type for this parameter */
76} pi_minor_info_t;
77
78typedef struct {
Joe Perches785c20a2014-12-10 10:28:58 -080079 const pi_minor_info_t *pi_minor_call_table;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 int len;
81} pi_major_info_t;
82
83typedef struct {
Joe Perches785c20a2014-12-10 10:28:58 -080084 const pi_major_info_t *tables;
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 int len;
86 __u8 pi_mask;
87 int pi_major_offset;
88} pi_param_info_t;
89
90int irda_param_pack(__u8 *buf, char *fmt, ...);
91
92int irda_param_insert(void *self, __u8 pi, __u8 *buf, int len,
93 pi_param_info_t *info);
94int irda_param_extract_all(void *self, __u8 *buf, int len,
95 pi_param_info_t *info);
96
97#define irda_param_insert_byte(buf,pi,pv) irda_param_pack(buf,"bbb",pi,1,pv)
98
99#endif /* IRDA_PARAMS_H */
100