summaryrefslogtreecommitdiff
path: root/libstd
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-06-21 23:17:01 -0700
committerOri Bernstein <ori@eigenstate.org>2015-06-21 23:17:01 -0700
commit526479d1064ab5daadf7b2a1aad5a00153a5d455 (patch)
tree04987c6101d5e3c7e948a8e2c3bf3a7377b06927 /libstd
parent23223a7626a6ccea0598937a94d15709afd0eb20 (diff)
downloadmc-526479d1064ab5daadf7b2a1aad5a00153a5d455.tar.gz
Add ipv6 support to dial.
Currently untested.
Diffstat (limited to 'libstd')
-rw-r--r--libstd/dial+posixy.myr20
-rw-r--r--libstd/sys+linux-x64.myr7
2 files changed, 20 insertions, 7 deletions
diff --git a/libstd/dial+posixy.myr b/libstd/dial+posixy.myr
index e63df76..9c6e817 100644
--- a/libstd/dial+posixy.myr
+++ b/libstd/dial+posixy.myr
@@ -31,7 +31,9 @@ var inited = false
/* takes a plan 9 style dial string */
const dial = {str
var proto, host, port
- var sa : sys.sockaddr_in /* we only support inet sockets right now.. ugh. */
+ var sa4 : sys.sockaddr_in /* we only support inet sockets right now.. ugh. */
+ var sa6 : sys.sockaddr_in6 /* we only support inet sockets right now.. ugh. */
+ var sa : sys.sockaddr#
var sock
match parsedial(str)
@@ -41,19 +43,23 @@ const dial = {str
match getaddr(host)
| `Ipv4 bits:
- sa.fam = sys.Afinet
- sa.addr = bits
- sa.port = hosttonet(port)
+ sa4.fam = sys.Afinet
+ sa4.addr = bits
+ sa4.port = hosttonet(port)
+ sa = &sa4 castto(sys.sockaddr#)
| `Ipv6 bits:
- -> `Fail "ipv6 not yet supported"
+ sa6.fam = sys.Afinet6
+ sa6.addr = bits
+ sa6.port = hosttonet(port)
+ sa = &sa6 castto(sys.sockaddr#)
;;
-
sock = sys.socket(sa.fam, proto, 0)
+
if sock < 0
-> `Fail "failed to connect to socket"
;;
var err
- err = sys.connect(sock, (&sa) castto(sys.sockaddr#), sizeof(sys.sockaddr_in))
+ err = sys.connect(sock, sa, sizeof(sys.sockaddr_in))
if err < 0
sys.close(sock)
-> `Fail "Failed to bind socket"
diff --git a/libstd/sys+linux-x64.myr b/libstd/sys+linux-x64.myr
index 4a3e3ea..de2d1e8 100644
--- a/libstd/sys+linux-x64.myr
+++ b/libstd/sys+linux-x64.myr
@@ -109,6 +109,13 @@ pkg sys =
zero : byte[8]
;;
+ type sockaddr_in6 = struct
+ fam : sockfam
+ port : uint16
+ addr : byte[16]
+ scope : uint32
+ ;;
+
type sockaddr_storage = struct
fam : sockfam
__align : uint32