| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * The USB Monitor, inspired by Dave Harding's USBMon. | 
					
						
							| 
									
										
										
										
											2005-08-16 15:16:46 -07:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2005 Pete Zaitcev (zaitcev@redhat.com) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __USB_MON_H
 | 
					
						
							|  |  |  | #define __USB_MON_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/list.h>
 | 
					
						
							|  |  |  | #include <linux/slab.h>
 | 
					
						
							|  |  |  | #include <linux/kref.h>
 | 
					
						
							|  |  |  | /* #include <linux/usb.h> */	/* We use struct pointers only in this header */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define TAG "usbmon"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct mon_bus { | 
					
						
							|  |  |  | 	struct list_head bus_link; | 
					
						
							|  |  |  | 	spinlock_t lock; | 
					
						
							| 
									
										
											  
											
												USB: add binary API to usbmon
This patch adds a new, "binary" API in addition to the old, text API usbmon
had before. The new API allows for less CPU use, and it allows to capture
all data from a packet where old API only captured 32 bytes at most. There
are some limitations and conditions to this, e.g. in case someone constructs
a URB with 1GB of data, it's not likely to be captured, because even the
huge buffers of the new reader are finite. Nonetheless, I expect this new
capability to capture all data for all real life scenarios.
The downside is, a special user mode application is required where cat(1)
worked before. I have sample code at http://people.redhat.com/zaitcev/linux/
and Paolo Abeni is working on patching libpcap.
This patch was initially written by Paolo and later I tweaked it, and
we had a little back-and-forth. So this is a jointly authored patch, but
I am submitting this I am responsible for the bugs.
Signed-off-by: Paolo Abeni <paolo.abeni@email.it>
Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
											
										 
											2006-12-30 22:43:10 -08:00
										 |  |  | 	struct usb_bus *u_bus; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int text_inited; | 
					
						
							| 
									
										
										
										
											2007-05-03 16:51:16 -07:00
										 |  |  | 	int bin_inited; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	struct dentry *dent_s;		/* Debugging file */ | 
					
						
							|  |  |  | 	struct dentry *dent_t;		/* Text interface file */ | 
					
						
							| 
									
										
										
										
											2007-02-24 19:27:33 -08:00
										 |  |  | 	struct dentry *dent_u;		/* Second text interface file */ | 
					
						
							| 
									
										
										
										
											2007-05-03 16:51:16 -07:00
										 |  |  | 	struct device *classdev;	/* Device in usbmon class */ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Ref */ | 
					
						
							|  |  |  | 	int nreaders;			/* Under mon_lock AND mbus->lock */ | 
					
						
							|  |  |  | 	struct list_head r_list;	/* Chain of readers (usually one) */ | 
					
						
							|  |  |  | 	struct kref ref;		/* Under mon_lock */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Stats */ | 
					
						
							| 
									
										
										
										
											2006-06-09 20:10:10 -07:00
										 |  |  | 	unsigned int cnt_events; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	unsigned int cnt_text_lost; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * An instance of a process which opened a file (but can fork later) | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | struct mon_reader { | 
					
						
							|  |  |  | 	struct list_head r_link; | 
					
						
							|  |  |  | 	struct mon_bus *m_bus; | 
					
						
							|  |  |  | 	void *r_data;		/* Use container_of instead? */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void (*rnf_submit)(void *data, struct urb *urb); | 
					
						
							| 
									
										
										
										
											2006-06-09 22:03:32 -07:00
										 |  |  | 	void (*rnf_error)(void *data, struct urb *urb, int error); | 
					
						
							| 
									
										
										
										
											2007-08-24 15:41:41 -04:00
										 |  |  | 	void (*rnf_complete)(void *data, struct urb *urb, int status); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r); | 
					
						
							|  |  |  | void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												USB: add binary API to usbmon
This patch adds a new, "binary" API in addition to the old, text API usbmon
had before. The new API allows for less CPU use, and it allows to capture
all data from a packet where old API only captured 32 bytes at most. There
are some limitations and conditions to this, e.g. in case someone constructs
a URB with 1GB of data, it's not likely to be captured, because even the
huge buffers of the new reader are finite. Nonetheless, I expect this new
capability to capture all data for all real life scenarios.
The downside is, a special user mode application is required where cat(1)
worked before. I have sample code at http://people.redhat.com/zaitcev/linux/
and Paolo Abeni is working on patching libpcap.
This patch was initially written by Paolo and later I tweaked it, and
we had a little back-and-forth. So this is a jointly authored patch, but
I am submitting this I am responsible for the bugs.
Signed-off-by: Paolo Abeni <paolo.abeni@email.it>
Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
											
										 
											2006-12-30 22:43:10 -08:00
										 |  |  | struct mon_bus *mon_bus_lookup(unsigned int num); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-03 16:51:16 -07:00
										 |  |  | int /*bool*/ mon_text_add(struct mon_bus *mbus, const struct usb_bus *ubus); | 
					
						
							| 
									
										
											  
											
												USB: add binary API to usbmon
This patch adds a new, "binary" API in addition to the old, text API usbmon
had before. The new API allows for less CPU use, and it allows to capture
all data from a packet where old API only captured 32 bytes at most. There
are some limitations and conditions to this, e.g. in case someone constructs
a URB with 1GB of data, it's not likely to be captured, because even the
huge buffers of the new reader are finite. Nonetheless, I expect this new
capability to capture all data for all real life scenarios.
The downside is, a special user mode application is required where cat(1)
worked before. I have sample code at http://people.redhat.com/zaitcev/linux/
and Paolo Abeni is working on patching libpcap.
This patch was initially written by Paolo and later I tweaked it, and
we had a little back-and-forth. So this is a jointly authored patch, but
I am submitting this I am responsible for the bugs.
Signed-off-by: Paolo Abeni <paolo.abeni@email.it>
Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
											
										 
											2006-12-30 22:43:10 -08:00
										 |  |  | void mon_text_del(struct mon_bus *mbus); | 
					
						
							| 
									
										
										
										
											2007-05-03 16:51:16 -07:00
										 |  |  | int /*bool*/ mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus); | 
					
						
							|  |  |  | void mon_bin_del(struct mon_bus *mbus); | 
					
						
							| 
									
										
											  
											
												USB: add binary API to usbmon
This patch adds a new, "binary" API in addition to the old, text API usbmon
had before. The new API allows for less CPU use, and it allows to capture
all data from a packet where old API only captured 32 bytes at most. There
are some limitations and conditions to this, e.g. in case someone constructs
a URB with 1GB of data, it's not likely to be captured, because even the
huge buffers of the new reader are finite. Nonetheless, I expect this new
capability to capture all data for all real life scenarios.
The downside is, a special user mode application is required where cat(1)
worked before. I have sample code at http://people.redhat.com/zaitcev/linux/
and Paolo Abeni is working on patching libpcap.
This patch was initially written by Paolo and later I tweaked it, and
we had a little back-and-forth. So this is a jointly authored patch, but
I am submitting this I am responsible for the bugs.
Signed-off-by: Paolo Abeni <paolo.abeni@email.it>
Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
											
										 
											2006-12-30 22:43:10 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | int __init mon_text_init(void); | 
					
						
							| 
									
										
										
										
											2007-02-20 10:37:52 -08:00
										 |  |  | void mon_text_exit(void); | 
					
						
							| 
									
										
											  
											
												USB: add binary API to usbmon
This patch adds a new, "binary" API in addition to the old, text API usbmon
had before. The new API allows for less CPU use, and it allows to capture
all data from a packet where old API only captured 32 bytes at most. There
are some limitations and conditions to this, e.g. in case someone constructs
a URB with 1GB of data, it's not likely to be captured, because even the
huge buffers of the new reader are finite. Nonetheless, I expect this new
capability to capture all data for all real life scenarios.
The downside is, a special user mode application is required where cat(1)
worked before. I have sample code at http://people.redhat.com/zaitcev/linux/
and Paolo Abeni is working on patching libpcap.
This patch was initially written by Paolo and later I tweaked it, and
we had a little back-and-forth. So this is a jointly authored patch, but
I am submitting this I am responsible for the bugs.
Signed-off-by: Paolo Abeni <paolo.abeni@email.it>
Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
											
										 
											2006-12-30 22:43:10 -08:00
										 |  |  | int __init mon_bin_init(void); | 
					
						
							| 
									
										
										
										
											2007-02-20 10:37:52 -08:00
										 |  |  | void mon_bin_exit(void); | 
					
						
							| 
									
										
											  
											
												USB: add binary API to usbmon
This patch adds a new, "binary" API in addition to the old, text API usbmon
had before. The new API allows for less CPU use, and it allows to capture
all data from a packet where old API only captured 32 bytes at most. There
are some limitations and conditions to this, e.g. in case someone constructs
a URB with 1GB of data, it's not likely to be captured, because even the
huge buffers of the new reader are finite. Nonetheless, I expect this new
capability to capture all data for all real life scenarios.
The downside is, a special user mode application is required where cat(1)
worked before. I have sample code at http://people.redhat.com/zaitcev/linux/
and Paolo Abeni is working on patching libpcap.
This patch was initially written by Paolo and later I tweaked it, and
we had a little back-and-forth. So this is a jointly authored patch, but
I am submitting this I am responsible for the bugs.
Signed-off-by: Paolo Abeni <paolo.abeni@email.it>
Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
											
										 
											2006-12-30 22:43:10 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2006-01-11 15:55:29 +01:00
										 |  |  | extern struct mutex mon_lock; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-05 20:37:11 -03:00
										 |  |  | extern const struct file_operations mon_fops_stat; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-04-11 13:47:26 -07:00
										 |  |  | extern struct mon_bus mon_bus0;		/* Only for redundant checks */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #endif /* __USB_MON_H */
 |