source:
PlatformSupport/WARPMAC/warpnet.c
Last change on this file was 1712, checked in by murphpo, 12 years ago | |
---|---|
|
|
File size: 1.4 KB |
Rev | Line | |
---|---|---|
[1616] | 1 | /* version 16.00 */ |
[1477] | 2 | #include "warpnet.h" |
3 | #include "warpmac.h" | |
4 | #include "warpphy.h" | |
[1494] | 5 | #include "string.h" |
[1477] | 6 | #include "xparameters.h" |
[1712] | 7 | #include <sleep.h> |
[1477] | 8 | |
9 | unsigned char arpTemplate[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x17, 0xf2, 0xc6, 0x5f, 0x30, 0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0x00, 0x17, 0xf2, 0xc6, 0x5f, 0x30, 0xC0, 0xA8, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xA8, 0xFE, 0xFE}; | |
10 | Netconfig configStruct; | |
11 | ||
[1494] | 12 | void warpnet_setMacAddr(void* macAddr){ |
13 | memcpy((void *)&configStruct.macAddr, macAddr, 6); | |
[1477] | 14 | } |
15 | ||
16 | void warpnet_sendGratuitousArp(char myID){ | |
17 | unsigned int i; | |
18 | ||
19 | //copy this node's wired MAC address into the source field of the arpTemplate | |
20 | memcpy(&arpTemplate[6],&configStruct.macAddr,6); | |
21 | memcpy(&arpTemplate[22],&configStruct.macAddr,6); | |
22 | ||
23 | arpTemplate[28]=192; | |
24 | arpTemplate[29]=168; | |
25 | arpTemplate[30]=1; | |
26 | arpTemplate[31]=200+myID; | |
27 | ||
28 | arpTemplate[38]=arpTemplate[28]; | |
29 | arpTemplate[39]=arpTemplate[29]; | |
30 | arpTemplate[40]=arpTemplate[30]; | |
31 | arpTemplate[41]=arpTemplate[31]; | |
32 | ||
33 | //This is a hack to get DMA to play nice with the packet we have created. | |
[1494] | 34 | void* bufferAddr = (void *)warpphy_getBuffAddr(0); |
35 | memcpy((void *)bufferAddr,(void *)&arpTemplate[0],sizeof(arpTemplate)); | |
[1477] | 36 | |
37 | for(i=0;i<ARPREPEAT;i++){ | |
38 | warpmac_prepPktToNetwork(bufferAddr, sizeof(arpTemplate)); | |
39 | warpmac_startPktToNetwork(sizeof(arpTemplate)); | |
40 | usleep(10); | |
41 | } | |
[1494] | 42 | } |
Note: See TracBrowser
for help on using the repository browser.