Added network.obj loader to C_layer

git-svn-id: svn://kolibrios.org@8345 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
superturbocat2001 2020-12-08 19:05:25 +00:00
parent bed1d7841c
commit a327d88cb7
2 changed files with 102 additions and 0 deletions

View File

@ -0,0 +1,48 @@
format coff
use32 ; Tell compiler to use 32 bit instructions
section '.flat' code
include '../../../programs/proc32.inc'
include '../../../programs/macros.inc'
purge section,mov,add,sub
include '../../../programs/dll.inc'
purge section,mov,add,sub
public lib_init as '_networklib_init'
proc lib_init
local retval dd ?
mov [retval], eax
pusha
mcall 68, 11
test eax, eax
jnz @f
mov [retval], -1
jmp exit_init_networklib
@@:
stdcall dll.Load, @IMPORT
test eax, eax
jz exit_init_networklib
mov [retval], -1
exit_init_networklib:
popa
mov eax, [retval]
ret
endp
@IMPORT:
library networklib, 'network.obj'
import networklib, \
inet_addr, 'inet_addr', \
inet_ntoa, 'inet_ntoa', \
getaddrinfo, 'getaddrinfo', \
freeaddrinfo, 'freeaddrinfo'
public inet_addr as '_inet_addr'
public inet_ntoa as '_inet_ntoa'
public getaddrinfo as '_getaddrinfo'
public freeaddrinfo as '_freeaddrinfo'

View File

@ -0,0 +1,54 @@
#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)
struct addrinfo {
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
int ai_addrlen;
char *ai_canonname;
sockaddr *ai_addr;
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));
extern int (*getaddrinfo)(char* hostname, int servname, struct addrinfo* hints, struct addrinfo** res) __attribute__ ((stdcall));
extern void (*freeaddrinfo)(struct addrinfo* ai) __attribute__ ((stdcall));
#endif