Check-in [6ed16db24a]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix disabling IPv6
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6ed16db24a83821e7fffbe6fe6f1b2b8fa05cf1a
User & Date: bernd 2019-08-30 21:57:43
Context
2019-09-05
20:39
Chante update-size to use a slightly smaller power than square root for size check-in: 58e9376a19 user: bernd tags: trunk
2019-08-30
21:57
Fix disabling IPv6 check-in: 6ed16db24a user: bernd tags: trunk
18:53
Experiment with flow label check-in: 69d886902f user: bernd tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to addr.fs.

117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
User dest-0key> \ pointer to dest-0key
User dest-0key< \ pointer to obtained dest-0key

: addr>6sock ( -- )
    host:key @ dest-0key< !
    host:portv6 w@ sockaddr1 port be-w!
    host:ipv6 sockaddr1 sin6_addr ip6!
    flowlabel( rng32 $7FFFF and sockaddr1 sin6_flowinfo be-l! )
    host:route $@ !temp-addr ;

: addr>4sock ( -- )
    host:key @ dest-0key< !
    host:portv4 w@ sockaddr1 port be-w!
    host:ipv4 be-ul@ sockaddr1 ipv4!
    host:route $@ !temp-addr ;







<







117
118
119
120
121
122
123

124
125
126
127
128
129
130
User dest-0key> \ pointer to dest-0key
User dest-0key< \ pointer to obtained dest-0key

: addr>6sock ( -- )
    host:key @ dest-0key< !
    host:portv6 w@ sockaddr1 port be-w!
    host:ipv6 sockaddr1 sin6_addr ip6!

    host:route $@ !temp-addr ;

: addr>4sock ( -- )
    host:key @ dest-0key< !
    host:portv4 w@ sockaddr1 port be-w!
    host:ipv4 be-ul@ sockaddr1 ipv4!
    host:route $@ !temp-addr ;

Changes to debugging.fs.

80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
debug: slurp( \ debug slurp&spit
debug: wallet( \ debug wallet stuff
debug: qr( \ qr code stuff
debug: deprecated( \ deprecated stuff
debug: unhandled( \ unhandled commands
debug: syncfile( \ synchronous file operations
debug: newvault( \ new style vault keys
debug: flowlabel( \ experiment with flow labels

-db profile( \ don't profile by default )
+db ipv6( \ ipv6 should be on by default )
+db ipv4( \ ipv4 should be on by default )
+db ipv64( \ ipv6 over 4
-db newvault( \ new vault disabled for now )
+db syncfile( \ disable async file operations for now )







<







80
81
82
83
84
85
86

87
88
89
90
91
92
93
debug: slurp( \ debug slurp&spit
debug: wallet( \ debug wallet stuff
debug: qr( \ qr code stuff
debug: deprecated( \ deprecated stuff
debug: unhandled( \ unhandled commands
debug: syncfile( \ synchronous file operations
debug: newvault( \ new style vault keys


-db profile( \ don't profile by default )
+db ipv6( \ ipv6 should be on by default )
+db ipv4( \ ipv4 should be on by default )
+db ipv64( \ ipv6 over 4
-db newvault( \ new vault disabled for now )
+db syncfile( \ disable async file operations for now )

Changes to ip.fs.

126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
    >r        r@ sin6_addr 12 + be-l!
    0         r@ sin6_addr 8 + l!
    0         r@ sin6_addr 4 + l!
    $0064ff9b r> sin6_addr be-l! ;

: sock-rest ( sockaddr -- addr u ) >r
    AF_INET6 r@ family w!
    flowlabel( )else( 0        r@ sin6_flowinfo l! )
    0        r@ sin6_scope_id l!
    r> sockaddr_in6 ;

: sock-rest4 ( sockaddr -- addr u ) >r
    AF_INET r@ family w!
    r> sockaddr_in4 ;

: my-port ( -- port )
    ipv6( )else( sockaddr_in4 )else( sockaddr_in6 ) alen !
    net2o-sock [IFDEF] no-hybrid drop [THEN] sockaddr1 alen getsockname ?ior
    sockaddr1 port be-uw@ ;

: sock[ ( -- )  query-sock ?EXIT
    ipv4( ipv6( new-udp-socket46 )else( new-udp-socket ) )else( new-udp-socket6 )
    to query-sock ;
: ]sock ( -- )  query-sock 0= ?EXIT







|








|







126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
    >r        r@ sin6_addr 12 + be-l!
    0         r@ sin6_addr 8 + l!
    0         r@ sin6_addr 4 + l!
    $0064ff9b r> sin6_addr be-l! ;

: sock-rest ( sockaddr -- addr u ) >r
    AF_INET6 r@ family w!
    0        r@ sin6_flowinfo l!
    0        r@ sin6_scope_id l!
    r> sockaddr_in6 ;

: sock-rest4 ( sockaddr -- addr u ) >r
    AF_INET r@ family w!
    r> sockaddr_in4 ;

: my-port ( -- port )
    ipv6( sockaddr_in6 )else( sockaddr_in4 ) alen !
    net2o-sock [IFDEF] no-hybrid drop [THEN] sockaddr1 alen getsockname ?ior
    sockaddr1 port be-uw@ ;

: sock[ ( -- )  query-sock ?EXIT
    ipv4( ipv6( new-udp-socket46 )else( new-udp-socket ) )else( new-udp-socket6 )
    to query-sock ;
: ]sock ( -- )  query-sock 0= ?EXIT

Changes to net2o.fs.

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
....
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
\ constants, and depending values

$2A Constant overhead \ constant overhead
$40 Constant min-size
1 Value buffers#
min-size max-size^2 lshift Value maxdata ( -- n )
maxdata overhead + Value maxpacket
maxpacket $F + -$10 and Value maxpacket-aligned
max-size^2 6 + Value chunk-p2
$10 Constant key-salt#
$10 Constant key-cksum#

\ for bigger blocks, we use use alloc+guard, i.e. mmap with a
\ guard page after the end.

................................................................................
: wait-send ( -- flag )
    ( clear-events )  timeout!  pollfds pollfd# >poll ;

: poll-sock ( -- flag )
    eval-queue  wait-send ;

User try-reads
4 Value try-read#

: read-a-packet4/6 ( -- addr u )
    pollfds [ pollfd revents ]L + w@ POLLIN and IF  try-reads off
	do-block read-a-packet
	( 0 pollfds [ pollfd revents ]L + w! ) +rec EXIT  THEN
    [IFDEF] no-hybrid
	pollfds [ pollfd 2* revents ]L + w@ POLLIN and IF  try-reads off







|







 







|







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
....
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
\ constants, and depending values

$2A Constant overhead \ constant overhead
$40 Constant min-size
1 Value buffers#
min-size max-size^2 lshift Value maxdata ( -- n )
maxdata overhead + Value maxpacket
maxpacket $F + -$10 and #1216 umax Value maxpacket-aligned
max-size^2 6 + Value chunk-p2
$10 Constant key-salt#
$10 Constant key-cksum#

\ for bigger blocks, we use use alloc+guard, i.e. mmap with a
\ guard page after the end.

................................................................................
: wait-send ( -- flag )
    ( clear-events )  timeout!  pollfds pollfd# >poll ;

: poll-sock ( -- flag )
    eval-queue  wait-send ;

User try-reads
0 Value try-read#

: read-a-packet4/6 ( -- addr u )
    pollfds [ pollfd revents ]L + w@ POLLIN and IF  try-reads off
	do-block read-a-packet
	( 0 pollfds [ pollfd revents ]L + w! ) +rec EXIT  THEN
    [IFDEF] no-hybrid
	pollfds [ pollfd 2* revents ]L + w@ POLLIN and IF  try-reads off

Changes to socks.fs.

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
    rec-droprate# IF  rng32 rec-droprate# u< IF
	    resend( ." dropping incoming packet" cr )
	    2drop #0.  THEN  THEN ;

: read-a-packet ( blockage -- addr u / 0 0 )
    >r sockaddr_in alen !
    net2o-sock [IFDEF] no-hybrid drop [THEN]
    inbuf maxpacket r> sockaddr< alen recvfrom
    dup 0< IF
	errno dup EAGAIN =  IF  2drop #0. EXIT  THEN
	#512 + negate throw  THEN
    inbuf swap  1 packetr +!  ?drop-inc
    recvfrom( ." received from: " sockaddr< alen @ .address space dup . cr )
;

[IFDEF] no-hybrid
    : read-a-packet4 ( blockage -- addr u / 0 0 )
	>r sockaddr_in alen !
	net2o-sock nip
	inbuf maxpacket r> sockaddr< alen recvfrom
	dup 0< IF
	    errno dup EAGAIN =  IF  2drop #0. EXIT  THEN
	THEN
	inbuf swap  1 packetr +!  ?drop-inc
	recvfrom( ." received from: " sockaddr< alen @ .address space dup . cr )
    ;
[THEN]
................................................................................
: ?>ipv6 ( addr u -- addr' u' )
    over family w@ AF_INET = IF  sockaddr> ipv4>ipv6  THEN ;
: ?<ipv6 ( addr u -- addr' u' )
    over family w@ AF_INET = IF  sockaddr< ipv4>ipv6  THEN ;
: info@ ( info -- addr u )
    dup ai_addr @ swap ai_addrlen l@ ;
: info>string ( info -- addr u )
    info@ ?>ipv6 ;

: -$split ( addr u char -- addr1 u1 addr2 u2 ) \ gforth-string string-split
    \G divides a string into two, with one char as separator (e.g. '?'
    \G for arguments in an HTML query)
    >r 2dup r> -scan dup >r dup IF  1-  THEN
    2swap r> /string ;
: ping ( "addr:port" -- )
................................................................................
    r> SOCK_DGRAM >hints 0 hints ai_family l!
    get-info dup >r info@ sendto
    r> freeaddrinfo ?ior ;

UValue lastaddr#
User lastn2oaddr

: insert-address ( addr u -- net2o-addr ) ?<ipv6
    address( ." Insert address " 2dup .address cr )
    lastaddr# IF  2dup lastaddr# $@ str=
	IF  2drop lastn2oaddr @ EXIT  THEN
    THEN
    2dup routes# #key dup -1 = IF
	drop s" " 2over routes# #!
	routes# #key







|











|







 







|







 







|







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
    rec-droprate# IF  rng32 rec-droprate# u< IF
	    resend( ." dropping incoming packet" cr )
	    2drop #0.  THEN  THEN ;

: read-a-packet ( blockage -- addr u / 0 0 )
    >r sockaddr_in alen !
    net2o-sock [IFDEF] no-hybrid drop [THEN]
    inbuf maxpacket-aligned r> sockaddr< alen recvfrom
    dup 0< IF
	errno dup EAGAIN =  IF  2drop #0. EXIT  THEN
	#512 + negate throw  THEN
    inbuf swap  1 packetr +!  ?drop-inc
    recvfrom( ." received from: " sockaddr< alen @ .address space dup . cr )
;

[IFDEF] no-hybrid
    : read-a-packet4 ( blockage -- addr u / 0 0 )
	>r sockaddr_in alen !
	net2o-sock nip
	inbuf maxpacket-aligned r> sockaddr< alen recvfrom
	dup 0< IF
	    errno dup EAGAIN =  IF  2drop #0. EXIT  THEN
	THEN
	inbuf swap  1 packetr +!  ?drop-inc
	recvfrom( ." received from: " sockaddr< alen @ .address space dup . cr )
    ;
[THEN]
................................................................................
: ?>ipv6 ( addr u -- addr' u' )
    over family w@ AF_INET = IF  sockaddr> ipv4>ipv6  THEN ;
: ?<ipv6 ( addr u -- addr' u' )
    over family w@ AF_INET = IF  sockaddr< ipv4>ipv6  THEN ;
: info@ ( info -- addr u )
    dup ai_addr @ swap ai_addrlen l@ ;
: info>string ( info -- addr u )
    info@ ipv6( ?>ipv6 ) ;

: -$split ( addr u char -- addr1 u1 addr2 u2 ) \ gforth-string string-split
    \G divides a string into two, with one char as separator (e.g. '?'
    \G for arguments in an HTML query)
    >r 2dup r> -scan dup >r dup IF  1-  THEN
    2swap r> /string ;
: ping ( "addr:port" -- )
................................................................................
    r> SOCK_DGRAM >hints 0 hints ai_family l!
    get-info dup >r info@ sendto
    r> freeaddrinfo ?ior ;

UValue lastaddr#
User lastn2oaddr

: insert-address ( addr u -- net2o-addr ) ipv6( ?<ipv6 )
    address( ." Insert address " 2dup .address cr )
    lastaddr# IF  2dup lastaddr# $@ str=
	IF  2drop lastn2oaddr @ EXIT  THEN
    THEN
    2dup routes# #key dup -1 = IF
	drop s" " 2over routes# #!
	routes# #key