basin/include/basin/network.h

77 lines
1.5 KiB
C
Raw Normal View History

2016-06-24 04:41:14 +00:00
/*
* network.h
*
* Created on: Feb 22, 2016
* Author: root
*/
2019-05-02 08:09:24 +00:00
#ifndef BASIN_NETWORK_H_
#define BASIN_NETWORK_H_
2016-06-24 04:41:14 +00:00
#include <basin/inventory.h>
2019-04-14 22:57:59 +00:00
#include <avuna/pmem.h>
2017-01-07 07:38:21 +00:00
#include <openssl/rsa.h>
2016-06-24 04:41:14 +00:00
2016-12-30 03:18:53 +00:00
struct packet;
2016-06-24 04:41:14 +00:00
struct __attribute__((__packed__)) encpos {
2019-05-02 08:09:24 +00:00
int32_t z :26;
int32_t y :12;
int32_t x :26;
2016-06-24 04:41:14 +00:00
};
struct __attribute__((__packed__)) uuid {
2019-05-02 08:09:24 +00:00
uint64_t uuid1;
uint64_t uuid2;
2016-06-24 04:41:14 +00:00
};
struct entity_metadata {
2019-05-02 08:09:24 +00:00
uint8_t* metadata;
size_t metadata_size;
};
2017-01-07 07:38:21 +00:00
RSA* public_rsa;
uint8_t* public_rsa_publickey;
SSL_CTX* mojang_ctx;
void init_encryption();
2016-06-24 04:41:14 +00:00
void swapEndian(void* dou, size_t ss);
int getVarIntSize(int32_t input);
int getVarLongSize(int64_t input);
int writeVarInt(int32_t input, unsigned char* buffer);
int writeVarLong(int64_t input, unsigned char* buffer);
int readVarInt(int32_t* output, unsigned char* buffer, size_t buflen);
int readVarLong(int64_t* output, unsigned char* buffer, size_t buflen);
2019-04-14 22:57:59 +00:00
ssize_t writeString(char* input, unsigned char* buffer, size_t buflen);
2016-06-24 04:41:14 +00:00
2019-04-14 22:57:59 +00:00
int readString(struct mempool* pool, char** output, unsigned char* buffer, size_t buflen);
2016-06-24 04:41:14 +00:00
2019-04-14 22:57:59 +00:00
int readSlot(struct mempool* pool, struct slot* slot, unsigned char* buffer, size_t buflen);
2016-12-25 04:59:02 +00:00
int writeSlot(struct slot* slot, unsigned char* buffer, size_t buflen);
2016-06-24 04:41:14 +00:00
int writeVarInt_stream(int32_t input,
#ifdef __MINGW32__
2019-05-02 08:09:24 +00:00
SOCKET
2016-06-24 04:41:14 +00:00
#else
2019-05-02 08:09:24 +00:00
int
2016-06-24 04:41:14 +00:00
#endif
2019-05-02 08:09:24 +00:00
fd);
2016-06-24 04:41:14 +00:00
int readVarInt_stream(int32_t* output,
#ifdef __MINGW32__
2019-05-02 08:09:24 +00:00
SOCKET
2016-06-24 04:41:14 +00:00
#else
2019-05-02 08:09:24 +00:00
int
2016-06-24 04:41:14 +00:00
#endif
2019-05-02 08:09:24 +00:00
fd);
#endif /* BASIN_NETWORK_H_ */