2 * Wireless network adapter utilities
4 * Copyright 2004, Broadcom Corporation
7 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
25 if ((ret
= wl_ioctl(name
, WLC_GET_MAGIC
, &val
, sizeof(val
))))
27 if (val
!= WLC_IOCTL_MAGIC
)
29 if ((ret
= wl_ioctl(name
, WLC_GET_VERSION
, &val
, sizeof(val
))))
31 if (val
> WLC_IOCTL_VERSION
)
38 wl_set_val(char *name
, char *var
, void *val
, int len
)
43 /* check for overflow */
44 if ((buf_len
= strlen(var
)) + 1 + len
> sizeof(buf
))
50 /* append int value onto the end of the name string */
51 memcpy(&buf
[buf_len
], val
, len
);
54 return wl_ioctl(name
, WLC_SET_VAR
, buf
, buf_len
);
58 wl_get_val(char *name
, char *var
, void *val
, int len
)
63 /* check for overflow */
64 if (strlen(var
) + 1 > sizeof(buf
) || len
> sizeof(buf
))
68 if ((ret
= wl_ioctl(name
, WLC_GET_VAR
, buf
, sizeof(buf
))))
71 memcpy(val
, buf
, len
);
76 wl_set_int(char *name
, char *var
, int val
)
78 return wl_set_val(name
, var
, &val
, sizeof(val
));
82 wl_get_int(char *name
, char *var
, int *val
)
84 return wl_get_val(name
, var
, val
, sizeof(*val
));
87 /**************************************************************************
88 * The following code is from Broadcom (wl.c) *
89 **************************************************************************/
92 wl_iovar_getbuf(char *ifname
, char *iovar
, void *param
,
93 int paramlen
, void *bufptr
, int buflen
)
99 namelen
= strlen(iovar
) + 1; /* length of iovar name plus null */
100 iolen
= namelen
+ paramlen
;
102 /* check for overflow */
106 memcpy(bufptr
, iovar
, namelen
); /* copy iovar name including null */
107 memcpy((int8
*)bufptr
+ namelen
, param
, paramlen
);
109 err
= wl_ioctl(ifname
, WLC_GET_VAR
, bufptr
, buflen
);
115 wl_iovar_setbuf(char *ifname
, char *iovar
, void *param
,
116 int paramlen
, void *bufptr
, int buflen
)
121 namelen
= strlen(iovar
) + 1; /* length of iovar name plus null */
122 iolen
= namelen
+ paramlen
;
124 /* check for overflow */
128 memcpy(bufptr
, iovar
, namelen
); /* copy iovar name including null */
129 memcpy((int8
*)bufptr
+ namelen
, param
, paramlen
);
131 return wl_ioctl(ifname
, WLC_SET_VAR
, bufptr
, iolen
);
135 wl_iovar_set(char *ifname
, char *iovar
, void *param
, int paramlen
)
137 char smbuf
[WLC_IOCTL_SMLEN
];
139 return wl_iovar_setbuf(ifname
, iovar
, param
, paramlen
, smbuf
, sizeof(smbuf
));
143 wl_iovar_get(char *ifname
, char *iovar
, void *bufptr
, int buflen
)
145 char smbuf
[WLC_IOCTL_SMLEN
];
148 /* use the return buffer if it is bigger than what we have on the stack */
149 if (buflen
> sizeof(smbuf
)) {
150 ret
= wl_iovar_getbuf(ifname
, iovar
, NULL
, 0, bufptr
, buflen
);
152 ret
= wl_iovar_getbuf(ifname
, iovar
, NULL
, 0, smbuf
, sizeof(smbuf
));
154 memcpy(bufptr
, smbuf
, buflen
);
161 * set named driver variable to int value
162 * calling example: wl_iovar_setint(ifname, "arate", rate)
165 wl_iovar_setint(char *ifname
, char *iovar
, int val
)
167 return wl_iovar_set(ifname
, iovar
, &val
, sizeof(val
));
171 * get named driver variable to int value and return error indication
172 * calling example: wl_iovar_getint(ifname, "arate", &rate)
175 wl_iovar_getint(char *ifname
, char *iovar
, int *val
)
177 return wl_iovar_get(ifname
, iovar
, val
, sizeof(int));
181 * format a bsscfg indexed iovar buffer
184 wl_bssiovar_mkbuf(char *iovar
, int bssidx
, void *param
,
185 int paramlen
, void *bufptr
, int buflen
, int *plen
)
187 char *prefix
= "bsscfg:";
193 prefixlen
= strlen(prefix
); /* length of bsscfg prefix */
194 namelen
= strlen(iovar
) + 1; /* length of iovar name + null */
195 iolen
= prefixlen
+ namelen
+ sizeof(int) + paramlen
;
197 /* check for overflow */
198 if (buflen
< 0 || iolen
> (uint
)buflen
) {
205 /* copy prefix, no null */
206 memcpy(p
, prefix
, prefixlen
);
209 /* copy iovar name including null */
210 memcpy(p
, iovar
, namelen
);
213 /* bss config index as first param */
214 memcpy(p
, &bssidx
, sizeof(int32
));
217 /* parameter buffer follows */
219 memcpy(p
, param
, paramlen
);
226 * set named & bss indexed driver variable to buffer value
229 wl_bssiovar_setbuf(char *ifname
, char *iovar
, int bssidx
, void *param
,
230 int paramlen
, void *bufptr
, int buflen
)
235 err
= wl_bssiovar_mkbuf(iovar
, bssidx
, param
, paramlen
, bufptr
, buflen
, &iolen
);
239 return wl_ioctl(ifname
, WLC_SET_VAR
, bufptr
, iolen
);
243 * get named & bss indexed driver variable buffer value
246 wl_bssiovar_getbuf(char *ifname
, char *iovar
, int bssidx
, void *param
,
247 int paramlen
, void *bufptr
, int buflen
)
252 err
= wl_bssiovar_mkbuf(iovar
, bssidx
, param
, paramlen
, bufptr
, buflen
, &iolen
);
256 return wl_ioctl(ifname
, WLC_GET_VAR
, bufptr
, buflen
);
260 * set named & bss indexed driver variable to buffer value
263 wl_bssiovar_set(char *ifname
, char *iovar
, int bssidx
, void *param
, int paramlen
)
265 char smbuf
[WLC_IOCTL_SMLEN
];
267 return wl_bssiovar_setbuf(ifname
, iovar
, bssidx
, param
, paramlen
, smbuf
, sizeof(smbuf
));
271 * get named & bss indexed driver variable buffer value
274 wl_bssiovar_get(char *ifname
, char *iovar
, int bssidx
, void *outbuf
, int len
)
276 char smbuf
[WLC_IOCTL_SMLEN
];
279 /* use the return buffer if it is bigger than what we have on the stack */
280 if (len
> (int)sizeof(smbuf
)) {
281 err
= wl_bssiovar_getbuf(ifname
, iovar
, bssidx
, NULL
, 0, outbuf
, len
);
283 memset(smbuf
, 0, sizeof(smbuf
));
284 err
= wl_bssiovar_getbuf(ifname
, iovar
, bssidx
, NULL
, 0, smbuf
, sizeof(smbuf
));
286 memcpy(outbuf
, smbuf
, len
);
293 * set named & bss indexed driver variable to int value
296 wl_bssiovar_setint(char *ifname
, char *iovar
, int bssidx
, int val
)
298 return wl_bssiovar_set(ifname
, iovar
, bssidx
, &val
, sizeof(int));
This page took 0.052141 seconds and 5 git commands to generate.