Line
Link Here
|
0 |
-- a/vmnet-only/bridge.c |
0 |
++ b/vmnet-only/bridge.c |
Lines 105-112
static Bool VNetBridgeCycleDetect(VNetJack *this, int generation);
Link Here
|
105 |
static Bool VNetBridgeIsDeviceWireless(struct net_device *dev); |
105 |
static Bool VNetBridgeIsDeviceWireless(struct net_device *dev); |
106 |
static void VNetBridgePortsChanged(VNetJack *this); |
106 |
static void VNetBridgePortsChanged(VNetJack *this); |
107 |
static int VNetBridgeIsBridged(VNetJack *this); |
107 |
static int VNetBridgeIsBridged(VNetJack *this); |
108 |
static int VNetBridgeProcRead(char *page, char **start, off_t off, |
|
|
109 |
int count, int *eof, void *data); |
110 |
static void VNetBridgeComputeHeaderPosIPv6(struct sk_buff *skb); |
108 |
static void VNetBridgeComputeHeaderPosIPv6(struct sk_buff *skb); |
111 |
static PacketStatus VNetCallSMACFunc(struct SMACState *state, |
109 |
static PacketStatus VNetCallSMACFunc(struct SMACState *state, |
112 |
struct sk_buff **skb, void *startOfData, |
110 |
struct sk_buff **skb, void *startOfData, |
Lines 225-230
VNetBridgeDevCompatible(VNetBridge *bridge, // IN: Bridge
Link Here
|
225 |
/* |
223 |
/* |
226 |
*---------------------------------------------------------------------- |
224 |
*---------------------------------------------------------------------- |
227 |
* |
225 |
* |
|
|
226 |
* VNetBridgeProcShow -- |
227 |
* |
228 |
* Callback for read operation on this bridge entry in vnets proc fs. |
229 |
* |
230 |
* Results: |
231 |
* Length of read operation. |
232 |
* |
233 |
* Side effects: |
234 |
* None. |
235 |
* |
236 |
*---------------------------------------------------------------------- |
237 |
*/ |
238 |
|
239 |
int |
240 |
VNetBridgeProcShow(struct seq_file *seqf, // IN/OUT: buffer to write into |
241 |
void *data) // IN: client data - pointer to bridge |
242 |
{ |
243 |
VNetBridge *bridge = (VNetBridge*)data; |
244 |
|
245 |
if (!bridge) { |
246 |
return 0; |
247 |
} |
248 |
|
249 |
VNetPrintPort(&bridge->port, seqf); |
250 |
|
251 |
seq_printf(seqf, "dev %s ", bridge->name); |
252 |
|
253 |
seq_printf(seqf, "\n"); |
254 |
|
255 |
return 0; |
256 |
} |
257 |
|
258 |
static int proc_bridge_open(struct inode *inode, struct file *file) |
259 |
{ |
260 |
return single_open(file, VNetBridgeProcShow, PDE_DATA(inode)); |
261 |
} |
262 |
|
263 |
static const struct file_operations proc_bridge_fops = { |
264 |
.open = proc_bridge_open, |
265 |
.read = seq_read, |
266 |
.llseek = seq_lseek, |
267 |
.release = seq_release, |
268 |
}; |
269 |
|
270 |
/* |
271 |
*---------------------------------------------------------------------- |
272 |
* |
228 |
* VNetBridge_Create -- |
273 |
* VNetBridge_Create -- |
229 |
* |
274 |
* |
230 |
* Creates a bridge. Allocates struct, allocates internal device, |
275 |
* Creates a bridge. Allocates struct, allocates internal device, |
Lines 319-335
VNetBridge_Create(const char *devName, // IN: name of device (e.g., "eth0")
Link Here
|
319 |
* Make proc entry for this jack. |
364 |
* Make proc entry for this jack. |
320 |
*/ |
365 |
*/ |
321 |
|
366 |
|
322 |
retval = VNetProc_MakeEntry(bridge->port.jack.name, S_IFREG, |
367 |
retval = VNetProc_MakeEntryOps(bridge->port.jack.name, S_IFREG, |
323 |
&bridge->port.jack.procEntry); |
368 |
&bridge->port.jack.procEntry, &proc_bridge_fops, bridge); |
324 |
if (retval) { |
369 |
if (retval) { |
325 |
if (retval == -ENXIO) { |
370 |
if (retval == -ENXIO) { |
326 |
bridge->port.jack.procEntry = NULL; |
371 |
bridge->port.jack.procEntry = NULL; |
327 |
} else { |
372 |
} else { |
328 |
goto out; |
373 |
goto out; |
329 |
} |
374 |
} |
330 |
} else { |
|
|
331 |
bridge->port.jack.procEntry->read_proc = VNetBridgeProcRead; |
332 |
bridge->port.jack.procEntry->data = bridge; |
333 |
} |
375 |
} |
334 |
|
376 |
|
335 |
/* |
377 |
/* |
Lines 1719-1763
VNetBridgeReceiveFromDev(struct sk_buff *skb, // IN: packet to receive
Link Here
|
1719 |
return 0; |
1761 |
return 0; |
1720 |
} |
1762 |
} |
1721 |
|
1763 |
|
1722 |
|
1764 |
++ b/vmnet-only/driver.c |
1723 |
/* |
|
|
1724 |
*---------------------------------------------------------------------- |
1725 |
* |
1726 |
* VNetBridgeProcRead -- |
1727 |
* |
1728 |
* Callback for read operation on this bridge entry in vnets proc fs. |
1729 |
* |
1730 |
* Results: |
1731 |
* Length of read operation. |
1732 |
* |
1733 |
* Side effects: |
1734 |
* None. |
1735 |
* |
1736 |
*---------------------------------------------------------------------- |
1737 |
*/ |
1738 |
|
1739 |
int |
1740 |
VNetBridgeProcRead(char *page, // IN/OUT: buffer to write into |
1741 |
char **start, // OUT: 0 if file < 4k, else offset into page |
1742 |
off_t off, // IN: (unused) offset of read into the file |
1743 |
int count, // IN: (unused) maximum number of bytes to read |
1744 |
int *eof, // OUT: TRUE if there is nothing more to read |
1745 |
void *data) // IN: client data - pointer to bridge |
1746 |
{ |
1747 |
VNetBridge *bridge = (VNetBridge*)data; |
1748 |
int len = 0; |
1749 |
|
1750 |
if (!bridge) { |
1751 |
return len; |
1752 |
} |
1753 |
|
1754 |
len += VNetPrintPort(&bridge->port, page+len); |
1755 |
|
1756 |
len += sprintf(page+len, "dev %s ", bridge->name); |
1757 |
|
1758 |
len += sprintf(page+len, "\n"); |
1759 |
|
1760 |
*start = 0; |
1761 |
*eof = 1; |
1762 |
return len; |
1763 |
} |
1764 |
-- a/vmnet-only/driver.c |
Lines 1785-1805
VNetSetMACUnique(VNetPort *port, // IN:
Link Here
|
1785 |
*---------------------------------------------------------------------- |
1785 |
*---------------------------------------------------------------------- |
1786 |
*/ |
1786 |
*/ |
1787 |
|
1787 |
|
1788 |
int |
1788 |
void |
1789 |
VNetPrintJack(const VNetJack *jack, // IN: jack |
1789 |
VNetPrintJack(const VNetJack *jack, // IN: jack |
1790 |
char *buf) // OUT: info about jack |
1790 |
struct seq_file *seqf) // OUT: info about jack |
1791 |
{ |
1791 |
{ |
1792 |
int len = 0; |
|
|
1793 |
|
1794 |
read_lock(&vnetPeerLock); |
1792 |
read_lock(&vnetPeerLock); |
1795 |
if (!jack->peer) { |
1793 |
if (!jack->peer) { |
1796 |
len += sprintf(buf+len, "connected not "); |
1794 |
seq_printf(seqf, "connected not "); |
1797 |
} else { |
1795 |
} else { |
1798 |
len += sprintf(buf+len, "connected %s ", jack->peer->name); |
1796 |
seq_printf(seqf, "connected %s ", jack->peer->name); |
1799 |
} |
1797 |
} |
1800 |
read_unlock(&vnetPeerLock); |
1798 |
read_unlock(&vnetPeerLock); |
1801 |
|
|
|
1802 |
return len; |
1803 |
} |
1799 |
} |
1804 |
|
1800 |
|
1805 |
|
1801 |
|
Lines 1819-1870
VNetPrintJack(const VNetJack *jack, // IN: jack
Link Here
|
1819 |
*---------------------------------------------------------------------- |
1815 |
*---------------------------------------------------------------------- |
1820 |
*/ |
1816 |
*/ |
1821 |
|
1817 |
|
1822 |
int |
1818 |
void |
1823 |
VNetPrintPort(const VNetPort *port, // IN: port |
1819 |
VNetPrintPort(const VNetPort *port, // IN: port |
1824 |
char *buf) // OUT: info about port |
1820 |
struct seq_file *seqf) // OUT: info about port |
1825 |
{ |
1821 |
{ |
1826 |
int len = 0; |
1822 |
VNetPrintJack(&port->jack, seqf); |
1827 |
|
1823 |
|
1828 |
len += VNetPrintJack(&port->jack, buf+len); |
1824 |
seq_printf(seqf, "mac %02x:%02x:%02x:%02x:%02x:%02x ", |
1829 |
|
|
|
1830 |
len += sprintf(buf+len, "mac %02x:%02x:%02x:%02x:%02x:%02x ", |
1831 |
port->paddr[0], port->paddr[1], port->paddr[2], |
1825 |
port->paddr[0], port->paddr[1], port->paddr[2], |
1832 |
port->paddr[3], port->paddr[4], port->paddr[5]); |
1826 |
port->paddr[3], port->paddr[4], port->paddr[5]); |
1833 |
|
1827 |
|
1834 |
len += sprintf(buf+len, "ladrf %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ", |
1828 |
seq_printf(seqf, "ladrf %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ", |
1835 |
port->ladrf[0], port->ladrf[1], port->ladrf[2], |
1829 |
port->ladrf[0], port->ladrf[1], port->ladrf[2], |
1836 |
port->ladrf[3], port->ladrf[4], port->ladrf[5], |
1830 |
port->ladrf[3], port->ladrf[4], port->ladrf[5], |
1837 |
port->ladrf[6], port->ladrf[7]); |
1831 |
port->ladrf[6], port->ladrf[7]); |
1838 |
|
1832 |
|
1839 |
len += sprintf(buf+len, "flags IFF_RUNNING"); |
1833 |
seq_printf(seqf, "flags IFF_RUNNING"); |
1840 |
|
1834 |
|
1841 |
if (port->flags & IFF_UP) { |
1835 |
if (port->flags & IFF_UP) { |
1842 |
len += sprintf(buf+len, ",IFF_UP"); |
1836 |
seq_printf(seqf, ",IFF_UP"); |
1843 |
} |
1837 |
} |
1844 |
|
1838 |
|
1845 |
if (port->flags & IFF_BROADCAST) { |
1839 |
if (port->flags & IFF_BROADCAST) { |
1846 |
len += sprintf(buf+len, ",IFF_BROADCAST"); |
1840 |
seq_printf(seqf, ",IFF_BROADCAST"); |
1847 |
} |
1841 |
} |
1848 |
|
1842 |
|
1849 |
if (port->flags & IFF_DEBUG) { |
1843 |
if (port->flags & IFF_DEBUG) { |
1850 |
len += sprintf(buf+len, ",IFF_DEBUG"); |
1844 |
seq_printf(seqf, ",IFF_DEBUG"); |
1851 |
} |
1845 |
} |
1852 |
|
1846 |
|
1853 |
if (port->flags & IFF_PROMISC) { |
1847 |
if (port->flags & IFF_PROMISC) { |
1854 |
len += sprintf(buf+len, ",IFF_PROMISC"); |
1848 |
seq_printf(seqf, ",IFF_PROMISC"); |
1855 |
} |
1849 |
} |
1856 |
|
1850 |
|
1857 |
if (port->flags & IFF_MULTICAST) { |
1851 |
if (port->flags & IFF_MULTICAST) { |
1858 |
len += sprintf(buf+len, ",IFF_MULTICAST"); |
1852 |
seq_printf(seqf, ",IFF_MULTICAST"); |
1859 |
} |
1853 |
} |
1860 |
|
1854 |
|
1861 |
if (port->flags & IFF_ALLMULTI) { |
1855 |
if (port->flags & IFF_ALLMULTI) { |
1862 |
len += sprintf(buf+len, ",IFF_ALLMULTI"); |
1856 |
seq_printf(seqf, ",IFF_ALLMULTI"); |
1863 |
} |
1857 |
} |
1864 |
|
1858 |
|
1865 |
len += sprintf(buf+len, " "); |
1859 |
seq_printf(seqf, " "); |
1866 |
|
|
|
1867 |
return len; |
1868 |
} |
1860 |
} |
1869 |
|
1861 |
|
1870 |
|
1862 |
|
1871 |
-- a/vmnet-only/hub.c |
1863 |
++ b/vmnet-only/hub.c |
Lines 25-30
Link Here
|
25 |
#include <linux/sched.h> |
25 |
#include <linux/sched.h> |
26 |
#include <linux/slab.h> |
26 |
#include <linux/slab.h> |
27 |
#include <linux/poll.h> |
27 |
#include <linux/poll.h> |
|
|
28 |
#include <linux/seq_file.h> |
28 |
|
29 |
|
29 |
#include <linux/netdevice.h> |
30 |
#include <linux/netdevice.h> |
30 |
#include <linux/etherdevice.h> |
31 |
#include <linux/etherdevice.h> |
Lines 71-78
static void VNetHubReceive(VNetJack *this, struct sk_buff *skb);
Link Here
|
71 |
static Bool VNetHubCycleDetect(VNetJack *this, int generation); |
72 |
static Bool VNetHubCycleDetect(VNetJack *this, int generation); |
72 |
static void VNetHubPortsChanged(VNetJack *this); |
73 |
static void VNetHubPortsChanged(VNetJack *this); |
73 |
static int VNetHubIsBridged(VNetJack *this); |
74 |
static int VNetHubIsBridged(VNetJack *this); |
74 |
static int VNetHubProcRead(char *page, char **start, off_t off, |
|
|
75 |
int count, int *eof, void *data); |
76 |
|
75 |
|
77 |
static VNetHub *vnetHub; |
76 |
static VNetHub *vnetHub; |
78 |
static DEFINE_SPINLOCK(vnetHubLock); |
77 |
static DEFINE_SPINLOCK(vnetHubLock); |
Lines 241-246
VNetHub_AllocPvn(uint8 id[]) // IN: the PVN ID to alloc on
Link Here
|
241 |
/* |
240 |
/* |
242 |
*---------------------------------------------------------------------- |
241 |
*---------------------------------------------------------------------- |
243 |
* |
242 |
* |
|
|
243 |
* VNetHubProcShow -- |
244 |
* |
245 |
* Callback for read operation on hub entry in vnets proc fs. |
246 |
* |
247 |
* Results: |
248 |
* Length of read operation. |
249 |
* |
250 |
* Side effects: |
251 |
* None. |
252 |
* |
253 |
*---------------------------------------------------------------------- |
254 |
*/ |
255 |
|
256 |
int |
257 |
VNetHubProcShow(struct seq_file *seqf, // IN/OUT: buffer to write into |
258 |
void *data) // IN: client data - not used |
259 |
{ |
260 |
VNetJack *jack = (VNetJack*)data; |
261 |
VNetHub *hub; |
262 |
|
263 |
if (!jack || !jack->private) { |
264 |
return 0; |
265 |
} |
266 |
hub = (VNetHub*)jack->private; |
267 |
|
268 |
VNetPrintJack(jack, seqf); |
269 |
|
270 |
seq_printf(seqf, "tx %u ", hub->stats[jack->index].tx); |
271 |
seq_printf(seqf, "\n"); |
272 |
return 0; |
273 |
} |
274 |
|
275 |
static int proc_hub_open(struct inode *inode, struct file *file) |
276 |
{ |
277 |
return single_open(file, VNetHubProcShow, PDE_DATA(inode)); |
278 |
} |
279 |
|
280 |
static const struct file_operations proc_hub_fops = { |
281 |
.open = proc_hub_open, |
282 |
.read = seq_read, |
283 |
.llseek = seq_lseek, |
284 |
.release = seq_release, |
285 |
}; |
286 |
|
287 |
/* |
288 |
*---------------------------------------------------------------------- |
289 |
* |
244 |
* VNetHubAlloc -- |
290 |
* VNetHubAlloc -- |
245 |
* |
291 |
* |
246 |
* Allocate a jack on this hub. |
292 |
* Allocate a jack on this hub. |
Lines 354-360
VNetHubAlloc(Bool allocPvn, // IN: TRUE for PVN, FALSE for vnet
Link Here
|
354 |
* Make proc entry for this jack. |
400 |
* Make proc entry for this jack. |
355 |
*/ |
401 |
*/ |
356 |
|
402 |
|
357 |
retval = VNetProc_MakeEntry(jack->name, S_IFREG, &jack->procEntry); |
403 |
retval = VNetProc_MakeEntryOps(jack->name, S_IFREG, &jack->procEntry, &proc_hub_fops, jack); |
358 |
if (retval) { |
404 |
if (retval) { |
359 |
if (retval == -ENXIO) { |
405 |
if (retval == -ENXIO) { |
360 |
jack->procEntry = NULL; |
406 |
jack->procEntry = NULL; |
Lines 362-370
VNetHubAlloc(Bool allocPvn, // IN: TRUE for PVN, FALSE for vnet
Link Here
|
362 |
hub->used[i] = FALSE; |
408 |
hub->used[i] = FALSE; |
363 |
return NULL; |
409 |
return NULL; |
364 |
} |
410 |
} |
365 |
} else { |
|
|
366 |
jack->procEntry->read_proc = VNetHubProcRead; |
367 |
jack->procEntry->data = jack; |
368 |
} |
411 |
} |
369 |
|
412 |
|
370 |
/* |
413 |
/* |
Lines 686-731
VNetHubIsBridged(VNetJack *this)
Link Here
|
686 |
} |
729 |
} |
687 |
|
730 |
|
688 |
|
731 |
|
689 |
/* |
732 |
++ b/vmnet-only/netif.c |
690 |
*---------------------------------------------------------------------- |
|
|
691 |
* |
692 |
* VNetHubProcRead -- |
693 |
* |
694 |
* Callback for read operation on hub entry in vnets proc fs. |
695 |
* |
696 |
* Results: |
697 |
* Length of read operation. |
698 |
* |
699 |
* Side effects: |
700 |
* None. |
701 |
* |
702 |
*---------------------------------------------------------------------- |
703 |
*/ |
704 |
|
705 |
int |
706 |
VNetHubProcRead(char *page, // IN/OUT: buffer to write into |
707 |
char **start, // OUT: 0 if file < 4k, else offset into page |
708 |
off_t off, // IN: offset of read into the file |
709 |
int count, // IN: maximum number of bytes to read |
710 |
int *eof, // OUT: TRUE if there is nothing more to read |
711 |
void *data) // IN: client data - not used |
712 |
{ |
713 |
VNetJack *jack = (VNetJack*)data; |
714 |
VNetHub *hub; |
715 |
int len = 0; |
716 |
|
717 |
if (!jack || !jack->private) { |
718 |
return len; |
719 |
} |
720 |
hub = (VNetHub*)jack->private; |
721 |
|
722 |
len += VNetPrintJack(jack, page+len); |
723 |
|
724 |
len += sprintf(page+len, "tx %u ", hub->stats[jack->index].tx); |
725 |
|
726 |
len += sprintf(page+len, "\n"); |
727 |
|
728 |
*start = 0; |
729 |
*eof = 1; |
730 |
return len; |
731 |
} |
732 |
-- a/vmnet-only/netif.c |
Lines 62-69
static int VNetNetifStartXmit(struct sk_buff *skb, struct net_device *dev);
Link Here
|
62 |
static struct net_device_stats *VNetNetifGetStats(struct net_device *dev); |
62 |
static struct net_device_stats *VNetNetifGetStats(struct net_device *dev); |
63 |
static int VNetNetifSetMAC(struct net_device *dev, void *addr); |
63 |
static int VNetNetifSetMAC(struct net_device *dev, void *addr); |
64 |
static void VNetNetifSetMulticast(struct net_device *dev); |
64 |
static void VNetNetifSetMulticast(struct net_device *dev); |
65 |
static int VNetNetIfProcRead(char *page, char **start, off_t off, |
|
|
66 |
int count, int *eof, void *data); |
67 |
|
65 |
|
68 |
/* |
66 |
/* |
69 |
*---------------------------------------------------------------------- |
67 |
*---------------------------------------------------------------------- |
Lines 116-121
VNetNetIfSetup(struct net_device *dev) // IN:
Link Here
|
116 |
|
114 |
|
117 |
} |
115 |
} |
118 |
|
116 |
|
|
|
117 |
/* |
118 |
*---------------------------------------------------------------------- |
119 |
* |
120 |
* VNetNetIfProcShow -- |
121 |
* |
122 |
* Callback for read operation on this netif entry in vnets proc fs. |
123 |
* |
124 |
* Results: |
125 |
* Length of read operation. |
126 |
* |
127 |
* Side effects: |
128 |
* None. |
129 |
* |
130 |
*---------------------------------------------------------------------- |
131 |
*/ |
132 |
|
133 |
int |
134 |
VNetNetIfProcShow(struct seq_file *seqf, // IN/OUT: buffer to write into |
135 |
void *data) // IN: client data |
136 |
{ |
137 |
VNetNetIF *netIf = data; |
138 |
|
139 |
if (!netIf) { |
140 |
return 0; |
141 |
} |
142 |
|
143 |
VNetPrintPort(&netIf->port, seqf); |
144 |
|
145 |
seq_printf(seqf, "dev %s ", netIf->dev->name); |
146 |
|
147 |
seq_printf(seqf, "\n"); |
148 |
|
149 |
return 0; |
150 |
} |
151 |
|
152 |
static int proc_netif_open(struct inode *inode, struct file *file) |
153 |
{ |
154 |
return single_open(file, VNetNetIfProcShow, PDE_DATA(inode)); |
155 |
} |
156 |
|
157 |
static const struct file_operations proc_netif_fops = { |
158 |
.open = proc_netif_open, |
159 |
.read = seq_read, |
160 |
.llseek = seq_lseek, |
161 |
.release = seq_release, |
162 |
}; |
163 |
|
119 |
|
164 |
|
120 |
/* |
165 |
/* |
121 |
*---------------------------------------------------------------------- |
166 |
*---------------------------------------------------------------------- |
Lines 180-195
VNetNetIf_Create(char *devName, // IN:
Link Here
|
180 |
* Make proc entry for this jack. |
225 |
* Make proc entry for this jack. |
181 |
*/ |
226 |
*/ |
182 |
|
227 |
|
183 |
retval = VNetProc_MakeEntry(netIf->port.jack.name, S_IFREG, |
228 |
retval = VNetProc_MakeEntryOps(netIf->port.jack.name, S_IFREG, |
184 |
&netIf->port.jack.procEntry); |
229 |
&netIf->port.jack.procEntry, &proc_netif_fops, netIf); |
185 |
if (retval) { |
230 |
if (retval) { |
186 |
netIf->port.jack.procEntry = NULL; |
231 |
netIf->port.jack.procEntry = NULL; |
187 |
if (retval != -ENXIO) { |
232 |
if (retval != -ENXIO) { |
188 |
goto outFreeDev; |
233 |
goto outFreeDev; |
189 |
} |
234 |
} |
190 |
} else { |
|
|
191 |
netIf->port.jack.procEntry->read_proc = VNetNetIfProcRead; |
192 |
netIf->port.jack.procEntry->data = netIf; |
193 |
} |
235 |
} |
194 |
|
236 |
|
195 |
/* |
237 |
/* |
Lines 553-597
VNetNetifGetStats(struct net_device *dev) // IN:
Link Here
|
553 |
return &netIf->stats; |
595 |
return &netIf->stats; |
554 |
} |
596 |
} |
555 |
|
597 |
|
556 |
|
598 |
++ b/vmnet-only/procfs.c |
557 |
/* |
|
|
558 |
*---------------------------------------------------------------------- |
559 |
* |
560 |
* VNetNetIfProcRead -- |
561 |
* |
562 |
* Callback for read operation on this netif entry in vnets proc fs. |
563 |
* |
564 |
* Results: |
565 |
* Length of read operation. |
566 |
* |
567 |
* Side effects: |
568 |
* None. |
569 |
* |
570 |
*---------------------------------------------------------------------- |
571 |
*/ |
572 |
|
573 |
int |
574 |
VNetNetIfProcRead(char *page, // IN/OUT: buffer to write into |
575 |
char **start, // OUT: 0 if file < 4k, else offset into page |
576 |
off_t off, // IN: (unused) offset of read into the file |
577 |
int count, // IN: (unused) maximum number of bytes to read |
578 |
int *eof, // OUT: TRUE if there is nothing more to read |
579 |
void *data) // IN: client data |
580 |
{ |
581 |
VNetNetIF *netIf = data; |
582 |
int len = 0; |
583 |
|
584 |
if (!netIf) { |
585 |
return len; |
586 |
} |
587 |
|
588 |
len += VNetPrintPort(&netIf->port, page+len); |
589 |
|
590 |
len += sprintf(page+len, "dev %s ", netIf->dev->name); |
591 |
|
592 |
len += sprintf(page+len, "\n"); |
593 |
|
594 |
*start = 0; |
595 |
*eof = 1; |
596 |
return len; |
597 |
} |
598 |
-- a/vmnet-only/procfs.c |
Lines 45-54
Link Here
|
45 |
|
45 |
|
46 |
#if defined(CONFIG_PROC_FS) |
46 |
#if defined(CONFIG_PROC_FS) |
47 |
|
47 |
|
48 |
static int VNetProcMakeEntryInt(VNetProcEntry *parent, char *name, int mode, |
|
|
49 |
VNetProcEntry **ret); |
50 |
static void VNetProcRemoveEntryInt(VNetProcEntry *node, VNetProcEntry *parent); |
51 |
|
52 |
static VNetProcEntry *base = NULL; |
48 |
static VNetProcEntry *base = NULL; |
53 |
|
49 |
|
54 |
|
50 |
|
Lines 71-77
static VNetProcEntry *base = NULL;
Link Here
|
71 |
int |
67 |
int |
72 |
VNetProc_Init(void) |
68 |
VNetProc_Init(void) |
73 |
{ |
69 |
{ |
74 |
return VNetProcMakeEntryInt(NULL, "vmnet", S_IFDIR, &base); |
70 |
base = proc_mkdir("vmnet", NULL); |
|
|
71 |
if(IS_ERR(base)) { |
72 |
base = NULL; |
73 |
return PTR_ERR(base); |
74 |
} |
75 |
return 0; |
75 |
} |
76 |
} |
76 |
|
77 |
|
77 |
|
78 |
|
Lines 94-107
VNetProc_Init(void)
Link Here
|
94 |
void |
95 |
void |
95 |
VNetProc_Cleanup(void) |
96 |
VNetProc_Cleanup(void) |
96 |
{ |
97 |
{ |
97 |
VNetProcRemoveEntryInt(base, NULL); |
98 |
proc_remove(base); |
98 |
base = NULL; |
99 |
base = NULL; |
99 |
} |
100 |
} |
100 |
|
101 |
|
101 |
/* |
102 |
/* |
102 |
*---------------------------------------------------------------------- |
103 |
*---------------------------------------------------------------------- |
103 |
* |
104 |
* |
104 |
* VNetProcMakeEntryInt -- |
105 |
* VNetProc_MakeEntryOps -- |
105 |
* |
106 |
* |
106 |
* Make an entry in the vnets proc file system. |
107 |
* Make an entry in the vnets proc file system. |
107 |
* |
108 |
* |
Lines 116-187
VNetProc_Cleanup(void)
Link Here
|
116 |
*/ |
117 |
*/ |
117 |
|
118 |
|
118 |
int |
119 |
int |
119 |
VNetProcMakeEntryInt(VNetProcEntry *parent, // IN: |
120 |
VNetProc_MakeEntryOps(char *name, // IN: |
120 |
char *name, // IN: |
|
|
121 |
int mode, // IN: |
121 |
int mode, // IN: |
122 |
VNetProcEntry **ret) // OUT: |
122 |
VNetProcEntry **ret, |
|
|
123 |
const struct file_operations *fops, |
124 |
void *data |
125 |
) // OUT: |
123 |
{ |
126 |
{ |
124 |
VNetProcEntry *ent; |
127 |
VNetProcEntry *ent; |
125 |
ent = create_proc_entry(name, mode, parent); |
128 |
ent = proc_create_data(name, mode, base, fops, data); |
126 |
*ret = ent; |
129 |
*ret = ent; |
127 |
if (!ent) |
130 |
if (!ent) |
128 |
return -ENOMEM; |
131 |
return -ENOMEM; |
129 |
return 0; |
132 |
return 0; |
130 |
} |
133 |
} |
131 |
|
134 |
|
132 |
|
|
|
133 |
/* |
134 |
*---------------------------------------------------------------------- |
135 |
* |
136 |
* VNetProcRemoveEntryInt -- |
137 |
* |
138 |
* Remove a previously installed proc entry. |
139 |
* |
140 |
* Results: |
141 |
* None. |
142 |
* |
143 |
* Side effects: |
144 |
* None. |
145 |
* |
146 |
*---------------------------------------------------------------------- |
147 |
*/ |
148 |
|
149 |
void |
150 |
VNetProcRemoveEntryInt(VNetProcEntry *node, |
151 |
VNetProcEntry *parent) |
152 |
{ |
153 |
if (node) { |
154 |
remove_proc_entry(node->name, parent); |
155 |
} |
156 |
} |
157 |
|
158 |
|
159 |
/* |
160 |
*---------------------------------------------------------------------- |
161 |
* |
162 |
* VNetProc_MakeEntry -- |
163 |
* |
164 |
* Make an entry in the vnets proc file system. |
165 |
* |
166 |
* Results: |
167 |
* errno. If errno is 0 and ret is non NULL then ret is filled |
168 |
* in with the resulting proc entry. |
169 |
* |
170 |
* Side effects: |
171 |
* None. |
172 |
* |
173 |
*---------------------------------------------------------------------- |
174 |
*/ |
175 |
|
176 |
int |
177 |
VNetProc_MakeEntry(char *name, // IN: |
178 |
int mode, // IN: |
179 |
VNetProcEntry **ret) // OUT: |
180 |
{ |
181 |
return VNetProcMakeEntryInt(base, name, mode, ret); |
182 |
} |
183 |
|
184 |
|
185 |
/* |
135 |
/* |
186 |
*---------------------------------------------------------------------- |
136 |
*---------------------------------------------------------------------- |
187 |
* |
137 |
* |
Lines 201-207
VNetProc_MakeEntry(char *name, // IN:
Link Here
|
201 |
void |
151 |
void |
202 |
VNetProc_RemoveEntry(VNetProcEntry *node) |
152 |
VNetProc_RemoveEntry(VNetProcEntry *node) |
203 |
{ |
153 |
{ |
204 |
VNetProcRemoveEntryInt(node, base); |
154 |
if(node) |
|
|
155 |
proc_remove(node); |
205 |
} |
156 |
} |
206 |
|
157 |
|
207 |
|
158 |
|
Lines 253-283
VNetProc_Cleanup(void)
Link Here
|
253 |
} |
204 |
} |
254 |
|
205 |
|
255 |
|
206 |
|
256 |
/* |
|
|
257 |
*---------------------------------------------------------------------- |
258 |
* |
259 |
* VNetProc_MakeEntry -- |
260 |
* |
261 |
* Make an entry in the vnets proc file system. |
262 |
* |
263 |
* Results: |
264 |
* errno. If errno is 0 and ret is non NULL then ret is filled |
265 |
* in with the resulting proc entry. |
266 |
* |
267 |
* Side effects: |
268 |
* None. |
269 |
* |
270 |
*---------------------------------------------------------------------- |
271 |
*/ |
272 |
|
273 |
int |
274 |
VNetProc_MakeEntry(char *name, |
275 |
int mode, |
276 |
VNetProcEntry **ret) |
277 |
{ |
278 |
return -ENXIO; |
279 |
} |
280 |
|
281 |
|
207 |
|
282 |
/* |
208 |
/* |
283 |
*---------------------------------------------------------------------- |
209 |
*---------------------------------------------------------------------- |
284 |
-- a/vmnet-only/userif.c |
210 |
++ b/vmnet-only/userif.c |
Lines 389-395
VNetUserIfReceive(VNetJack *this, // IN
Link Here
|
389 |
/* |
389 |
/* |
390 |
*---------------------------------------------------------------------- |
390 |
*---------------------------------------------------------------------- |
391 |
* |
391 |
* |
392 |
* VNetUserIfProcRead -- |
392 |
* VNetUserIfProcShow -- |
393 |
* |
393 |
* |
394 |
* Callback for read operation on this userif entry in vnets proc fs. |
394 |
* Callback for read operation on this userif entry in vnets proc fs. |
395 |
* |
395 |
* |
Lines 403-432
VNetUserIfReceive(VNetJack *this, // IN
Link Here
|
403 |
*/ |
403 |
*/ |
404 |
|
404 |
|
405 |
static int |
405 |
static int |
406 |
VNetUserIfProcRead(char *page, // IN/OUT: buffer to write into |
406 |
VNetUserIfProcShow(struct seq_file *seqf, // IN/OUT: buffer to write into |
407 |
char **start, // OUT: 0 if file < 4k, else offset into |
|
|
408 |
// page |
409 |
off_t off, // IN: offset of read into the file |
410 |
int count, // IN: maximum number of bytes to read |
411 |
int *eof, // OUT: TRUE if there is nothing more to |
412 |
// read |
413 |
void *data) // IN: client data - not used |
407 |
void *data) // IN: client data - not used |
414 |
{ |
408 |
{ |
415 |
VNetUserIF *userIf = (VNetUserIF*)data; |
409 |
VNetUserIF *userIf = (VNetUserIF*)data; |
416 |
int len = 0; |
|
|
417 |
|
410 |
|
418 |
if (!userIf) { |
411 |
if (!userIf) { |
419 |
return len; |
412 |
return 0; |
420 |
} |
413 |
} |
421 |
|
414 |
|
422 |
len += VNetPrintPort(&userIf->port, page+len); |
415 |
VNetPrintPort(&userIf->port, seqf); |
423 |
|
416 |
|
424 |
len += sprintf(page+len, "read %u written %u queued %u ", |
417 |
seq_printf(seqf, "read %u written %u queued %u ", |
425 |
userIf->stats.read, |
418 |
userIf->stats.read, |
426 |
userIf->stats.written, |
419 |
userIf->stats.written, |
427 |
userIf->stats.queued); |
420 |
userIf->stats.queued); |
428 |
|
421 |
|
429 |
len += sprintf(page+len, |
422 |
seq_printf(seqf, |
430 |
"dropped.down %u dropped.mismatch %u " |
423 |
"dropped.down %u dropped.mismatch %u " |
431 |
"dropped.overflow %u dropped.largePacket %u", |
424 |
"dropped.overflow %u dropped.largePacket %u", |
432 |
userIf->stats.droppedDown, |
425 |
userIf->stats.droppedDown, |
Lines 434-446
VNetUserIfProcRead(char *page, // IN/OUT: buffer to write into
Link Here
|
434 |
userIf->stats.droppedOverflow, |
427 |
userIf->stats.droppedOverflow, |
435 |
userIf->stats.droppedLargePacket); |
428 |
userIf->stats.droppedLargePacket); |
436 |
|
429 |
|
437 |
len += sprintf(page+len, "\n"); |
430 |
seq_printf(seqf, "\n"); |
438 |
|
431 |
|
439 |
*start = 0; |
432 |
return 0; |
440 |
*eof = 1; |
433 |
} |
441 |
return len; |
434 |
|
|
|
435 |
static int proc_userif_open(struct inode *inode, struct file *file) |
436 |
{ |
437 |
return single_open(file, VNetUserIfProcShow, PDE_DATA(inode)); |
442 |
} |
438 |
} |
443 |
|
439 |
|
|
|
440 |
static const struct file_operations proc_userif_fops = { |
441 |
.open = proc_userif_open, |
442 |
.read = seq_read, |
443 |
.llseek = seq_lseek, |
444 |
.release = seq_release, |
445 |
}; |
446 |
|
444 |
|
447 |
|
445 |
/* |
448 |
/* |
446 |
*---------------------------------------------------------------------- |
449 |
*---------------------------------------------------------------------- |
Lines 1036-1043
VNetUserIf_Create(VNetPort **ret) // OUT
Link Here
|
1036 |
* Make proc entry for this jack. |
1039 |
* Make proc entry for this jack. |
1037 |
*/ |
1040 |
*/ |
1038 |
|
1041 |
|
1039 |
retval = VNetProc_MakeEntry(userIf->port.jack.name, S_IFREG, |
1042 |
retval = VNetProc_MakeEntryOps(userIf->port.jack.name, S_IFREG, |
1040 |
&userIf->port.jack.procEntry); |
1043 |
&userIf->port.jack.procEntry, &proc_userif_fops, userIf); |
1041 |
if (retval) { |
1044 |
if (retval) { |
1042 |
if (retval == -ENXIO) { |
1045 |
if (retval == -ENXIO) { |
1043 |
userIf->port.jack.procEntry = NULL; |
1046 |
userIf->port.jack.procEntry = NULL; |
Lines 1045-1053
VNetUserIf_Create(VNetPort **ret) // OUT
Link Here
|
1045 |
kfree(userIf); |
1048 |
kfree(userIf); |
1046 |
return retval; |
1049 |
return retval; |
1047 |
} |
1050 |
} |
1048 |
} else { |
|
|
1049 |
userIf->port.jack.procEntry->read_proc = VNetUserIfProcRead; |
1050 |
userIf->port.jack.procEntry->data = userIf; |
1051 |
} |
1051 |
} |
1052 |
|
1052 |
|
1053 |
/* |
1053 |
/* |
1054 |
-- a/vmnet-only/vnetInt.h |
1054 |
++ b/vmnet-only/vnetInt.h |
Lines 171-182
VNetJack *VNetDisconnect(VNetJack *jack);
Link Here
|
171 |
|
171 |
|
172 |
void VNetSend(const VNetJack *jack, struct sk_buff *skb); |
172 |
void VNetSend(const VNetJack *jack, struct sk_buff *skb); |
173 |
|
173 |
|
174 |
int VNetProc_MakeEntry(char *name, int mode, |
174 |
int VNetProc_MakeEntryOps(char *name, int mode, |
175 |
VNetProcEntry **ret); |
175 |
VNetProcEntry **ret, |
|
|
176 |
const struct file_operations *fops, |
177 |
void *data); |
176 |
|
178 |
|
177 |
void VNetProc_RemoveEntry(VNetProcEntry *node); |
179 |
void VNetProc_RemoveEntry(VNetProcEntry *node); |
178 |
|
180 |
|
179 |
int VNetPrintJack(const VNetJack *jack, char *buf); |
181 |
void VNetPrintJack(const VNetJack *jack, struct seq_file *seqf); |
180 |
|
182 |
|
181 |
int VNet_MakeMACAddress(VNetPort *port); |
183 |
int VNet_MakeMACAddress(VNetPort *port); |
182 |
|
184 |
|
Lines 196-202
Bool VNetPacketMatch(const uint8 *destAddr, const uint8 *ifAddr,
Link Here
|
196 |
|
198 |
|
197 |
Bool VNetCycleDetectIf(const char *name, int generation); |
199 |
Bool VNetCycleDetectIf(const char *name, int generation); |
198 |
|
200 |
|
199 |
int VNetPrintPort(const VNetPort *port, char *buf); |
201 |
void VNetPrintPort(const VNetPort *port, struct seq_file *seqf); |
200 |
|
202 |
|
201 |
int VNetSnprintf(char *str, size_t size, const char *format, ...); |
203 |
int VNetSnprintf(char *str, size_t size, const char *format, ...); |
202 |
|
204 |
|
203 |
- |
|
|