• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Misc useful os-independent macros and functions.
3  *
4  * Copyright (C) 1999-2009, Broadcom Corporation
5  *
6  *      Unless you and Broadcom execute a separate written software license
7  * agreement governing use of this software, this software is licensed to you
8  * under the terms of the GNU General Public License version 2 (the "GPL"),
9  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10  * following added to such license:
11  *
12  *      As a special exception, the copyright holders of this software give you
13  * permission to link this software with independent modules, and to copy and
14  * distribute the resulting executable under terms of your choice, provided that
15  * you also meet, for each linked independent module, the terms and conditions of
16  * the license of that module.  An independent module is a module which is not
17  * derived from this software.  The special exception does not apply to any
18  * modifications of the software.
19  *
20  *      Notwithstanding the above, under no circumstances may you combine this
21  * software in any way with any other Broadcom software provided under a license
22  * other than the GPL, without Broadcom's express prior written consent.
23  * $Id: bcmutils.h,v 13.184.4.6.2.1.18.22 2009/10/28 18:25:39 Exp $
24  */
25 
26 
27 #ifndef	_bcmutils_h_
28 #define	_bcmutils_h_
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 
35 #define _BCM_U	0x01
36 #define _BCM_L	0x02
37 #define _BCM_D	0x04
38 #define _BCM_C	0x08
39 #define _BCM_P	0x10
40 #define _BCM_S	0x20
41 #define _BCM_X	0x40
42 #define _BCM_SP	0x80
43 
44 extern const unsigned char bcm_ctype[];
45 #define bcm_ismask(x)	(bcm_ctype[(int)(unsigned char)(x)])
46 
47 #define bcm_isalnum(c)	((bcm_ismask(c)&(_BCM_U|_BCM_L|_BCM_D)) != 0)
48 #define bcm_isalpha(c)	((bcm_ismask(c)&(_BCM_U|_BCM_L)) != 0)
49 #define bcm_iscntrl(c)	((bcm_ismask(c)&(_BCM_C)) != 0)
50 #define bcm_isdigit(c)	((bcm_ismask(c)&(_BCM_D)) != 0)
51 #define bcm_isgraph(c)	((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D)) != 0)
52 #define bcm_islower(c)	((bcm_ismask(c)&(_BCM_L)) != 0)
53 #define bcm_isprint(c)	((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D|_BCM_SP)) != 0)
54 #define bcm_ispunct(c)	((bcm_ismask(c)&(_BCM_P)) != 0)
55 #define bcm_isspace(c)	((bcm_ismask(c)&(_BCM_S)) != 0)
56 #define bcm_isupper(c)	((bcm_ismask(c)&(_BCM_U)) != 0)
57 #define bcm_isxdigit(c)	((bcm_ismask(c)&(_BCM_D|_BCM_X)) != 0)
58 #define bcm_tolower(c)	(bcm_isupper((c)) ? ((c) + 'a' - 'A') : (c))
59 #define bcm_toupper(c)	(bcm_islower((c)) ? ((c) + 'A' - 'a') : (c))
60 
61 
62 
63 struct bcmstrbuf {
64 	char *buf;
65 	unsigned int size;
66 	char *origbuf;
67 	unsigned int origsize;
68 };
69 
70 
71 #ifdef BCMDRIVER
72 #include <osl.h>
73 
74 #define GPIO_PIN_NOTDEFINED 	0x20
75 
76 
77 #define SPINWAIT(exp, us) { \
78 	uint countdown = (us) + 9; \
79 	while ((exp) && (countdown >= 10)) {\
80 		OSL_DELAY(10); \
81 		countdown -= 10; \
82 	} \
83 }
84 
85 
86 
87 #ifndef PKTQ_LEN_DEFAULT
88 #define PKTQ_LEN_DEFAULT        128
89 #endif
90 #ifndef PKTQ_MAX_PREC
91 #define PKTQ_MAX_PREC           16
92 #endif
93 
94 typedef struct pktq_prec {
95 	void *head;
96 	void *tail;
97 	uint16 len;
98 	uint16 max;
99 } pktq_prec_t;
100 
101 
102 
103 struct pktq {
104 	uint16 num_prec;
105 	uint16 hi_prec;
106 	uint16 max;
107 	uint16 len;
108 
109 	struct pktq_prec q[PKTQ_MAX_PREC];
110 };
111 
112 
113 struct spktq {
114 	uint16 num_prec;
115 	uint16 hi_prec;
116 	uint16 max;
117 	uint16 len;
118 
119 	struct pktq_prec q[1];
120 };
121 
122 #define PKTQ_PREC_ITER(pq, prec)        for (prec = (pq)->num_prec - 1; prec >= 0; prec--)
123 
124 
125 
126 
127 struct ether_addr;
128 
129 extern int ether_isbcast(const void *ea);
130 extern int ether_isnulladdr(const void *ea);
131 
132 
133 
134 #define pktq_psetmax(pq, prec, _max)    ((pq)->q[prec].max = (_max))
135 #define pktq_plen(pq, prec)             ((pq)->q[prec].len)
136 #define pktq_pavail(pq, prec)           ((pq)->q[prec].max - (pq)->q[prec].len)
137 #define pktq_pfull(pq, prec)            ((pq)->q[prec].len >= (pq)->q[prec].max)
138 #define pktq_pempty(pq, prec)           ((pq)->q[prec].len == 0)
139 
140 #define pktq_ppeek(pq, prec)            ((pq)->q[prec].head)
141 #define pktq_ppeek_tail(pq, prec)       ((pq)->q[prec].tail)
142 
143 extern void *pktq_penq(struct pktq *pq, int prec, void *p);
144 extern void *pktq_penq_head(struct pktq *pq, int prec, void *p);
145 extern void *pktq_pdeq(struct pktq *pq, int prec);
146 extern void *pktq_pdeq_tail(struct pktq *pq, int prec);
147 
148 extern bool pktq_pdel(struct pktq *pq, void *p, int prec);
149 
150 
151 extern void pktq_pflush(osl_t *osh, struct pktq *pq, int prec, bool dir);
152 
153 extern void pktq_flush(osl_t *osh, struct pktq *pq, bool dir);
154 
155 
156 
157 extern int pktq_mlen(struct pktq *pq, uint prec_bmp);
158 extern void *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out);
159 
160 
161 
162 #define pktq_len(pq)                    ((int)(pq)->len)
163 #define pktq_max(pq)                    ((int)(pq)->max)
164 #define pktq_avail(pq)                  ((int)((pq)->max - (pq)->len))
165 #define pktq_full(pq)                   ((pq)->len >= (pq)->max)
166 #define pktq_empty(pq)                  ((pq)->len == 0)
167 
168 
169 #define pktenq(pq, p)		pktq_penq(((struct pktq *)pq), 0, (p))
170 #define pktenq_head(pq, p)	pktq_penq_head(((struct pktq *)pq), 0, (p))
171 #define pktdeq(pq)		pktq_pdeq(((struct pktq *)pq), 0)
172 #define pktdeq_tail(pq)		pktq_pdeq_tail(((struct pktq *)pq), 0)
173 #define pktqinit(pq, len) pktq_init(((struct pktq *)pq), 1, len)
174 
175 extern void pktq_init(struct pktq *pq, int num_prec, int max_len);
176 
177 extern void *pktq_deq(struct pktq *pq, int *prec_out);
178 extern void *pktq_deq_tail(struct pktq *pq, int *prec_out);
179 extern void *pktq_peek(struct pktq *pq, int *prec_out);
180 extern void *pktq_peek_tail(struct pktq *pq, int *prec_out);
181 
182 
183 
184 extern uint pktcopy(osl_t *osh, void *p, uint offset, int len, uchar *buf);
185 extern uint pktfrombuf(osl_t *osh, void *p, uint offset, int len, uchar *buf);
186 extern uint pkttotlen(osl_t *osh, void *p);
187 extern void *pktlast(osl_t *osh, void *p);
188 extern uint pktsegcnt(osl_t *osh, void *p);
189 
190 
191 extern uint pktsetprio(void *pkt, bool update_vtag);
192 #define	PKTPRIO_VDSCP	0x100
193 #define	PKTPRIO_VLAN	0x200
194 #define	PKTPRIO_UPD	0x400
195 #define	PKTPRIO_DSCP	0x800
196 
197 
198 extern int bcm_atoi(char *s);
199 extern ulong bcm_strtoul(char *cp, char **endp, uint base);
200 extern char *bcmstrstr(char *haystack, char *needle);
201 extern char *bcmstrcat(char *dest, const char *src);
202 extern char *bcmstrncat(char *dest, const char *src, uint size);
203 extern ulong wchar2ascii(char *abuf, ushort *wbuf, ushort wbuflen, ulong abuflen);
204 char* bcmstrtok(char **string, const char *delimiters, char *tokdelim);
205 int bcmstricmp(const char *s1, const char *s2);
206 int bcmstrnicmp(const char* s1, const char* s2, int cnt);
207 
208 
209 
210 extern char *bcm_ether_ntoa(const struct ether_addr *ea, char *buf);
211 extern int bcm_ether_atoe(char *p, struct ether_addr *ea);
212 
213 
214 struct ipv4_addr;
215 extern char *bcm_ip_ntoa(struct ipv4_addr *ia, char *buf);
216 
217 
218 extern void bcm_mdelay(uint ms);
219 
220 extern char *getvar(char *vars, const char *name);
221 extern int getintvar(char *vars, const char *name);
222 extern uint getgpiopin(char *vars, char *pin_name, uint def_pin);
223 #define bcm_perf_enable()
224 #define bcmstats(fmt)
225 #define	bcmlog(fmt, a1, a2)
226 #define	bcmdumplog(buf, size)	*buf = '\0'
227 #define	bcmdumplogent(buf, idx)	-1
228 
229 #define bcmtslog(tstamp, fmt, a1, a2)
230 #define bcmprinttslogs()
231 #define bcmprinttstamp(us)
232 
233 
234 
235 
236 typedef struct bcm_iovar {
237 	const char *name;
238 	uint16 varid;
239 	uint16 flags;
240 	uint16 type;
241 	uint16 minlen;
242 } bcm_iovar_t;
243 
244 
245 
246 
247 #define IOV_GET 0
248 #define IOV_SET 1
249 
250 
251 #define IOV_GVAL(id)		((id)*2)
252 #define IOV_SVAL(id)		(((id)*2)+IOV_SET)
253 #define IOV_ISSET(actionid)	((actionid & IOV_SET) == IOV_SET)
254 
255 
256 
257 extern const bcm_iovar_t *bcm_iovar_lookup(const bcm_iovar_t *table, const char *name);
258 extern int bcm_iovar_lencheck(const bcm_iovar_t *table, void *arg, int len, bool set);
259 
260 #endif
261 
262 
263 #define IOVT_VOID	0
264 #define IOVT_BOOL	1
265 #define IOVT_INT8	2
266 #define IOVT_UINT8	3
267 #define IOVT_INT16	4
268 #define IOVT_UINT16	5
269 #define IOVT_INT32	6
270 #define IOVT_UINT32	7
271 #define IOVT_BUFFER	8
272 #define BCM_IOVT_VALID(type) (((unsigned int)(type)) <= IOVT_BUFFER)
273 
274 
275 #define BCM_IOV_TYPE_INIT { \
276 	"void", \
277 	"bool", \
278 	"int8", \
279 	"uint8", \
280 	"int16", \
281 	"uint16", \
282 	"int32", \
283 	"uint32", \
284 	"buffer", \
285 	"" }
286 
287 #define BCM_IOVT_IS_INT(type) (\
288 	(type == IOVT_BOOL) || \
289 	(type == IOVT_INT8) || \
290 	(type == IOVT_UINT8) || \
291 	(type == IOVT_INT16) || \
292 	(type == IOVT_UINT16) || \
293 	(type == IOVT_INT32) || \
294 	(type == IOVT_UINT32))
295 
296 
297 
298 #define BCME_STRLEN 		64
299 #define VALID_BCMERROR(e)  ((e <= 0) && (e >= BCME_LAST))
300 
301 
302 
303 
304 #define BCME_OK				0
305 #define BCME_ERROR			-1
306 #define BCME_BADARG			-2
307 #define BCME_BADOPTION			-3
308 #define BCME_NOTUP			-4
309 #define BCME_NOTDOWN			-5
310 #define BCME_NOTAP			-6
311 #define BCME_NOTSTA			-7
312 #define BCME_BADKEYIDX			-8
313 #define BCME_RADIOOFF 			-9
314 #define BCME_NOTBANDLOCKED		-10
315 #define BCME_NOCLK			-11
316 #define BCME_BADRATESET			-12
317 #define BCME_BADBAND			-13
318 #define BCME_BUFTOOSHORT		-14
319 #define BCME_BUFTOOLONG			-15
320 #define BCME_BUSY			-16
321 #define BCME_NOTASSOCIATED		-17
322 #define BCME_BADSSIDLEN			-18
323 #define BCME_OUTOFRANGECHAN		-19
324 #define BCME_BADCHAN			-20
325 #define BCME_BADADDR			-21
326 #define BCME_NORESOURCE			-22
327 #define BCME_UNSUPPORTED		-23
328 #define BCME_BADLEN			-24
329 #define BCME_NOTREADY			-25
330 #define BCME_EPERM			-26
331 #define BCME_NOMEM			-27
332 #define BCME_ASSOCIATED			-28
333 #define BCME_RANGE			-29
334 #define BCME_NOTFOUND			-30
335 #define BCME_WME_NOT_ENABLED		-31
336 #define BCME_TSPEC_NOTFOUND		-32
337 #define BCME_ACM_NOTSUPPORTED		-33
338 #define BCME_NOT_WME_ASSOCIATION	-34
339 #define BCME_SDIO_ERROR			-35
340 #define BCME_DONGLE_DOWN		-36
341 #define BCME_VERSION			-37
342 #define BCME_UNFINISHED			-38
343 #define BCME_LAST			BCME_UNFINISHED
344 
345 
346 #define BCMERRSTRINGTABLE {		\
347 	"OK",				\
348 	"Undefined error",		\
349 	"Bad Argument",			\
350 	"Bad Option",			\
351 	"Not up",			\
352 	"Not down",			\
353 	"Not AP",			\
354 	"Not STA",			\
355 	"Bad Key Index",		\
356 	"Radio Off",			\
357 	"Not band locked",		\
358 	"No clock",			\
359 	"Bad Rate valueset",		\
360 	"Bad Band",			\
361 	"Buffer too short",		\
362 	"Buffer too long",		\
363 	"Busy",				\
364 	"Not Associated",		\
365 	"Bad SSID len",			\
366 	"Out of Range Channel",		\
367 	"Bad Channel",			\
368 	"Bad Address",			\
369 	"Not Enough Resources",		\
370 	"Unsupported",			\
371 	"Bad length",			\
372 	"Not Ready",			\
373 	"Not Permitted",		\
374 	"No Memory",			\
375 	"Associated",			\
376 	"Not In Range",			\
377 	"Not Found",			\
378 	"WME Not Enabled",		\
379 	"TSPEC Not Found",		\
380 	"ACM Not Supported",		\
381 	"Not WME Association",		\
382 	"SDIO Bus Error",		\
383 	"Dongle Not Accessible",	\
384 	"Incorrect version",	\
385 	"Command not finished"	\
386 }
387 
388 #ifndef ABS
389 #define	ABS(a)			(((a) < 0)?-(a):(a))
390 #endif
391 
392 #ifndef MIN
393 #define	MIN(a, b)		(((a) < (b))?(a):(b))
394 #endif
395 
396 #ifndef MAX
397 #define	MAX(a, b)		(((a) > (b))?(a):(b))
398 #endif
399 
400 #define CEIL(x, y)		(((x) + ((y)-1)) / (y))
401 #define	ROUNDUP(x, y)		((((x)+((y)-1))/(y))*(y))
402 #define	ISALIGNED(a, x)		(((a) & ((x)-1)) == 0)
403 #define ALIGN_ADDR(addr, boundary) (void *)(((uintptr)(addr) + (boundary) - 1) \
404 	                                         & ~((boundary) - 1))
405 #define	ISPOWEROF2(x)		((((x)-1)&(x)) == 0)
406 #define VALID_MASK(mask)	!((mask) & ((mask) + 1))
407 #ifndef OFFSETOF
408 #define	OFFSETOF(type, member)	((uint)(uintptr)&((type *)0)->member)
409 #endif
410 #ifndef ARRAYSIZE
411 #define ARRAYSIZE(a)		(sizeof(a)/sizeof(a[0]))
412 #endif
413 
414 
415 #ifndef setbit
416 #ifndef NBBY
417 #define	NBBY	8
418 #endif
419 #define	setbit(a, i)	(((uint8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY))
420 #define	clrbit(a, i)	(((uint8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
421 #define	isset(a, i)	(((const uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY)))
422 #define	isclr(a, i)	((((const uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
423 #endif
424 
425 #define	NBITS(type)	(sizeof(type) * 8)
426 #define NBITVAL(nbits)	(1 << (nbits))
427 #define MAXBITVAL(nbits)	((1 << (nbits)) - 1)
428 #define	NBITMASK(nbits)	MAXBITVAL(nbits)
429 #define MAXNBVAL(nbyte)	MAXBITVAL((nbyte) * 8)
430 
431 
432 #define MUX(pred, true, false) ((pred) ? (true) : (false))
433 
434 
435 #define MODDEC(x, bound) MUX((x) == 0, (bound) - 1, (x) - 1)
436 #define MODINC(x, bound) MUX((x) == (bound) - 1, 0, (x) + 1)
437 
438 
439 #define MODDEC_POW2(x, bound) (((x) - 1) & ((bound) - 1))
440 #define MODINC_POW2(x, bound) (((x) + 1) & ((bound) - 1))
441 
442 
443 #define MODADD(x, y, bound) \
444     MUX((x) + (y) >= (bound), (x) + (y) - (bound), (x) + (y))
445 #define MODSUB(x, y, bound) \
446     MUX(((int)(x)) - ((int)(y)) < 0, (x) - (y) + (bound), (x) - (y))
447 
448 
449 #define MODADD_POW2(x, y, bound) (((x) + (y)) & ((bound) - 1))
450 #define MODSUB_POW2(x, y, bound) (((x) - (y)) & ((bound) - 1))
451 
452 
453 #define CRC8_INIT_VALUE  0xff
454 #define CRC8_GOOD_VALUE  0x9f
455 #define CRC16_INIT_VALUE 0xffff
456 #define CRC16_GOOD_VALUE 0xf0b8
457 #define CRC32_INIT_VALUE 0xffffffff
458 #define CRC32_GOOD_VALUE 0xdebb20e3
459 
460 
461 typedef struct bcm_bit_desc {
462 	uint32	bit;
463 	const char* name;
464 } bcm_bit_desc_t;
465 
466 
467 typedef struct bcm_tlv {
468 	uint8	id;
469 	uint8	len;
470 	uint8	data[1];
471 } bcm_tlv_t;
472 
473 
474 #define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && (int)(buflen) >= (int)(2 + (elt)->len))
475 
476 
477 #define ETHER_ADDR_STR_LEN	18
478 
479 
480 #ifdef IL_BIGENDIAN
481 static INLINE uint32
load32_ua(uint8 * a)482 load32_ua(uint8 *a)
483 {
484 	return ((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]);
485 }
486 
487 static INLINE void
store32_ua(uint8 * a,uint32 v)488 store32_ua(uint8 *a, uint32 v)
489 {
490 	a[0] = (v >> 24) & 0xff;
491 	a[1] = (v >> 16) & 0xff;
492 	a[2] = (v >> 8) & 0xff;
493 	a[3] = v & 0xff;
494 }
495 
496 static INLINE uint16
load16_ua(uint8 * a)497 load16_ua(uint8 *a)
498 {
499 	return ((a[0] << 8) | a[1]);
500 }
501 
502 static INLINE void
store16_ua(uint8 * a,uint16 v)503 store16_ua(uint8 *a, uint16 v)
504 {
505 	a[0] = (v >> 8) & 0xff;
506 	a[1] = v & 0xff;
507 }
508 
509 #else
510 
511 static INLINE uint32
load32_ua(uint8 * a)512 load32_ua(uint8 *a)
513 {
514 	return ((a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0]);
515 }
516 
517 static INLINE void
store32_ua(uint8 * a,uint32 v)518 store32_ua(uint8 *a, uint32 v)
519 {
520 	a[3] = (v >> 24) & 0xff;
521 	a[2] = (v >> 16) & 0xff;
522 	a[1] = (v >> 8) & 0xff;
523 	a[0] = v & 0xff;
524 }
525 
526 static INLINE uint16
load16_ua(uint8 * a)527 load16_ua(uint8 *a)
528 {
529 	return ((a[1] << 8) | a[0]);
530 }
531 
532 static INLINE void
store16_ua(uint8 * a,uint16 v)533 store16_ua(uint8 *a, uint16 v)
534 {
535 	a[1] = (v >> 8) & 0xff;
536 	a[0] = v & 0xff;
537 }
538 
539 #endif
540 
541 
542 
543 static INLINE void
xor_128bit_block(const uint8 * src1,const uint8 * src2,uint8 * dst)544 xor_128bit_block(const uint8 *src1, const uint8 *src2, uint8 *dst)
545 {
546 	if (
547 #ifdef __i386__
548 	    1 ||
549 #endif
550 	    (((uintptr)src1 | (uintptr)src2 | (uintptr)dst) & 3) == 0) {
551 
552 
553 		((uint32 *)dst)[0] = ((uint32 *)src1)[0] ^ ((uint32 *)src2)[0];
554 		((uint32 *)dst)[1] = ((uint32 *)src1)[1] ^ ((uint32 *)src2)[1];
555 		((uint32 *)dst)[2] = ((uint32 *)src1)[2] ^ ((uint32 *)src2)[2];
556 		((uint32 *)dst)[3] = ((uint32 *)src1)[3] ^ ((uint32 *)src2)[3];
557 	} else {
558 
559 		int k;
560 		for (k = 0; k < 16; k++)
561 			dst[k] = src1[k] ^ src2[k];
562 	}
563 }
564 
565 
566 
567 extern uint8 hndcrc8(uint8 *p, uint nbytes, uint8 crc);
568 extern uint16 hndcrc16(uint8 *p, uint nbytes, uint16 crc);
569 extern uint32 hndcrc32(uint8 *p, uint nbytes, uint32 crc);
570 
571 #if defined(DHD_DEBUG) || defined(WLMSG_PRHDRS) || defined(WLMSG_PRPKT) || \
572 	defined(WLMSG_ASSOC)
573 extern int bcm_format_flags(const bcm_bit_desc_t *bd, uint32 flags, char* buf, int len);
574 extern int bcm_format_hex(char *str, const void *bytes, int len);
575 extern void prhex(const char *msg, uchar *buf, uint len);
576 #endif
577 extern char *bcm_brev_str(uint32 brev, char *buf);
578 extern void printbig(char *buf);
579 
580 
581 extern bcm_tlv_t *bcm_next_tlv(bcm_tlv_t *elt, int *buflen);
582 extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, uint key);
583 extern bcm_tlv_t *bcm_parse_ordered_tlvs(void *buf, int buflen, uint key);
584 
585 
586 extern const char *bcmerrorstr(int bcmerror);
587 
588 
589 typedef uint32 mbool;
590 #define mboolset(mb, bit)		((mb) |= (bit))
591 #define mboolclr(mb, bit)		((mb) &= ~(bit))
592 #define mboolisset(mb, bit)		(((mb) & (bit)) != 0)
593 #define	mboolmaskset(mb, mask, val)	((mb) = (((mb) & ~(mask)) | (val)))
594 
595 
596 extern uint16 bcm_qdbm_to_mw(uint8 qdbm);
597 extern uint8 bcm_mw_to_qdbm(uint16 mw);
598 
599 
600 struct fielddesc {
601 	const char *nameandfmt;
602 	uint32 	offset;
603 	uint32 	len;
604 };
605 
606 extern void bcm_binit(struct bcmstrbuf *b, char *buf, uint size);
607 extern int bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...);
608 extern void bcm_inc_bytes(uchar *num, int num_bytes, uint8 amount);
609 extern int bcm_cmp_bytes(uchar *arg1, uchar *arg2, uint8 nbytes);
610 extern void bcm_print_bytes(char *name, const uchar *cdata, int len);
611 
612 typedef  uint32 (*bcmutl_rdreg_rtn)(void *arg0, uint arg1, uint32 offset);
613 extern uint bcmdumpfields(bcmutl_rdreg_rtn func_ptr, void *arg0, uint arg1, struct fielddesc *str,
614                           char *buf, uint32 bufsize);
615 
616 extern uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint len);
617 extern uint bcm_bitcount(uint8 *bitmap, uint bytelength);
618 
619 #if defined(WLTINYDUMP) || defined(WLMSG_INFORM) || defined(WLMSG_ASSOC) || \
620 	defined(WLMSG_PRPKT) || defined(WLMSG_WSEC)
621 extern int bcm_format_ssid(char* buf, const uchar ssid[], uint ssid_len);
622 #endif
623 
624 
625 #define SSID_FMT_BUF_LEN	((4 * DOT11_MAX_SSID_LEN) + 1)
626 
627 #ifdef __cplusplus
628 	}
629 #endif
630 
631 #endif
632