wake on lan - Writing Magic Packet in C++ -
i want send magic packet wake specific pc(specific mac address) connected mbed through lan . have found following code in code project.
my mac address : 00-c0-9f-bd-e4-3a (sample).....how can declare , fill in array.* have little knowledge in programming. please ignore mistake or miss interpretation.
byte magicp[102];
...
//fill in magic packet 102 bytes of data //header //fill 6 bytes 0xff (int i=0;i<6;i++) magicp[i] = 0xff; //first 6 bytes (these must repeated!!) //fill bytes 6-12 (i=0;i<6;i++) { //get 2 charachters mac address , convert int fill //magic packet magicp[i+6] = hexstrtoint(macaddr.mid(i*2,2)); } //fill remaining 90 bytes (15 time repeat) (i=0;i<15;i++) memcpy(&magicp[(i+2)*6],&magicp[6],6);
...
here have found code: http://www.codeproject.com/kb/ip/wol.aspx
i'm afraid not providing enough of code give unambiguous answer (a link might help), think don't have fill in magicp[]
- code doing you. appears have provide hexadecimal mac address input in macaddr
variable, string of 12 hexadecimal digits (e.g. "023fdca889fa").
edit: after reading link, consider hunch confirmed. code snippet shows how magicp[]
array (which holds packet payload) constructed based on provided macaddr
, in order illustrate theoretical explanation preceding it. somewhere there needs definition std::string macaddr;
enter mac address, , passed calculation method.
i suggest download full source linked project (or other open wol program), give better understanding on how pieces fit together.
Comments
Post a Comment