2020-12-08 20:05:25 +01:00
|
|
|
#ifndef __NETWORK_H
|
|
|
|
#define __NETWORK_H
|
|
|
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
#define EAI_ADDRFAMILY 1
|
|
|
|
#define EAI_AGAIN 2
|
|
|
|
#define EAI_BADFLAGS 3
|
|
|
|
#define EAI_FAIL 4
|
|
|
|
#define EAI_FAMILY 5
|
|
|
|
#define EAI_MEMORY 6
|
|
|
|
#define EAI_NONAME 8
|
|
|
|
#define EAI_SERVICE 9
|
|
|
|
#define EAI_SOCKTYPE 10
|
|
|
|
#define EAI_BADHINTS 12
|
|
|
|
#define EAI_PROTOCOL 13
|
|
|
|
#define EAI_OVERFLOW 14
|
|
|
|
|
|
|
|
// Flags for addrinfo
|
|
|
|
#define AI_PASSIVE 1
|
|
|
|
#define AI_CANONNAME 2
|
|
|
|
#define AI_NUMERICHOST 4
|
|
|
|
#define AI_NUMERICSERV 8
|
|
|
|
#define AI_ADDRCONFIG 0x400
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
struct ARP_entry{
|
|
|
|
unsigned int IP;
|
|
|
|
unsigned char MAC[6];
|
|
|
|
unsigned short status;
|
|
|
|
unsigned short TTL;
|
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
2021-01-05 17:19:36 +01:00
|
|
|
struct addrinfo{
|
2020-12-08 20:05:25 +01:00
|
|
|
int ai_flags;
|
|
|
|
int ai_family;
|
|
|
|
int ai_socktype;
|
|
|
|
int ai_protocol;
|
|
|
|
int ai_addrlen;
|
|
|
|
char *ai_canonname;
|
2021-01-05 17:19:36 +01:00
|
|
|
struct sockaddr *ai_addr;
|
2020-12-08 20:05:25 +01:00
|
|
|
struct addrinfo *ai_next;
|
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
extern int networklib_init ();
|
|
|
|
extern int (*inet_addr)(const char* hostname) __attribute__ ((stdcall));
|
|
|
|
extern char* (*inet_ntoa)(int ip_addr) __attribute__ ((stdcall));
|
2021-01-05 17:19:36 +01:00
|
|
|
extern int (*getaddrinfo)(char* hostname, char *servname, struct addrinfo* hints, struct addrinfo** res) __attribute__ ((stdcall));
|
2020-12-08 20:05:25 +01:00
|
|
|
extern void (*freeaddrinfo)(struct addrinfo* ai) __attribute__ ((stdcall));
|
|
|
|
|
|
|
|
#endif
|