Remote wake up code

xiaoxiao2021-03-06  36

Network wake up program code

Published: 2005-01-06 11:15:20

I Depending on the network wake-up program written by the network wakeup packet, only the basic code parts are implemented, and the password cannot be sent. For Linux, there must be support for the libnet library. #include #include #include main () {u_char * packet; u_short packet_size = 0; u_char enet_dst [6] = {0x00, 0x11, 0x22, 0x33,0x44 , 0x55}; u_char enet_src [6] = {0x00,0x40,0x05,0x47,0x23,0xfb}; u_char * payload; int payload_size = 0; char * dev = "eth0"; char ebuf [LIBNET_ERRBUF_SIZE]; struct libnet_link_int * S; INT I, C; PayLoad = (u_char *) malloc (102); packet_size = libnet_eth_h 102; if ((libnet_init_packet (packet_size, & packet)) == - 1) {} IF ((s = libnet_open_link_interface (dev, EBUF)) == null) {} Memset (PayLoad, 0xFF, 6); payload_size = 6; for (i = 0; i <16; i ) {memcpy (payload payload_size, enet_dst, 6); payload_size = 6; } libnet_build_ethernet (ENET_DST, ENET_SRC, 0x842, PAYLOAD, PAYLOAD_SIZE, PACKET); for (i = 0; i

Void TwakeUponlanForm :: WakeremoteComputer (ANSISTRING ipaddress, unsigned char * macaddress) {unsigned char sendbuf [102]; for (int i = 0; i <102; i ) {sendbuf [i] = (i <6)? 0xff : Macaddress [i% 6];} TMEMORYSTREAM * MEMORYSTREAM = New TMEMORYSTREAM (); MemoryStream -> Clear (); MemoryStream -> Write (SendBuf, 102); nmudp1 -> remotehost = ipaddress; // Remove IP after the network The entire complement of segment 255 // 210.45.234.255 NMUDP1 -> SendStream (MemoryStream); delete MemoryStream;} unit WakeUp; interface uses Windows, Messages, SysUtils, Dialogs, WinSock; function CheckWinSockResult (ResultCode: Integer; const FuncName: string): Integer; procedure OpenComputer (SAddr: string); const LEN_PHYSADDR = 6; implementation {$ R * .DFM} function CheckWinSockResult (ResultCode: Integer; const FuncName: string): Integer; begin if Result Code <> 0 THEN BEGIN RESULT: = WSAGetLastError; showMessage (format (# 13 # 10'windows socket function ''% s' 'error:% s (% d)', [FuncName, SySerrorMessage (Result), Result]) Abort; Else Result: = 0; End; Procedure OpenComputer (Saddr: string); // 00-B0-D0-15-86-B4 Var Wsadata: Twsadata; Msocket: Tsocket; SockAddrin: TsockAddrin; RetVal, OptVal , i: integer; macaddr: array [0..5] of byte; MagicData: array [0..101] of byte; position: longint; begin tryness; for i: = 1 TO Length (Saddr) Do IF I in [3, 6, 9, 12, 15] Then IF Saddr [i] <

转载请注明原文地址:https://www.9cbs.com/read-62330.html

New Post(0)