diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 20:52:35 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 20:52:35 +0000 |
| commit | 46439007cf417cbd9ac8049bb4122c890097a0fa (patch) | |
| tree | 6fdb25e5f3a2b6d5657eb23b35774b631d4d97e4 /module/ip.m | |
| parent | 37da2899f40661e3e9631e497da8dc59b971cbd0 (diff) | |
20060303-partial
Diffstat (limited to 'module/ip.m')
| -rw-r--r-- | module/ip.m | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/module/ip.m b/module/ip.m new file mode 100644 index 00000000..d25278d1 --- /dev/null +++ b/module/ip.m @@ -0,0 +1,104 @@ +IP: module +{ + PATH: con "/dis/lib/ip.dis"; + + IPaddrlen: con 16; + IPv4addrlen: con 4; + IPv4off: con 12; + + IPaddr: adt { + a: array of byte; + + newv6: fn(nil: array of byte): IPaddr; + newv4: fn(nil: array of byte): IPaddr; + copy: fn(nil: self IPaddr): IPaddr; + eq: fn(nil: self IPaddr, v: IPaddr): int; + mask: fn(nil: self IPaddr, m: IPaddr): IPaddr; + maskn: fn(nil: self IPaddr, m: IPaddr): IPaddr; + isv4: fn(nil: self IPaddr): int; + ismulticast: fn(nil: self IPaddr): int; + isvalid: fn(nil: self IPaddr): int; + + v4: fn(nil: self IPaddr): array of byte; + v6: fn(nil: self IPaddr): array of byte; + class: fn(nil: self IPaddr): int; + classmask: fn(nil: self IPaddr): IPaddr; + + parse: fn(s: string): (int, IPaddr); + parsemask: fn(s: string): (int, IPaddr); + parsecidr: fn(s: string): (int, IPaddr, IPaddr); + + text: fn(nil: self IPaddr): string; + masktext: fn(nil: self IPaddr): string; + }; + + v4bcast, v4allsys, v4allrouter, v4noaddr, noaddr, allbits, selfv6, selfv4: IPaddr; + v4prefix: array of byte; + + Ifcaddr: adt { + ip: IPaddr; + mask: IPaddr; + net: IPaddr; + preflt: big; + validlt: big; + }; + + Ipifc: adt { + index: int; # /net/ipifc/N + dev: string; # bound device + addrs: list of ref Ifcaddr; + sendra: int; # !=0, send router adverts + recvra: int; # !=0, receive router adverts + mtu: int; + pktin: big; # packets in + pktout: big; # packets out + errin: big; # input errors + errout: big; # output errors + rp: IPv6rp; # IPv6 route advert params + }; + + IPv6rp: adt { + mflag: int; + oflag: int; + maxraint: int; # max route advert interval + minraint: int; # min route advert interval + linkmtu: int; + reachtime: int; + rxmitra: int; + ttl: int; + routerlt: int; + }; + + Udp4hdrlen: con 2*IPv4addrlen+2*2; + OUdphdrlen: con 2*IPaddrlen+2*2; + + Udphdrlen: con 52; + Udpraddr: con 0; + Udpladdr: con Udpraddr + IPaddrlen; + Udpifcaddr: con Udpladdr + IPaddrlen; + Udprport: con Udpifcaddr + IPaddrlen; + Udplport: con Udprport + 2; + + Udphdr: adt { + raddr: IPaddr; + laddr: IPaddr; + ifcaddr: IPaddr; + rport: int; + lport: int; + + new: fn(): ref Udphdr; + unpack: fn(a: array of byte, n: int): ref Udphdr; + pack: fn(h: self ref Udphdr, a: array of byte, n: int); + }; + + init: fn(); + readipifc: fn(net: string, index: int): (list of ref Ipifc, string); + addressesof: fn(l: list of ref Ipifc, all: int): list of IPaddr; + interfaceof: fn(l: list of ref Ipifc, ip: IPaddr): (ref Ipifc, ref Ifcaddr); + ownerof: fn(l: list of ref Ipifc, ip: IPaddr): (ref Ipifc, ref Ifcaddr); + + get2: fn(a: array of byte, o: int): int; + put2: fn(a: array of byte, o: int, v: int): int; + get4: fn(a: array of byte, o: int): int; + put4: fn(a: array of byte, o: int, v: int): int; +}; |
