1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #ifndef SYSART_NETWORK_H
- #define SYSART_NETWORK_H
- #include <stdint.h>
- #include <unistd.h>
- #include "common.h"
- #define PORT "29541"
- #define PKT_SIZE_MAX 4096
- #define assert_packet_size(packet) _Static_assert( \
- sizeof(struct packet) < PKT_SIZE_MAX, "PKT_SIZE_MAX violated");
- #define PKT_TYPE_UPDATE 0x01
- struct packet_update_t {
- uint16_t size;
- uint8_t type;
- uint8_t y;
- uint8_t x;
- uint8_t ch;
- } __attribute__((__packed__));
- assert_packet_size(packet_update_t)
- #define PKT_TYPE_HELLO 0x02
- #define PKT_TYPE_INIT 0x03
- struct packet_init_t {
- uint16_t size;
- uint8_t type;
- uint8_t data[(WIDTH+1)*HEIGHT];
- } __attribute__((__packed__));
- assert_packet_size(packet_init_t)
- int recv_packet(int fd, uint8_t* buf, size_t* n);
- int recv_dump_all(int fd);
- int recv_dump(int fd);
- size_t send_packet(int fd, uint8_t* buf, size_t length);
- #endif
|