1 #include <sys/socket.h>
9 #define VSYS_PACKETSEER "/vsys/fd_packetseer.control"
11 int (*socket_orig)(int f, int p, int s);
14 socket_orig = &socket;
15 printf("Stored value of socket");
18 int socket(int f, int p, int s)
21 void *handle = dlopen("/lib/libc.so.6",RTLD_LAZY);
23 fprintf(stderr,"Error loading libc.so.6\n");
26 socket_orig = dlsym(handle, "socket");
28 fprintf(stderr,"Error loading socket symbol\n");
35 struct sockaddr_un addr;
38 printf("[packetseer] Rerouting socket call via vsys...\n");
39 sfd = socket(AF_UNIX, SOCK_STREAM, 0);
41 perror("Could not create UNIX socket\n");
45 memset(&addr, 0, sizeof(struct sockaddr_un));
47 addr.sun_family = AF_UNIX;
48 strncpy(addr.sun_path, VSYS_PACKETSEER,
49 sizeof(addr.sun_path) - 1);
51 if (connect(sfd, (struct sockaddr *) &addr,
52 sizeof(struct sockaddr_un)) == -1) {
53 perror("Could not connect to Vsys control socket");
57 remotefd = receive_fd(sfd);
58 printf("Received fd %d",remotefd);
62 return (*socket_orig)(f, p, s);