return PLUGIN_CMD_SUCCESS;
}
+int verify_peer_ipv6 ( parameters* in, parameters* out )
+{
+ if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
+ || in->array_of_parameter[0].type != type_string ) {
+ D ( "Invalid argument\n" );
+ return PLUGIN_CMD_FAIL;
+ }
+
+ if ( out == NULL ) {
+ D ( "Invalid argument\n" );
+ return PLUGIN_CMD_FAIL;
+ }
+
+ D ( "shell command : %s\n", in->array_of_parameter[0].v_string.data );
+
+ out->number_of_parameter = 1;
+ out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (out->array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return PLUGIN_CMD_FAIL;
+ }
+ out->array_of_parameter[0].type = type_int32;
+ out->array_of_parameter[0].v_int32 = PLUGIN_RET_INVALID;
+
+ return PLUGIN_CMD_SUCCESS;
+}
+
int verify_sdbd_launch ( parameters* in, parameters* out )
{
if ( out == NULL ) {
out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
return PLUGIN_CMD_SUCCESS;
-}
\ No newline at end of file
+}
ret = convert_shell_cmd ( in, out );
} else if ( cmd == PLUGIN_SYNC_CMD_VERIFY_PEERIP ) {
ret = verify_peer_ip ( in, out );
+ } else if ( cmd == PLUGIN_SYNC_CMD_VERIFY_PEERIPV6 ) {
+ ret = verify_peer_ipv6 ( in, out );
} else if ( cmd == PLUGIN_SYNC_CMD_VERIFY_LAUNCH ) {
ret = verify_sdbd_launch ( in, out );
} else if ( cmd == PLUGIN_SYNC_CMD_VERIFY_ROOTCMD ) {
struct sockaddr_storage addr;
struct sockaddr_in *addr_v4;
struct sockaddr_in6 *addr_v6;
+ char addr_buffer[INET6_ADDRSTRLEN];
+ int validate_cmd;
D("transport: server_socket_thread() starting\n");
serverfd = sdb_port_get_tcp_listenfd();
if (addr.ss_family == AF_INET) {
addr_v4 = (struct sockaddr_in *)(&addr);
addr_str = inet_ntoa(addr_v4->sin_addr);
+ validate_cmd = PLUGIN_SYNC_CMD_VERIFY_PEERIP;
D("IPv4 connection (addr %s)\n", addr_str);
} else if (addr.ss_family == AF_INET6) {
struct in_addr in;
addr_v6 = (struct sockaddr_in6 *)(&addr);
- memcpy(&in, addr_v6->sin6_addr.s6_addr + 12, sizeof(in));
- addr_str = inet_ntoa(in);
- D("IPv6 connection, mapped IPv4 addr: %s\n", addr_str);
+ if (IN6_IS_ADDR_V4MAPPED(&addr_v6->sin6_addr)) {
+ memcpy(&in, addr_v6->sin6_addr.s6_addr + 12, sizeof(in));
+ addr_str = inet_ntoa(in);
+ validate_cmd = PLUGIN_SYNC_CMD_VERIFY_PEERIP;
+ D("IPv6 connection, mapped IPv4 addr: %s\n", addr_str);
+ } else {
+ addr_str = inet_ntop(addr.ss_family, &addr_v6->sin6_addr,
+ addr_buffer, INET6_ADDRSTRLEN);
+ validate_cmd = PLUGIN_SYNC_CMD_VERIFY_PEERIPV6;
+ D("IPv6 connection, addr: %s\n", addr_str);
+ }
} else {
D("Unknown socket family %d\n", addr.ss_family);
continue;
// Check the peer ip validation.
if (!is_emulator()
- && !request_validity_to_plugin(PLUGIN_SYNC_CMD_VERIFY_PEERIP, addr_str)) {
+ && !request_validity_to_plugin(validate_cmd, addr_str)) {
sdb_close(fd);
} else {
int ret = -1;