- added command line parameter for USB iInterface, use it to fool AusweisApp

- fixed population of event notification status
- dont initialize serial number, when given in input


git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@295 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
frankmorgner
2010-10-04 12:04:06 +00:00
parent 523ce83c7b
commit 35ce942354

View File

@@ -58,6 +58,8 @@ static int debug = 0;
static int dohid = 0; static int dohid = 0;
static int doint = 0; static int doint = 0;
static int doinfo = 0; static int doinfo = 0;
static const char *doserial = NULL;
static const char *doiintf = NULL;
static int usb_reader_num = -1; static int usb_reader_num = -1;
static const char *cdriver = NULL; static const char *cdriver = NULL;
@@ -65,6 +67,7 @@ static const char *cdriver = NULL;
#define OPT_INTERRUPT 'n' #define OPT_INTERRUPT 'n'
#define OPT_READER 'r' #define OPT_READER 'r'
#define OPT_SERIAL 's' #define OPT_SERIAL 's'
#define OPT_IINTERFACE 'i'
#define OPT_PRODUCT 'p' #define OPT_PRODUCT 'p'
#define OPT_VENDOR 'e' #define OPT_VENDOR 'e'
#define OPT_VERBOSE 'v' #define OPT_VERBOSE 'v'
@@ -77,6 +80,7 @@ static const struct option options[] = {
{ "reader", required_argument, NULL, OPT_READER }, { "reader", required_argument, NULL, OPT_READER },
{ "card-driver", required_argument, NULL, OPT_CARD }, { "card-driver", required_argument, NULL, OPT_CARD },
{ "serial", required_argument, NULL, OPT_SERIAL }, { "serial", required_argument, NULL, OPT_SERIAL },
{ "interface", required_argument, NULL, OPT_IINTERFACE },
{ "product", required_argument, NULL, OPT_PRODUCT }, { "product", required_argument, NULL, OPT_PRODUCT },
{ "vendor", required_argument, NULL, OPT_VENDOR }, { "vendor", required_argument, NULL, OPT_VENDOR },
{ "interrupt", no_argument, NULL, OPT_INTERRUPT }, { "interrupt", no_argument, NULL, OPT_INTERRUPT },
@@ -87,11 +91,12 @@ static const struct option options[] = {
static const char *option_help[] = { static const char *option_help[] = {
/*"Emulate HID device",*/ /*"Emulate HID device",*/
"Print help and exit", "Print help and exit",
"Number of reader to use (default: auto-detect)", "Number of reader (default: auto-detect)",
"Which card driver to use (default: auto-detect)", "Card driver to use (default: auto-detect)",
"USB serial number (default: random)", "USB serial number (default: random)",
"USB product ID (default: 0x3010)", "USB iInterface (default: notification status)",
"USB vendor ID (default: 0x0D46)", "USB product ID (default: 0x3010)",
"USB vendor ID (default: 0x0D46)",
"Add interrupt pipe for CCID", "Add interrupt pipe for CCID",
"Use (several times) to be more verbose", "Use (several times) to be more verbose",
"Print version, available readers and drivers.", "Print version, available readers and drivers.",
@@ -286,8 +291,8 @@ static const struct usb_endpoint_descriptor *hs_eps [] = {
/* 56 is the maximum for the KOBIL Class 3 Reader */ /* 56 is the maximum for the KOBIL Class 3 Reader */
static char serial [57]; static char serial [57];
static const char interrupt_on_string[] = "REINER SCT cyberJack pinpad/e-com USB"; static const char interrupt_on_string[] = "Insertion and removal events enabled";
static const char interrupt_off_string[] = "REINER SCT cyberJack pinpad/e-com USB"; static const char interrupt_off_string[] = "Insertion and removal events disabled";
static struct usb_string stringtab [] = { static struct usb_string stringtab [] = {
{ STRINGID_MFGR, "Virtual Smart Card Architecture", }, { STRINGID_MFGR, "Virtual Smart Card Architecture", },
{ STRINGID_PRODUCT, "CCID Emulator", }, { STRINGID_PRODUCT, "CCID Emulator", },
@@ -593,10 +598,12 @@ static int autoconfig ()
if (!doint) { if (!doint) {
source_sink_intf.bNumEndpoints = 2; source_sink_intf.bNumEndpoints = 2;
int i; int i;
for (i=0; i<sizeof(stringtab)/sizeof(struct usb_string); i++) { if (!doiintf) {
if (stringtab[i].id == STRINGID_INTERFACE) { for (i=0; i<sizeof(stringtab)/sizeof(struct usb_string); i++) {
stringtab[i].s = interrupt_off_string; if (stringtab[i].id == STRINGID_INTERFACE) {
break; stringtab[i].s = interrupt_off_string;
break;
}
} }
} }
// Automatic activation of ICC on inserting not supported // Automatic activation of ICC on inserting not supported
@@ -1719,16 +1726,8 @@ main (int argc, char **argv)
int fd, c, i; int fd, c, i;
int oindex = 0; int oindex = 0;
/* random initial serial number */
srand ((int) time (0));
for (i = 0; i < sizeof serial - 1; ) {
c = rand () % 127;
if ((('a' <= c && c <= 'z') || ('0' <= c && c <= '9')))
serial [i++] = c;
}
while (1) { while (1) {
c = getopt_long(argc, argv, "hnr:s:i::u::a::z::I::A::p:e:voc:", options, &oindex); c = getopt_long(argc, argv, "hnr:s:i:p:e:voc:", options, &oindex);
if (c == -1) if (c == -1)
break; break;
switch (c) { switch (c) {
@@ -1743,10 +1742,10 @@ main (int argc, char **argv)
} }
break; break;
case OPT_SERIAL: case OPT_SERIAL:
if (sscanf(optarg, "%56s", serial) != 1) { doserial = optarg;
parse_error(argv[0], options, option_help, optarg, oindex); break;
exit(2); case OPT_IINTERFACE:
} doiintf = optarg;
break; break;
case OPT_PRODUCT: case OPT_PRODUCT:
if (sscanf(optarg, "%x", &productid) != 1) { if (sscanf(optarg, "%x", &productid) != 1) {
@@ -1809,6 +1808,32 @@ main (int argc, char **argv)
return 1; return 1;
} }
if (doserial) {
for (i=0; i<sizeof(stringtab)/sizeof(struct usb_string); i++) {
if (stringtab[i].id == STRINGID_SERIAL) {
stringtab[i].s = doserial;
break;
}
}
} else {
/* random initial serial number */
srand ((int) time (0));
for (i = 0; i < sizeof serial - 1; ) {
c = rand () % 127;
if ((('a' <= c && c <= 'z') || ('0' <= c && c <= '9')))
serial [i++] = c;
}
}
if (doiintf) {
for (i=0; i<sizeof(stringtab)/sizeof(struct usb_string); i++) {
if (stringtab[i].id == STRINGID_INTERFACE) {
stringtab[i].s = doiintf;
break;
}
}
}
fd = init_device (); fd = init_device ();
if (fd < 0) if (fd < 0)
return 1; return 1;