hc
2024-03-22 a0752693d998599af469473b8dc239ef973a012f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<errno.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<sys/time.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<unistd.h>
#include<fcntl.h>
#include<pthread.h>
#define MAXLINE 4096
 
int main(int argc, char** argv)
{
    int   sockfd, n;
    char  recvline[4096], sendline[4096];
    struct sockaddr_in  servaddr;
   int fd, size, send_count = 0;
   char buf[200];
   char recvbuffer[200];
   char sendbuf[2] = {0xc0, 0x00};
 
    if( argc != 2){
        printf("usage: ./client <ipaddress>\n");
        return 0;
    }
 
    if( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0){
        printf("create socket error: %s(errno: %d)\n", strerror(errno),errno);
        return 0;
    }
 
    memset(&servaddr, 0, sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_port = htons(5150);
    if ( inet_pton(AF_INET, argv[1], &servaddr.sin_addr) <= 0) {
        printf("inet_pton error for %s\n",argv[1]);
        return 0;
    }
 
    char timestamp = 0;
    setsockopt(sockfd, SOL_SOCKET, SO_TIMESTAMP, (const char*)&timestamp, sizeof(char));
 
    if (connect(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr)) < 0) {
        printf("connect error: %s (errno: %d)\n",strerror(errno),errno);
        return 0;
    }
 
    printf("connected to server \n");
 
     //fd = open("/sys/kernel/debug/tcp_keepalive_param/tcp_param", O_RDONLY);
     fd = open("/proc/tcp_params", O_RDONLY);
 
    //fgets(sendline, 4096, stdin);
    while (1) {
       if (send_count == 5) {
           memset(buf, 0, 200);
           memset(recvbuffer, 0, 200);
           lseek(fd, 0, SEEK_SET);
           size = read(fd, buf, 200);
           system("wl_cy tcpka_conn_mode 1");
            usleep(200*200);
            printf("buf: %s\n", buf);
           system(buf);
            usleep(200*200);
           system("wl_cy tcpka_conn_enable 1 1 10 1 8");
            usleep(200*200);
           system("wl_cy wowl 131094");
            usleep(200*200);
           printf("wl_cy wowl_pattern add 54 0x07 0x313233\n");
           system("wl_cy wowl_pattern add 54 0x07 0x313233");
            usleep(200*200);
           printf("wl_cy wowl_pattern add 66 0x07 0x313233\n");
           system("wl_cy wowl_pattern add 66 0x07 0x313233");
            usleep(200*200);
           system("wl_cy wowl_activate 1");
            usleep(200*200);
            system("wl_cy PM 2");
            usleep(200*200);
           system("wl_cy hostsleep 1");
            usleep(200*200);
           system("killall wpa_supplicant");
            usleep(200*200);
           system("poweroff");
           while (1)
                sleep(1);
       }
 
        if (send(sockfd, "hellp tcp", 9, 0) != 9) {
           printf("send msg error: %s(errno: %d)\n", strerror(errno), errno);
           return 0;
        }
        send_count++;
        sleep(1);
    }
    close(sockfd);
    return 0;
}