1/*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24/*
25 *  PCSCDevice.h
26 *  SmartCardServices
27 *
28 */
29
30#ifndef _H_PCSCDEVICE
31#define _H_PCSCDEVICE
32
33#include <MacTypes.h>
34#include <security_utilities/iodevices.h>
35#include <security_utilities/refcount.h>
36
37#if defined(__cplusplus)
38
39namespace PCSCD {
40
41class Device : public IOKit::Device, public RefCount
42{
43public:
44//	Device() :  { }
45	Device(io_service_t d) : IOKit::Device(d) { }
46
47	virtual ~Device() throw();
48
49	bool operator < (const Device &other) const { return this->address() < other.address(); }
50
51	void setAddress(uint32_t address)  { mAddress = address; }
52	void setInterfaceClass(uint32_t interfaceClass)  { mInterfaceClass = interfaceClass; }
53	void setDeviceClass(uint32_t deviceClass)  { mDeviceClass = deviceClass; }
54	void setVendorid(uint32_t vendorid)  { mVendorid = vendorid; }
55	void setProductid(uint32_t productid)  { mProductid = productid; }
56	void setPath(const std::string path)  { mLibPath = path; }
57	void setName(const std::string name)  { mName = name; }
58	void setIsPCCard(bool isPCCard)  { mIsPCCard = isPCCard; }
59
60	uint32_t address() const { return mAddress; }
61	uint32_t interfaceClass() const { return mInterfaceClass; }
62	uint32_t deviceClass() const { return mDeviceClass; }
63	uint32_t vendorid() const { return mVendorid; }
64	uint32_t productid() const { return mProductid; }
65	std::string path() const { return mLibPath; }
66	std::string name() const { return mName; }
67	bool isPCCard() const { return mIsPCCard; }
68
69	std::string vendorName() const { return mVendorName; }
70	std::string productName() const { return mProductName; }
71	std::string serialNumber() const { return mSerialNumber; }
72
73	void setDebugParams(const std::string vendorName, const std::string productName,
74		const std::string serialNumber)
75		{ mVendorName = vendorName; mProductName = productName; mSerialNumber = serialNumber;}
76
77	void dump();
78
79private:
80
81	uint32_t mAddress;
82
83	std::string mName;			// Manufacturer's name for device
84	std::string mLibPath;		// path to driver bundle from PCSCDriverBundle
85
86	uint32_t mInterfaceClass;	// If present, one of kUSBChipSmartCardInterfaceClass/kUSBVendorSpecificInterfaceClass
87	uint32_t mDeviceClass;		// If == kUSBVendorSpecificClass, check vendor/product
88	uint32_t mVendorid;
89	uint32_t mProductid;
90
91	bool mIsPCCard;
92
93	// Mainly for debugging
94	std::string mVendorName, mProductName, mSerialNumber;
95};
96
97} // end namespace PCSCD
98
99#endif /* __cplusplus__ */
100
101#endif // _H_PCSCDEVICE
102