extractedLnx/linux-2.6.7/drivers/usb/gadget/rndis.c_gen_ndis_query_resp.c
static int gen_ndis_query_resp (int configNr, u32 OID, rndis_resp_t *r)
{
int retval = -ENOTSUPP;
u32 length = 0;
rndis_query_cmplt_type *resp;
if (!r) return -ENOMEM;
resp = (rndis_query_cmplt_type *) r->buf;
if (!resp) return -ENOMEM;
switch (OID) {
/* mandatory */
case OID_GEN_SUPPORTED_LIST:
DEBUG ("%s: OID_GEN_SUPPORTED_LIST\n", __FUNCTION__);
length = sizeof (oid_supported_list);
memcpy ((u8 *) resp + 24, oid_supported_list, length);
retval = 0;
break;
/* mandatory */
case OID_GEN_HARDWARE_STATUS:
DEBUG("%s: OID_GEN_HARDWARE_STATUS\n", __FUNCTION__);
length = 4;
/* Bogus question!
* Hardware must be ready to recieve high level protocols.
* BTW:
* reddite ergo quae sunt Caesaris Caesari
* et quae sunt Dei Deo!
*/
*((u32 *) resp + 6) = 0;
retval = 0;
break;
/* mandatory */
case OID_GEN_MEDIA_SUPPORTED:
DEBUG("%s: OID_GEN_MEDIA_SUPPORTED\n", __FUNCTION__);
length = 4;
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].medium;
retval = 0;
break;
/* mandatory */
case OID_GEN_MEDIA_IN_USE:
DEBUG("%s: OID_GEN_MEDIA_IN_USE\n", __FUNCTION__);
length = 4;
/* one medium, one transport... (maybe you do it better) */
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].medium;
retval = 0;
break;
case OID_GEN_MAXIMUM_LOOKAHEAD:
DEBUG("%s: OID_GEN_MAXIMUM_LOOKAHEAD\n", __FUNCTION__);
break;
/* mandatory */
case OID_GEN_MAXIMUM_FRAME_SIZE:
DEBUG("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].dev) {
length = 4;
*((u32 *) resp + 6) = rndis_per_dev_params [configNr]
.dev->mtu;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
/* mandatory */
case OID_GEN_LINK_SPEED:
DEBUG("%s: OID_GEN_LINK_SPEED\n", __FUNCTION__);
length = 4;
if (rndis_per_dev_params [configNr].media_state
== NDIS_MEDIA_STATE_DISCONNECTED)
*((u32 *) resp + 6) = 0;
else
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].speed;
retval = 0;
break;
case OID_GEN_TRANSMIT_BUFFER_SPACE:
DEBUG("%s: OID_GEN_TRANSMIT_BUFFER_SPACE\n", __FUNCTION__);
length = 4;
*((u32 *) resp + 6) = 0;
retval = 0;
break;
case OID_GEN_RECEIVE_BUFFER_SPACE:
DEBUG("%s: OID_GEN_RECEIVE_BUFFER_SPACE\n", __FUNCTION__);
break;
/* mandatory */
case OID_GEN_TRANSMIT_BLOCK_SIZE:
DEBUG("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].dev) {
length = 4;
*((u32 *) resp + 6) = rndis_per_dev_params [configNr]
.dev->mtu;
retval = 0;
}
break;
/* mandatory */
case OID_GEN_RECEIVE_BLOCK_SIZE:
DEBUG("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].dev) {
length = 4;
*((u32 *) resp + 6) = rndis_per_dev_params [configNr]
.dev->mtu;
retval = 0;
}
break;
/* mandatory */
case OID_GEN_VENDOR_ID:
DEBUG("%s: OID_GEN_VENDOR_ID\n", __FUNCTION__);
length = 4;
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].vendorID;
retval = 0;
break;
/* mandatory */
case OID_GEN_VENDOR_DESCRIPTION:
DEBUG("%s: OID_GEN_VENDOR_DESCRIPTION\n", __FUNCTION__);
length = strlen (rndis_per_dev_params [configNr].vendorDescr);
memcpy ((u8 *) resp + 24,
rndis_per_dev_params [configNr].vendorDescr, length);
retval = 0;
break;
/* mandatory */
case OID_GEN_CURRENT_PACKET_FILTER:
DEBUG("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __FUNCTION__);
length = 4;
*((u32 *) resp + 6) = rndis_per_dev_params[configNr].filter;
retval = 0;
break;
case OID_GEN_CURRENT_LOOKAHEAD:
DEBUG("%s: OID_GEN_CURRENT_LOOKAHEAD\n", __FUNCTION__);
break;
case OID_GEN_DRIVER_VERSION:
DEBUG("%s: OID_GEN_DRIVER_VERSION\n", __FUNCTION__);
break;
/* mandatory */
case OID_GEN_MAXIMUM_TOTAL_SIZE:
DEBUG("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __FUNCTION__);
length = 4;
*((u32 *) resp + 6) = RNDIS_MAX_TOTAL_SIZE;
retval = 0;
break;
case OID_GEN_PROTOCOL_OPTIONS:
DEBUG("%s: OID_GEN_PROTOCOL_OPTIONS\n", __FUNCTION__);
break;
case OID_GEN_MAC_OPTIONS:
DEBUG("%s: OID_GEN_MAC_OPTIONS\n", __FUNCTION__);
length = 4;
*((u32 *) resp + 6) = NDIS_MAC_OPTION_RECEIVE_SERIALIZED |
NDIS_MAC_OPTION_FULL_DUPLEX;
retval = 0;
break;
/* mandatory */
case OID_GEN_MEDIA_CONNECT_STATUS:
DEBUG("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __FUNCTION__);
length = 4;
*((u32 *) resp + 6) = rndis_per_dev_params [configNr]
.media_state;
retval = 0;
break;
case OID_GEN_MAXIMUM_SEND_PACKETS:
DEBUG("%s: OID_GEN_MAXIMUM_SEND_PACKETS\n", __FUNCTION__);
break;
/* mandatory */
case OID_GEN_VENDOR_DRIVER_VERSION:
DEBUG("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __FUNCTION__);
length = 4;
*((u32 *) resp + 6) = rndis_driver_version;
retval = 0;
break;
case OID_GEN_SUPPORTED_GUIDS:
DEBUG("%s: OID_GEN_SUPPORTED_GUIDS\n", __FUNCTION__);
break;
case OID_GEN_NETWORK_LAYER_ADDRESSES:
DEBUG("%s: OID_GEN_NETWORK_LAYER_ADDRESSES\n", __FUNCTION__);
break;
case OID_GEN_TRANSPORT_HEADER_OFFSET:
DEBUG("%s: OID_GEN_TRANSPORT_HEADER_OFFSET\n", __FUNCTION__);
break;
case OID_GEN_MACHINE_NAME:
DEBUG("%s: OID_GEN_MACHINE_NAME\n", __FUNCTION__);
break;
case OID_GEN_RNDIS_CONFIG_PARAMETER:
DEBUG("%s: OID_GEN_RNDIS_CONFIG_PARAMETER\n", __FUNCTION__);
length = 4;
*((u32 *) resp + 6) = 0;
retval = 0;
break;
case OID_GEN_VLAN_ID:
DEBUG("%s: OID_GEN_VLAN_ID\n", __FUNCTION__);
break;
case OID_GEN_MEDIA_CAPABILITIES:
DEBUG("%s: OID_GEN_MEDIA_CAPABILITIES\n", __FUNCTION__);
break;
case OID_GEN_PHYSICAL_MEDIUM:
DEBUG("%s: OID_GEN_PHYSICAL_MEDIUM\n", __FUNCTION__);
length = 4;
*((u32 *) resp + 6) = 0;
retval = 0;
break;
/* mandatory */
case OID_GEN_XMIT_OK:
DEBUG("%s: OID_GEN_XMIT_OK\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats) {
length = 4;
*((u32 *) resp + 6) = rndis_per_dev_params [configNr]
.stats->tx_packets -
rndis_per_dev_params [configNr].stats->tx_errors -
rndis_per_dev_params [configNr].stats->tx_dropped;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
/* mandatory */
case OID_GEN_RCV_OK:
DEBUG("%s: OID_GEN_RCV_OK\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats) {
length = 4;
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].
stats->rx_packets -
rndis_per_dev_params [configNr].stats->rx_errors -
rndis_per_dev_params [configNr].stats->rx_dropped;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
/* mandatory */
case OID_GEN_XMIT_ERROR:
DEBUG("%s: OID_GEN_XMIT_ERROR\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats) {
length = 4;
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].
stats->tx_errors;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
/* mandatory */
case OID_GEN_RCV_ERROR:
DEBUG("%s: OID_GEN_RCV_ERROR\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats) {
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].
stats->rx_errors;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
/* mandatory */
case OID_GEN_RCV_NO_BUFFER:
DEBUG("%s: OID_GEN_RCV_NO_BUFFER\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats) {
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].
stats->rx_dropped;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
case OID_GEN_DIRECTED_BYTES_XMIT:
DEBUG("%s: OID_GEN_DIRECTED_BYTES_XMIT\n", __FUNCTION__);
/*
* Aunt Tilly's size of shoes
* minus antarctica count of penguins
* divided by weight of Alpha Centauri
*/
if (rndis_per_dev_params [configNr].stats) {
length = 4;
*((u32 *) resp + 6) = (rndis_per_dev_params [configNr].
stats->tx_packets -
rndis_per_dev_params [configNr].stats->tx_errors -
rndis_per_dev_params [configNr].stats->tx_dropped)
*123;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
case OID_GEN_DIRECTED_FRAMES_XMIT:
DEBUG("%s: OID_GEN_DIRECTED_FRAMES_XMIT\n", __FUNCTION__);
/* dito */
if (rndis_per_dev_params [configNr].stats) {
length = 4;
*((u32 *) resp + 6) = (rndis_per_dev_params [configNr].
stats->tx_packets -
rndis_per_dev_params [configNr].stats->tx_errors -
rndis_per_dev_params [configNr].stats->tx_dropped)
/123;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
case OID_GEN_MULTICAST_BYTES_XMIT:
DEBUG("%s: OID_GEN_MULTICAST_BYTES_XMIT\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats) {
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].
stats->multicast*1234;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
case OID_GEN_MULTICAST_FRAMES_XMIT:
DEBUG("%s: OID_GEN_MULTICAST_FRAMES_XMIT\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats) {
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].
stats->multicast;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
case OID_GEN_BROADCAST_BYTES_XMIT:
DEBUG("%s: OID_GEN_BROADCAST_BYTES_XMIT\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats) {
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].
stats->tx_packets/42*255;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
case OID_GEN_BROADCAST_FRAMES_XMIT:
DEBUG("%s: OID_GEN_BROADCAST_FRAMES_XMIT\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats) {
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].
stats->tx_packets/42;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
case OID_GEN_DIRECTED_BYTES_RCV:
DEBUG("%s: OID_GEN_DIRECTED_BYTES_RCV\n", __FUNCTION__);
*((u32 *) resp + 6) = 0;
retval = 0;
break;
case OID_GEN_DIRECTED_FRAMES_RCV:
DEBUG("%s: OID_GEN_DIRECTED_FRAMES_RCV\n", __FUNCTION__);
*((u32 *) resp + 6) = 0;
retval = 0;
break;
case OID_GEN_MULTICAST_BYTES_RCV:
DEBUG("%s: OID_GEN_MULTICAST_BYTES_RCV\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats) {
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].
stats->multicast*1111;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
case OID_GEN_MULTICAST_FRAMES_RCV:
DEBUG("%s: OID_GEN_MULTICAST_FRAMES_RCV\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats) {
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].
stats->multicast;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
case OID_GEN_BROADCAST_BYTES_RCV:
DEBUG("%s: OID_GEN_BROADCAST_BYTES_RCV\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats) {
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].
stats->rx_packets/42*255;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
case OID_GEN_BROADCAST_FRAMES_RCV:
DEBUG("%s: OID_GEN_BROADCAST_FRAMES_RCV\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats) {
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].
stats->rx_packets/42;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
case OID_GEN_RCV_CRC_ERROR:
DEBUG("%s: OID_GEN_RCV_CRC_ERROR\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats) {
*((u32 *) resp + 6) = rndis_per_dev_params [configNr].
stats->rx_crc_errors;
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
case OID_GEN_TRANSMIT_QUEUE_LENGTH:
DEBUG("%s: OID_GEN_TRANSMIT_QUEUE_LENGTH\n", __FUNCTION__);
*((u32 *) resp + 6) = 0;
retval = 0;
break;
case OID_GEN_GET_TIME_CAPS:
DEBUG("%s: OID_GEN_GET_TIME_CAPS\n", __FUNCTION__);
break;
case OID_GEN_GET_NETCARD_TIME:
DEBUG("%s: OID_GEN_GET_NETCARD_TIME\n", __FUNCTION__);
break;
case OID_GEN_NETCARD_LOAD:
DEBUG("%s: OID_GEN_NETCARD_LOAD\n", __FUNCTION__);
break;
case OID_GEN_DEVICE_PROFILE:
DEBUG("%s: OID_GEN_DEVICE_PROFILE\n", __FUNCTION__);
break;
case OID_GEN_INIT_TIME_MS:
DEBUG("%s: OID_GEN_INIT_TIME_MS\n", __FUNCTION__);
break;
case OID_GEN_RESET_COUNTS:
DEBUG("%s: OID_GEN_RESET_COUNTS\n", __FUNCTION__);
break;
case OID_GEN_MEDIA_SENSE_COUNTS:
DEBUG("%s: OID_GEN_MEDIA_SENSE_COUNTS\n", __FUNCTION__);
break;
case OID_GEN_FRIENDLY_NAME:
DEBUG("%s: OID_GEN_FRIENDLY_NAME\n", __FUNCTION__);
break;
case OID_GEN_MINIPORT_INFO:
DEBUG("%s: OID_GEN_MINIPORT_INFO\n", __FUNCTION__);
break;
case OID_GEN_RESET_VERIFY_PARAMETERS:
DEBUG("%s: OID_GEN_RESET_VERIFY_PARAMETERS\n", __FUNCTION__);
break;
/* mandatory */
case OID_802_3_PERMANENT_ADDRESS:
DEBUG("%s: OID_802_3_PERMANENT_ADDRESS\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].dev) {
length = ETH_ALEN;
memcpy ((u8 *) resp + 24,
rndis_per_dev_params [configNr].host_mac,
length);
retval = 0;
} else {
*((u32 *) resp + 6) = 0;
retval = 0;
}
break;
/* mandatory */
case OID_802_3_CURRENT_ADDRESS:
DEBUG("%s: OID_802_3_CURRENT_ADDRESS\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].dev) {
length = ETH_ALEN;
memcpy ((u8 *) resp + 24,
rndis_per_dev_params [configNr].host_mac,
length);
retval = 0;
}
break;
/* mandatory */
case OID_802_3_MULTICAST_LIST:
DEBUG("%s: OID_802_3_MULTICAST_LIST\n", __FUNCTION__);
length = 4;
/* Multicast base address only */
*((u32 *) resp + 6) = 0xE0000000;
retval = 0;
break;
/* mandatory */
case OID_802_3_MAXIMUM_LIST_SIZE:
DEBUG("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __FUNCTION__);
length = 4;
/* Multicast base address only */
*((u32 *) resp + 6) = 1;
retval = 0;
break;
case OID_802_3_MAC_OPTIONS:
DEBUG("%s: OID_802_3_MAC_OPTIONS\n", __FUNCTION__);
break;
/* mandatory */
case OID_802_3_RCV_ERROR_ALIGNMENT:
DEBUG("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __FUNCTION__);
if (rndis_per_dev_params [configNr].stats)
{
length = 4;
*((u32 *) resp + 6) = rndis_per_dev_params [configNr]
.stats->rx_frame_errors;
retval = 0;
}
break;
/* mandatory */
case OID_802_3_XMIT_ONE_COLLISION:
DEBUG("%s: OID_802_3_XMIT_ONE_COLLISION\n", __FUNCTION__);
length = 4;
*((u32 *) resp + 6) = 0;
retval = 0;
break;
/* mandatory */
case OID_802_3_XMIT_MORE_COLLISIONS:
DEBUG("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __FUNCTION__);
length = 4;
*((u32 *) resp + 6) = 0;
retval = 0;
break;
case OID_802_3_XMIT_DEFERRED:
DEBUG("%s: OID_802_3_XMIT_DEFERRED\n", __FUNCTION__);
/* TODO */
break;
case OID_802_3_XMIT_MAX_COLLISIONS:
DEBUG("%s: OID_802_3_XMIT_MAX_COLLISIONS\n", __FUNCTION__);
/* TODO */
break;
case OID_802_3_RCV_OVERRUN:
DEBUG("%s: OID_802_3_RCV_OVERRUN\n", __FUNCTION__);
/* TODO */
break;
case OID_802_3_XMIT_UNDERRUN:
DEBUG("%s: OID_802_3_XMIT_UNDERRUN\n", __FUNCTION__);
/* TODO */
break;
case OID_802_3_XMIT_HEARTBEAT_FAILURE:
DEBUG("%s: OID_802_3_XMIT_HEARTBEAT_FAILURE\n", __FUNCTION__);
/* TODO */
break;
case OID_802_3_XMIT_TIMES_CRS_LOST:
DEBUG("%s: OID_802_3_XMIT_TIMES_CRS_LOST\n", __FUNCTION__);
/* TODO */
break;
case OID_802_3_XMIT_LATE_COLLISIONS:
DEBUG("%s: OID_802_3_XMIT_LATE_COLLISIONS\n", __FUNCTION__);
/* TODO */
break;
default: printk (KERN_ERR "%s: unknown OID 0x%08X\n",
__FUNCTION__, OID);
}
resp->InformationBufferOffset = 16;
resp->InformationBufferLength = length;
resp->MessageLength = 24 + length;
r->length = 24 + length;
return retval;
}
Generated by GNU enscript 1.6.4.