72 lines
2.7 KiB
C
72 lines
2.7 KiB
C
/* *****************************************************************************
|
|
* libp7/packetio.h -- libp7 Packet I/O interface.
|
|
* Copyright (C) 2016-2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
|
|
*
|
|
* This file is part of libp7.
|
|
* libp7 is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation; either version 3.0 of the License,
|
|
* or (at your option) any later version.
|
|
*
|
|
* libp7 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 Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with libp7; if not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* The Protocol 7.00 definition used to be there, but since the library should
|
|
* now be able to manage several protocols, they are in separate headers.
|
|
* ************************************************************************** */
|
|
#ifndef LIBP7_PACKETIO_H
|
|
# define LIBP7_PACKETIO_H
|
|
# include <libp7/protocol/seven.h>
|
|
|
|
/* ************************************************************************** */
|
|
/* Common structures */
|
|
/* ************************************************************************** */
|
|
/* For now, libp7 has a common packet representation for all protocols.
|
|
* It contains all the possible fields, but depending on the protocol and the
|
|
* packet type, only some of them are actually set.
|
|
*
|
|
* Here is the structure: */
|
|
|
|
typedef struct {
|
|
/* main info */
|
|
unsigned int type;
|
|
int extended;
|
|
|
|
/* error, termination, check */
|
|
int code, initial;
|
|
|
|
/* commands */
|
|
int ow; int mcstype; p7uint_t filesize;
|
|
char *args[6]; char _argsdata[6][MAX_CMDARG_SIZE + 1];
|
|
p7uint_t uploadsize, loadaddr, straddr; /* 0x56 */
|
|
|
|
/* data */
|
|
p7ushort_t id, total;
|
|
unsigned char data[MAX_RAWDATA_SIZE];
|
|
p7ushort_t data_size;
|
|
|
|
/* server information */
|
|
p7_server_t info;
|
|
|
|
/* screen */
|
|
p7_pictype_t pictype;
|
|
unsigned int height, width;
|
|
uint8_t vram[MAX_VRAM_SIZE];
|
|
} p7_packet_t;
|
|
/* ************************************************************************** */
|
|
/* Get private members from the handle */
|
|
/* ************************************************************************** */
|
|
/* Since the handle structure is private, here are methods to extract
|
|
* things from it. */
|
|
|
|
extern const p7_stream_t *p7_get_stream(p7_handle_t *handle);
|
|
extern const p7_server_t *p7_get_info(p7_handle_t *handle);
|
|
extern const p7_packet_t *p7_get_response(p7_handle_t *handle);
|
|
|
|
#endif /* LIBP7_PACKETIO_H */
|