Staging: Add initial release of brcm80211 - Broadcom 802.11n wireless LAN driver.
[linux-2.6-block.git] / drivers / staging / brcm80211 / include / bcm_xdr.h
1 /*
2  * Copyright (c) 2010 Broadcom Corporation
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 #ifndef _BCM_XDR_H
18 #define _BCM_XDR_H
19
20 /*
21  * bcm_xdr_buf_t
22  * Structure used for bookkeeping of a buffer being packed or unpacked.
23  * Keeps a current read/write pointer and size as well as
24  * the original buffer pointer and size.
25  *
26  */
27 typedef struct {
28         uint8 *buf;             /* pointer to current position in origbuf */
29         uint size;              /* current (residual) size in bytes */
30         uint8 *origbuf;         /* unmodified pointer to orignal buffer */
31         uint origsize;          /* unmodified orignal buffer size in bytes */
32 } bcm_xdr_buf_t;
33
34 void bcm_xdr_buf_init(bcm_xdr_buf_t * b, void *buf, size_t len);
35
36 int bcm_xdr_pack_uint32(bcm_xdr_buf_t * b, uint32 val);
37 int bcm_xdr_unpack_uint32(bcm_xdr_buf_t * b, uint32 * pval);
38 int bcm_xdr_pack_int32(bcm_xdr_buf_t * b, int32 val);
39 int bcm_xdr_unpack_int32(bcm_xdr_buf_t * b, int32 * pval);
40 int bcm_xdr_pack_int8(bcm_xdr_buf_t * b, int8 val);
41 int bcm_xdr_unpack_int8(bcm_xdr_buf_t * b, int8 * pval);
42 int bcm_xdr_pack_opaque(bcm_xdr_buf_t * b, uint len, void *data);
43 int bcm_xdr_unpack_opaque(bcm_xdr_buf_t * b, uint len, void **pdata);
44 int bcm_xdr_unpack_opaque_cpy(bcm_xdr_buf_t * b, uint len, void *data);
45 int bcm_xdr_pack_opaque_varlen(bcm_xdr_buf_t * b, uint len, void *data);
46 int bcm_xdr_unpack_opaque_varlen(bcm_xdr_buf_t * b, uint * plen, void **pdata);
47 int bcm_xdr_pack_string(bcm_xdr_buf_t * b, char *str);
48 int bcm_xdr_unpack_string(bcm_xdr_buf_t * b, uint * plen, char **pstr);
49
50 int bcm_xdr_pack_uint8_vec(bcm_xdr_buf_t *, uint8 * vec, uint32 elems);
51 int bcm_xdr_unpack_uint8_vec(bcm_xdr_buf_t *, uint8 * vec, uint32 elems);
52 int bcm_xdr_pack_uint16_vec(bcm_xdr_buf_t * b, uint len, void *vec);
53 int bcm_xdr_unpack_uint16_vec(bcm_xdr_buf_t * b, uint len, void *vec);
54 int bcm_xdr_pack_uint32_vec(bcm_xdr_buf_t * b, uint len, void *vec);
55 int bcm_xdr_unpack_uint32_vec(bcm_xdr_buf_t * b, uint len, void *vec);
56
57 int bcm_xdr_pack_opaque_raw(bcm_xdr_buf_t * b, uint len, void *data);
58 int bcm_xdr_pack_opaque_pad(bcm_xdr_buf_t * b);
59
60 #endif                          /* _BCM_XDR_H */