mirror of
https://github.com/aaru-dps/aaruremote.git
synced 2025-12-16 19:24:37 +00:00
Send device info list response.
This commit is contained in:
@@ -83,5 +83,6 @@ typedef struct DeviceInfoList
|
|||||||
|
|
||||||
DeviceInfoList* ListDevices();
|
DeviceInfoList* ListDevices();
|
||||||
void FreeDeviceInfoList(DeviceInfoList* start);
|
void FreeDeviceInfoList(DeviceInfoList* start);
|
||||||
|
uint16_t DeviceInfoListCount(DeviceInfoList* start);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -44,3 +44,18 @@ void FreeDeviceInfoList(DeviceInfoList* start)
|
|||||||
free(current);
|
free(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t DeviceInfoListCount(DeviceInfoList* start)
|
||||||
|
{
|
||||||
|
uint16_t count = 0;
|
||||||
|
DeviceInfoList* current;
|
||||||
|
|
||||||
|
while(start)
|
||||||
|
{
|
||||||
|
current = start;
|
||||||
|
start = current->next;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
33
main.c
33
main.c
@@ -43,6 +43,9 @@ int main()
|
|||||||
char* dummy_buf;
|
char* dummy_buf;
|
||||||
int skip_next_hdr;
|
int skip_next_hdr;
|
||||||
struct DeviceInfoList* deviceInfoList;
|
struct DeviceInfoList* deviceInfoList;
|
||||||
|
DicPacketResListDevs* deviceInfoResponsePacket;
|
||||||
|
int i;
|
||||||
|
uint64_t n;
|
||||||
|
|
||||||
printf("DiscImageChef Remote Server %s\n", DICMOTE_VERSION);
|
printf("DiscImageChef Remote Server %s\n", DICMOTE_VERSION);
|
||||||
printf("Copyright (C) 2019 Natalia Portillo\n");
|
printf("Copyright (C) 2019 Natalia Portillo\n");
|
||||||
@@ -317,8 +320,38 @@ int main()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deviceInfoResponsePacket = malloc(sizeof(DicPacketResListDevs));
|
||||||
|
deviceInfoResponsePacket->devices = DeviceInfoListCount(deviceInfoList);
|
||||||
|
|
||||||
|
n = sizeof(DicPacketResListDevs) + deviceInfoResponsePacket->devices * sizeof(DeviceInfo);
|
||||||
|
dummy_buf = malloc(n);
|
||||||
|
((DicPacketResListDevs*)dummy_buf)->hdr.len = n;
|
||||||
|
((DicPacketResListDevs*)dummy_buf)->devices = deviceInfoResponsePacket->devices;
|
||||||
|
free(deviceInfoResponsePacket);
|
||||||
|
deviceInfoResponsePacket = (DicPacketResListDevs*)dummy_buf;
|
||||||
|
dummy_buf = NULL;
|
||||||
|
|
||||||
|
deviceInfoResponsePacket->hdr.id = DICMOTE_PACKET_ID;
|
||||||
|
deviceInfoResponsePacket->hdr.version = DICMOTE_PACKET_VERSION;
|
||||||
|
deviceInfoResponsePacket->hdr.packet_type = DICMOTE_PACKET_TYPE_RESPONSE_LIST_DEVICES;
|
||||||
|
|
||||||
|
// Save list start
|
||||||
|
dummy_buf = (char*)deviceInfoList;
|
||||||
|
long off = sizeof(DicPacketResListDevs);
|
||||||
|
|
||||||
|
while(deviceInfoList)
|
||||||
|
{
|
||||||
|
memcpy(((char*)deviceInfoResponsePacket) + off, &deviceInfoList->this, sizeof(DeviceInfo));
|
||||||
|
deviceInfoList = deviceInfoList->next;
|
||||||
|
off += sizeof(DeviceInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
deviceInfoList = (struct DeviceInfoList*)dummy_buf;
|
||||||
FreeDeviceInfoList(deviceInfoList);
|
FreeDeviceInfoList(deviceInfoList);
|
||||||
|
|
||||||
|
write(cli_sock, deviceInfoResponsePacket, deviceInfoResponsePacket->hdr.len);
|
||||||
|
free(deviceInfoResponsePacket);
|
||||||
|
|
||||||
printf("List devices not yet implemented, skipping...\n");
|
printf("List devices not yet implemented, skipping...\n");
|
||||||
continue;
|
continue;
|
||||||
case DICMOTE_PACKET_TYPE_RESPONSE_LIST_DEVICES:
|
case DICMOTE_PACKET_TYPE_RESPONSE_LIST_DEVICES:
|
||||||
|
|||||||
Reference in New Issue
Block a user