FreeBSD/sys/dev/hyperv/netvsc/hv_rndis_filter.c
/*
 * RNDIS filter set packet filter
 * Sends an rndis request with the new filter, then waits for a response
 * from the host.
 * Returns zero on success, non-zero on failure.
 */
RNDIS filter set packet filter
Sends an rndis request with the new filter, then waits for a response
from the host.
Returns zero on success, non-zero on failure.
RNDIS filter set packet filter Sends an rndis request with the new filter then waits for a response from the host . Returns zero on success non - zero on failure .
static int
hv_rf_set_packet_filter(rndis_device *device, uint32_t new_filter)
{
	rndis_request *request;
	rndis_set_request *set;
	rndis_set_complete *set_complete;
	uint32_t status;
	int ret;
	request = hv_rndis_request(device, REMOTE_NDIS_SET_MSG,
	    RNDIS_MESSAGE_SIZE(rndis_set_request) + sizeof(uint32_t));
	if (request == NULL) {
		ret = -1;
		goto cleanup;
	}
	set = &request->request_msg.msg.set_request;
	set->oid = RNDIS_OID_GEN_CURRENT_PACKET_FILTER;
	set->info_buffer_length = sizeof(uint32_t);
	set->info_buffer_offset = sizeof(rndis_set_request); 
	memcpy((void *)((unsigned long)set + sizeof(rndis_set_request)),
	    &new_filter, sizeof(uint32_t));
	ret = hv_rf_send_request(device, request, REMOTE_NDIS_SET_MSG);
	if (ret != 0) {
		goto cleanup;
	}
	ret = sema_timedwait(&request->wait_sema, 5 * hz);
	if (ret == 0) {
		set_complete = &request->response_msg.msg.set_complete;
		status = set_complete->status;
		if (status != RNDIS_STATUS_SUCCESS) {
			ret = -2;
		}
	} else {
		goto exit;
	}
cleanup:
	if (request != NULL) {
		hv_put_rndis_request(device, request);
	}
exit:
	return (ret);
}
static int hv_rf_set_packet_filter ( rndis_device * device , uint32_t new_filter ) { rndis_request * request ; rndis_set_request * set ; rndis_set_complete * set_complete ; uint32_t status ; int ret ; request = hv_rndis_request ( device , REMOTE_NDIS_SET_MSG , RNDIS_MESSAGE_SIZE ( rndis_set_request ) + sizeof ( uint32_t ) ) ; if ( request == NULL ) { ret = -1 ; goto cleanup ; } set = & request -> request_msg . msg . set_request ; set -> oid = RNDIS_OID_GEN_CURRENT_PACKET_FILTER ; set -> info_buffer_length = sizeof ( uint32_t ) ; set -> info_buffer_offset = sizeof ( rndis_set_request ) ; memcpy ( ( void * ) ( ( unsigned long ) set + sizeof ( rndis_set_request ) ) , & new_filter , sizeof ( uint32_t ) ) ; ret = hv_rf_send_request ( device , request , REMOTE_NDIS_SET_MSG ) ; if ( ret != 0 ) { goto cleanup ; } ret = sema_timedwait ( & request -> wait_sema , 5 * hz ) ; if ( ret == 0 ) { set_complete = & request -> response_msg . msg . set_complete ; status = set_complete -> status ; if ( status != RNDIS_STATUS_SUCCESS ) { ret = -2 ; } } else { goto exit ; } cleanup : if ( request != NULL ) { hv_put_rndis_request ( device , request ) ; } exit : return ( ret ) ; }
RNDIS filter set packet filter
 Sends an rndis request with the new filter, then waits for a response
 from the host.
RNDIS filter set packet filter Sends an rndis request with the new filter then waits for a response from the host .
/* Set up the rndis set */ /*
	 * Wait for the response from the host.  Another thread will signal
	 * us when the response has arrived.  In the failure case,
	 * sema_timedwait() returns a non-zero status after waiting 5 seconds.
	 */ /* Response received, check status */ /* Bad response status, return error */ /*
		 * We cannot deallocate the request since we may still
		 * receive a send completion for it.
		 */