/* len: length of packet to be sent (in bytes)  */
static int API_dev_write(va_list ap)
/* len: length of packet to be sent (in bytes)  */
static int API_dev_write(va_list ap)
{
	struct device_info *di;
	void *buf;
	int *len;
	int err = 0;
	di = (struct device_info *)va_arg(ap, u_int32_t);
	if (di == NULL)
		return API_EINVAL;
	if (di->cookie == NULL)
		return API_ENODEV;
	buf = (void *)va_arg(ap, u_int32_t);
	if (buf == NULL)
		return API_EINVAL;
	len = (int *)va_arg(ap, u_int32_t);
	if (len == NULL)
		return API_EINVAL;
	if (*len <= 0)
		return API_EINVAL;
	if (di->type & DEV_TYP_STOR)
		return API_ENODEV;
	else if (di->type & DEV_TYP_NET)
		err = dev_write_net(di->cookie, buf, *len);
	else
		err = API_ENODEV;
	return err;
}