mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
changes from plan 9
This commit is contained in:
parent
bd8cb1a5b3
commit
66209ac0fe
2 changed files with 33 additions and 77 deletions
|
@ -2,6 +2,21 @@
|
|||
#include <libc.h>
|
||||
#include <ip.h>
|
||||
|
||||
void
|
||||
hnputv(void *p, uvlong v)
|
||||
{
|
||||
uchar *a;
|
||||
|
||||
a = p;
|
||||
a[0] = v>>56;
|
||||
a[1] = v>>48;
|
||||
a[2] = v>>40;
|
||||
a[3] = v>>32;
|
||||
a[4] = v>>24;
|
||||
a[5] = v>>16;
|
||||
a[6] = v>>8;
|
||||
a[7] = v;
|
||||
}
|
||||
|
||||
void
|
||||
hnputl(void *p, uint v)
|
||||
|
@ -25,6 +40,24 @@ hnputs(void *p, ushort v)
|
|||
a[1] = v;
|
||||
}
|
||||
|
||||
uvlong
|
||||
nhgetv(void *p)
|
||||
{
|
||||
uchar *a;
|
||||
uvlong v;
|
||||
|
||||
a = p;
|
||||
v = (uvlong)a[0]<<56;
|
||||
v |= (uvlong)a[1]<<48;
|
||||
v |= (uvlong)a[2]<<40;
|
||||
v |= (uvlong)a[3]<<32;
|
||||
v |= a[4]<<24;
|
||||
v |= a[5]<<16;
|
||||
v |= a[6]<<8;
|
||||
v |= a[7]<<0;
|
||||
return v;
|
||||
}
|
||||
|
||||
uint
|
||||
nhgetl(void *p)
|
||||
{
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
#pragma src "/sys/src/libip"
|
||||
#pragma lib "libip.a"
|
||||
|
||||
enum
|
||||
{
|
||||
IPaddrlen= 16,
|
||||
IPv4addrlen= 4,
|
||||
IPv4off= 12,
|
||||
IPllen= 4,
|
||||
};
|
||||
|
||||
/*
|
||||
* for reading /net/ipifc
|
||||
*/
|
||||
typedef struct Ipifc Ipifc;
|
||||
typedef struct Ipifcs Ipifcs;
|
||||
|
||||
struct Ipifc
|
||||
{
|
||||
char dev[64];
|
||||
uchar ip[IPaddrlen];
|
||||
uchar mask[IPaddrlen];
|
||||
uchar net[IPaddrlen]; /* ip & mask */
|
||||
Ipifc *next;
|
||||
};
|
||||
|
||||
struct Ipifcs
|
||||
{
|
||||
Ipifc *first;
|
||||
Ipifc *last;
|
||||
};
|
||||
|
||||
/*
|
||||
* user level udp headers
|
||||
*/
|
||||
enum
|
||||
{
|
||||
Udphdrsize= 36, /* size of a Udphdr */
|
||||
};
|
||||
|
||||
typedef struct Udphdr Udphdr;
|
||||
struct Udphdr
|
||||
{
|
||||
uchar raddr[IPaddrlen]; /* remote address and port */
|
||||
uchar laddr[IPaddrlen]; /* local address and port */
|
||||
uchar rport[2];
|
||||
uchar lport[2];
|
||||
};
|
||||
|
||||
uchar* defmask(uchar*);
|
||||
void maskip(uchar*, uchar*, uchar*);
|
||||
int eipconv(va_list*, Fconv*);
|
||||
ulong parseip(uchar*, char*);
|
||||
ulong parseipmask(uchar*, char*);
|
||||
int parseether(uchar*, char*);
|
||||
int myipaddr(uchar*, char*);
|
||||
int myetheraddr(uchar*, char*);
|
||||
|
||||
void readipifc(char*, Ipifcs*);
|
||||
|
||||
void hnputl(void*, uint);
|
||||
void hnputs(void*, ushort);
|
||||
uint nhgetl(void*);
|
||||
ushort nhgets(void*);
|
||||
|
||||
#define ipcmp(x, y) memcmp(x, y, IPaddrlen)
|
||||
#define ipmove(x, y) memmove(x, y, IPaddrlen)
|
||||
|
||||
extern uchar IPv4bcast[IPaddrlen];
|
||||
extern uchar IPv4bcastobs[IPaddrlen];
|
||||
extern uchar IPv4allsys[IPaddrlen];
|
||||
extern uchar IPv4allrouter[IPaddrlen];
|
||||
extern uchar IPnoaddr[IPaddrlen];
|
||||
extern uchar v4prefix[IPaddrlen];
|
||||
extern uchar IPallbits[IPaddrlen];
|
||||
|
||||
#define CLASS(p) ((*(uchar*)(p))>>6)
|
Loading…
Reference in a new issue