mirror of
https://github.com/aaru-dps/aaruremote.git
synced 2025-12-16 11:14:35 +00:00
Separate hello packet creation for platform.
This commit is contained in:
@@ -497,5 +497,6 @@ int32_t SendSdhciCommand(int device_fd,
|
||||
uint32_t* response,
|
||||
uint32_t* duration,
|
||||
uint32_t* sense);
|
||||
DicPacketHello* GetHello();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@ if (NOT "${CMAKE_SYSTEM}" MATCHES "Linux")
|
||||
return()
|
||||
endif ()
|
||||
|
||||
set(PLATFORM_SOURCES list_devices.c linux.h device.c scsi.c usb.c ieee1394.c pcmcia.c ata.c sdhci.c)
|
||||
set(PLATFORM_SOURCES list_devices.c linux.h device.c scsi.c usb.c ieee1394.c pcmcia.c ata.c sdhci.c ../unix/hello.c)
|
||||
CHECK_LIBRARY_EXISTS("udev" udev_new "" HAS_UDEV)
|
||||
CHECK_INCLUDE_FILES("linux/mmc/ioctl.h" HAVE_MMC_IOCTL_H)
|
||||
|
||||
|
||||
33
main.c
33
main.c
@@ -23,9 +23,6 @@
|
||||
#include <netinet/in.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
// TODO: Packet for NOP
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -74,7 +71,6 @@ int main()
|
||||
struct ifaddrs* ifa;
|
||||
struct ifaddrs* ifa_start;
|
||||
struct sockaddr_in cli_addr, serv_addr;
|
||||
struct utsname utsname;
|
||||
uint32_t duration;
|
||||
uint32_t sdhci_response[4];
|
||||
uint32_t sense;
|
||||
@@ -84,15 +80,16 @@ int main()
|
||||
printf("DiscImageChef Remote Server %s\n", DICMOTE_VERSION);
|
||||
printf("Copyright (C) 2019 Natalia Portillo\n");
|
||||
|
||||
ret = uname(&utsname);
|
||||
pkt_server_hello = GetHello();
|
||||
|
||||
if(ret)
|
||||
if(!pkt_server_hello)
|
||||
{
|
||||
printf("Error %d getting system version.\n", errno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Running under %s %s (%s).\n", utsname.sysname, utsname.release, utsname.machine);
|
||||
printf(
|
||||
"Running under %s %s (%s).\n", pkt_server_hello->sysname, pkt_server_hello->release, pkt_server_hello->machine);
|
||||
|
||||
printf("Opening socket.\n");
|
||||
sock_fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
@@ -146,28 +143,6 @@ int main()
|
||||
return 1;
|
||||
}
|
||||
|
||||
pkt_server_hello = malloc(sizeof(DicPacketHello));
|
||||
|
||||
if(!pkt_server_hello)
|
||||
{
|
||||
printf("Fatal error %d allocating memory.\n", errno);
|
||||
close(sock_fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
memset(pkt_server_hello, 0, sizeof(DicPacketHello));
|
||||
|
||||
pkt_server_hello->hdr.id = DICMOTE_PACKET_ID;
|
||||
pkt_server_hello->hdr.len = sizeof(DicPacketHello);
|
||||
pkt_server_hello->hdr.version = DICMOTE_PACKET_VERSION;
|
||||
pkt_server_hello->hdr.packet_type = DICMOTE_PACKET_TYPE_HELLO;
|
||||
strncpy(pkt_server_hello->application, DICMOTE_NAME, sizeof(DICMOTE_NAME));
|
||||
strncpy(pkt_server_hello->version, DICMOTE_VERSION, sizeof(DICMOTE_VERSION));
|
||||
pkt_server_hello->max_protocol = DICMOTE_PROTOCOL_MAX;
|
||||
strncpy(pkt_server_hello->sysname, utsname.sysname, 255);
|
||||
strncpy(pkt_server_hello->release, utsname.release, 255);
|
||||
strncpy(pkt_server_hello->machine, utsname.machine, 255);
|
||||
|
||||
pkt_nop = malloc(sizeof(DicPacketNop));
|
||||
|
||||
if(!pkt_nop)
|
||||
|
||||
52
unix/hello.c
Normal file
52
unix/hello.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of the DiscImageChef Remote Server.
|
||||
* Copyright (c) 2019 Natalia Portillo.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../dicmote.h"
|
||||
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
DicPacketHello* GetHello()
|
||||
{
|
||||
struct utsname utsname;
|
||||
int ret;
|
||||
DicPacketHello* pkt_server_hello;
|
||||
|
||||
ret = uname(&utsname);
|
||||
|
||||
if(ret) { return 0; }
|
||||
|
||||
pkt_server_hello = malloc(sizeof(DicPacketHello));
|
||||
|
||||
if(!pkt_server_hello) { return 0; }
|
||||
|
||||
memset(pkt_server_hello, 0, sizeof(DicPacketHello));
|
||||
|
||||
pkt_server_hello->hdr.id = DICMOTE_PACKET_ID;
|
||||
pkt_server_hello->hdr.len = sizeof(DicPacketHello);
|
||||
pkt_server_hello->hdr.version = DICMOTE_PACKET_VERSION;
|
||||
pkt_server_hello->hdr.packet_type = DICMOTE_PACKET_TYPE_HELLO;
|
||||
strncpy(pkt_server_hello->application, DICMOTE_NAME, sizeof(DICMOTE_NAME));
|
||||
strncpy(pkt_server_hello->version, DICMOTE_VERSION, sizeof(DICMOTE_VERSION));
|
||||
pkt_server_hello->max_protocol = DICMOTE_PROTOCOL_MAX;
|
||||
strncpy(pkt_server_hello->sysname, utsname.sysname, 255);
|
||||
strncpy(pkt_server_hello->release, utsname.release, 255);
|
||||
strncpy(pkt_server_hello->machine, utsname.machine, 255);
|
||||
|
||||
return pkt_server_hello;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ if (NOT WII)
|
||||
return()
|
||||
endif ()
|
||||
|
||||
set(PLATFORM_SOURCES wii.c)
|
||||
set(PLATFORM_SOURCES wii.c hello.c)
|
||||
|
||||
add_executable(dicremote-wii ${PLATFORM_SOURCES})
|
||||
set_target_properties(dicremote-wii PROPERTIES LINK_FLAGS -L$ENV{DEVKITPRO}/libogc/lib/wii/)
|
||||
|
||||
45
wii/hello.c
Normal file
45
wii/hello.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of the DiscImageChef Remote Server.
|
||||
* Copyright (c) 2019 Natalia Portillo.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../dicmote.h"
|
||||
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
DicPacketHello* GetHello()
|
||||
{
|
||||
DicPacketHello* pkt_server_hello;
|
||||
|
||||
pkt_server_hello = malloc(sizeof(DicPacketHello));
|
||||
|
||||
if(!pkt_server_hello) { return 0; }
|
||||
|
||||
memset(pkt_server_hello, 0, sizeof(DicPacketHello));
|
||||
|
||||
pkt_server_hello->hdr.id = DICMOTE_PACKET_ID;
|
||||
pkt_server_hello->hdr.len = sizeof(DicPacketHello);
|
||||
pkt_server_hello->hdr.version = DICMOTE_PACKET_VERSION;
|
||||
pkt_server_hello->hdr.packet_type = DICMOTE_PACKET_TYPE_HELLO;
|
||||
strncpy(pkt_server_hello->application, DICMOTE_NAME, sizeof(DICMOTE_NAME));
|
||||
strncpy(pkt_server_hello->version, DICMOTE_VERSION, sizeof(DICMOTE_VERSION));
|
||||
pkt_server_hello->max_protocol = DICMOTE_PROTOCOL_MAX;
|
||||
strncpy(pkt_server_hello->sysname, "TODO: Gecko", 255);
|
||||
strncpy(pkt_server_hello->release, "TODO: Unknown", 255);
|
||||
strncpy(pkt_server_hello->machine, "TODO: Unknown", 255);
|
||||
|
||||
return pkt_server_hello;
|
||||
}
|
||||
Reference in New Issue
Block a user