diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-05-18 02:42:43 +0200 |
---|---|---|
committer | Arnon Gilboa <agilboa@redhat.com> | 2013-05-19 09:19:57 +0300 |
commit | 50d15c7427b43c39c640803c620d5321cf38efd5 (patch) | |
tree | 9a1aa39726da49480ddcfdbbff3c672d9dff2bf3 /usbredirfilter.h | |
parent | 816c408490b3cc82503509aa62c49212fcc2d86c (diff) |
Move Visual C files to VC dir
Diffstat (limited to 'usbredirfilter.h')
-rw-r--r-- | usbredirfilter.h | 127 |
1 files changed, 0 insertions, 127 deletions
diff --git a/usbredirfilter.h b/usbredirfilter.h deleted file mode 100644 index 9574d56..0000000 --- a/usbredirfilter.h +++ /dev/null @@ -1,127 +0,0 @@ -/* usbredirfilter.h usb redirection filter header - - Copyright 2012 Red Hat, Inc. - - Red Hat Authors: - Hans de Goede <hdegoede@redhat.com> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see <http://www.gnu.org/licenses/>. -*/ -#ifndef __USBREDIRFILTER_H -#define __USBREDIRFILTER_H - -#include <stdio.h> - -#pragma warning(disable : 4996)
-#include "stdint.h" - -struct usbredirfilter_rule { - int device_class; /* 0-255, -1 to match any class */ - int vendor_id; /* 0-65535, -1 to match any id */ - int product_id; /* 0-65535, -1 to match any id */ - int device_version_bcd; /* 0-255, -1 to match any version */ - int allow; /* 0: deny redir for this device, non 0: allow */ -}; - -/* Read a filter string and parse it into an array of usbredirfilter_rule-s. - - Where each rule has the form of: - <class>,<vendor>,<product>,<version>,<allow> - Assuming "," as the specified token_sep character. - - And the rules are themselves are separated by the rule_sep character, ie: - <rule1>|<rule2>|<rule3> - - Assuming "|" as the rule_sep character. Note that with the seperator used - in this example the format matches the format as written by the RHEV-M USB - filter editor tool. - - Note that the seperators must be single character strings! - - On success the rules get returned in rules_ret and rules_count_ret, the - returned rules array should be freed with free() when the caller is done - with it. - - Return value: 0 on success, -ENOMEM when allocating the rules array fails, - or -EINVAL when there is on parsing error. -*/ -int usbredirfilter_string_to_rules( - const char *filter_str, const char *token_sep, const char *rule_sep, - struct usbredirfilter_rule **rules_ret, int *rules_count_ret); - -/* Convert a set of rules back to a string suitable for passing to - usbredirfilter_string_to_rules(); The returned string must be free()-ed - by the caller when it is done with it. - - Return value: The string on sucess, or NULL if the rules fail verification, - or when allocating the string fails. -*/ -char *usbredirfilter_rules_to_string(const struct usbredirfilter_rule *rules, - int rules_count, const char *token_sep, const char *rule_sep); - -/* Check if redirection of a device with the passed in device info is allowed - by the passed set of filter rules. - - Since a device has class info at both the device level and the interface - level, this function does multiple passes. - - First the rules are checked one by one against the given device info using - the device class info, if a matching rule is found, the result of the check - is that of that rule. If the result is deny, -EPERM will be returned. - - Then the same is done substituting the device class info with the class info - from the interfaces. If any of the interfaces class checks result in a deny, - then -EPERM will be returned. - - Note that under certain circumstances some passes are skipped: - - For devices with a device class of 0x00 or 0xef, the pass which checks the - device class is skipped. - - If the usbredirfilter_fl_dont_skip_non_boot_hid flag is not passed then - for devices with more then 1 interface and an interface with an interface - class of 0x03, an interface subclass of 0x00 and an interface protocol - of 0x00. the check is skipped for that interface. This allows to skip ie - checking the interface for volume buttons one some usbaudio class devices. - - If the result of all (not skipped) passes is allow, then 0 will be returned, - which indicates that redirection should be allowed. - - If a given pass does not match any rules the result of that pass will be - deny. This behavior can be changed with the usbredirfilter_fl_default_allow - flag, if this flas is set the result on no matching rules will be allow. - - Return value: 0 when redirection is allowed, -EINVAL for invalid parameters, - -EPERM when redirection is blocked by the filter rules. -*/ -enum { - usbredirfilter_fl_default_allow = 0x01, - usbredirfilter_fl_dont_skip_non_boot_hid = 0x02, -}; -int usbredirfilter_check( - const struct usbredirfilter_rule *rules, int rules_count, - uint8_t device_class, uint8_t device_subclass, uint8_t device_protocol, - uint8_t *interface_class, uint8_t *interface_subclass, - uint8_t *interface_protocol, int interface_count, - uint16_t vendor_id, uint16_t product_id, uint16_t device_version_bcd, - int flags); - -/* Sanity check the passed in rules - - Return value: 0 on success, -EINVAL when some values are out of bound. */ -int usbredirfilter_verify( - const struct usbredirfilter_rule *rules, int rules_count); - -/* Print the passed in rules to FILE out in human readable format */ -void usbredirfilter_print( - const struct usbredirfilter_rule *rules, int rules_count, FILE *out); -#endif |