~thestr4ng3r/chiaki

7870a28cdd5e42e36e10a55f27b05fc2bdb22562 — Florian Märkl 3 months ago a44000e
Fix Discovery in CLI
1 files changed, 10 insertions(+), 4 deletions(-)

M cli/src/discover.c
M cli/src/discover.c => cli/src/discover.c +10 -4
@@ 142,13 142,19 @@ CHIAKI_EXPORT int chiaki_cli_cmd_discover(ChiakiLog *log, int argc, char *argv[]
		return 1;
	}

	((struct sockaddr_in *)host_addr)->sin_port = htons(CHIAKI_DISCOVERY_PORT_PS4); // TODO: IPv6, PS5, should probably use the service

	ChiakiDiscoveryPacket packet;
	memset(&packet, 0, sizeof(packet));
	packet.cmd = CHIAKI_DISCOVERY_CMD_SRCH;

	chiaki_discovery_send(&discovery, &packet, host_addr, host_addr_len);
	packet.protocol_version = CHIAKI_DISCOVERY_PROTOCOL_VERSION_PS4;
	((struct sockaddr_in *)host_addr)->sin_port = htons(CHIAKI_DISCOVERY_PORT_PS4);
	err = chiaki_discovery_send(&discovery, &packet, host_addr, host_addr_len);
	if(err != CHIAKI_ERR_SUCCESS)
		CHIAKI_LOGE(log, "Failed to send discovery packet for PS4: %s", chiaki_error_string(err));
	packet.protocol_version = CHIAKI_DISCOVERY_PROTOCOL_VERSION_PS5;
	((struct sockaddr_in *)host_addr)->sin_port = htons(CHIAKI_DISCOVERY_PORT_PS5);
	err = chiaki_discovery_send(&discovery, &packet, host_addr, host_addr_len);
	if(err != CHIAKI_ERR_SUCCESS)
		CHIAKI_LOGE(log, "Failed to send discovery packet for PS5: %s", chiaki_error_string(err));

	while(1)
		sleep(1); // TODO: wtf