| 77 | } |
| 78 | |
| 79 | static int |
| 80 | register_client(const char *cmd __rte_unused, const char *params, |
| 81 | char *buffer __rte_unused, int buf_len __rte_unused) |
| 82 | { |
| 83 | #ifndef RTE_EXEC_ENV_WINDOWS |
| 84 | pthread_t th; |
| 85 | char data[BUF_SIZE]; |
| 86 | int fd; |
| 87 | int rc; |
| 88 | struct sockaddr_un addrs; |
| 89 | #endif /* !RTE_EXEC_ENV_WINDOWS */ |
| 90 | |
| 91 | if (!strchr(params, ':')) { |
| 92 | fprintf(stderr, "Invalid data\n"); |
| 93 | return -1; |
| 94 | } |
| 95 | #ifndef RTE_EXEC_ENV_WINDOWS |
| 96 | strlcpy(data, strchr(params, ':'), sizeof(data)); |
| 97 | memmove(data, &data[strlen(":\"")], strlen(data)); |
| 98 | if (!strchr(data, '\"')) { |
| 99 | fprintf(stderr, "Invalid client data\n"); |
| 100 | return -1; |
| 101 | } |
| 102 | *strchr(data, '\"') = 0; |
| 103 | |
| 104 | fd = socket(AF_UNIX, SOCK_SEQPACKET, 0); |
| 105 | if (fd < 0) { |
| 106 | perror("Failed to open socket"); |
| 107 | return -1; |
| 108 | } |
| 109 | addrs.sun_family = AF_UNIX; |
| 110 | strlcpy(addrs.sun_path, data, sizeof(addrs.sun_path)); |
| 111 | |
| 112 | if (connect(fd, (struct sockaddr *)&addrs, sizeof(addrs)) == -1) { |
| 113 | perror("\nClient connection error\n"); |
| 114 | close(fd); |
| 115 | return -1; |
| 116 | } |
| 117 | rc = pthread_create(&th, NULL, &legacy_client_handler, |
| 118 | (void *)(uintptr_t)fd); |
| 119 | if (rc != 0) { |
| 120 | fprintf(stderr, "Failed to create legacy client thread: %s\n", |
| 121 | strerror(rc)); |
| 122 | close(fd); |
| 123 | return -1; |
| 124 | } |
| 125 | pthread_detach(th); |
| 126 | #endif /* !RTE_EXEC_ENV_WINDOWS */ |
| 127 | return 0; |
| 128 | } |
| 129 | |
| 130 | #ifndef RTE_EXEC_ENV_WINDOWS |
| 131 | |