nr0 doesn't show up (netrom)
A message that is not in the archive (sent off-list or not yet received): S1752195AbZK3HxQ/[email protected]
On Fedora 12. Kernel 2.6.31.5-127.fc12.i686 I install libax25,ax25-apps, and ax25-tools via yum. I created my nrports file as follows. nrattach says it's creating nr0, but then it says it creates nr0 again. ifconfig never shows nr0.
(Actually, otherwise this combination of software is working correctly so far, and I am able to connect to ax25 stations over actual RF.)
[root@junglevision ax25]# modprobe netrom [root@junglevision ax25]# cat nrports
netrom KE6I-10 BERK 236 Berkeley
netrom2 KE6I-11 BRKBBS 236 Berkeley BBS [root@junglevision ax25]# nrattach -i 192.168.0.10 netrom NET/ROM port netrom bound to device nr0 [root@junglevision ax25]# nrattach -i 192.168.0.11 netrom2 NET/ROM port netrom2 bound to device nr0 [root@junglevision ax25]# /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:13:20:12:68:A4
inet addr:75.101.49.34 Bcast:75.101.49.63 Mask:255.255.255.224
inet6 addr: fe80::213:20ff:fe12:68a4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2572078 errors:0 dropped:0 overruns:0 frame:0
TX packets:4287069 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:682027869 (650.4 MiB) TX bytes:4048632775 (3.7 GiB)lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2318600 errors:0 dropped:0 overruns:0 frame:0
TX packets:2318600 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3228300929 (3.0 GiB) TX bytes:3228300929 (3.0 GiB)virbr0 Link encap:Ethernet HWaddr 5A:7F:B7:E8:BC:C4
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:26 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:5517 (5.3 KiB)
[root@junglevision ax25]#
Messages doesn't show much. Just
NET: Registered protocol family 3
NET: Registered protocol family 6
A little bit more information.
I can bring up a nr0 device by doing
/sbin/ifconfig nr0 up 192.168.0.10
But any attempts to set the hardware address fail.
/sbin/ifconfig nr0 hw ax25 KE6I-10 192.168.0.10
Give me
SIOCSIFHWADDR: Invalid argument
I don't think it works this way, because netromd then tells me "no NET/ROM ports defined"
Oops. Looking through the proper archive of linux hams I found this.
Quoted 8 lines
nrattach.c#ifndef notdef if (!startiface(dev, hp)) return 1; #endif printf("NET/ROM port %s bound to device %s\n", argv[optind], dev);
Quoted 4 lines
However, if notdef is defined somewhere, there will be again no netrom device created, but a false success message will still be displayed.
I don't really understand the purpose of this.
I think somebody just screwed up and committed this by accident. Just remove that ifdef and endif. (I suggest.)
For the record, I actually managed to connect to another NETROM site over actual RF after fixing nrattach.c and recompiling. It's acting kind of slow but I need to do some conventional AX25 tweaking first before I can claim anything is actually broken here. This is a new install, using the rc2 files on the site.
I'm still dependent on the BSD style pty's, and it looks like the utilities have been updated to get around this, so I have to put in some time to see if I can run a completely stock kernel from Fedora, which would be nice.
Generally, it's looking good so far though.
ax25ipd.c routing
How does this work with multiple connections?
Suppose I have two incoming connections
My call is K1BBS.
route K1PAR 1.0.0.0
route K2PAR 2.0.0.0 d
Then suppose K1USR at K1PAR does a connect to K1BBS.
What seems to happen is I see packets come in from K1USR to K1BBS. But then when packets go back out, they go back to K2PAR, even though
he's at K1PAR. At least that's what I think is happening.
Shouldn't ax25d.c keep a record of which IP callsigns came from, so that way when it needs to send a packet back they go to the right place? I'm not 100% sure of this, but it seems like the lookup only checks
the route commands. I only see one call to route_add in config.c.
Shouldn't it 'route_add' every time a callsign comes in axip? Or the only way to make this work is to run a separate ax25ipd for every connection.
Re: ax25ipd.c routing
On 2009-12-07 02:30:27 -0800, Cathryn Mataga <[email protected]> wrote in <[email protected]>:
Quoted 10 lines
How does this work with multiple connections?
Suppose I have two incoming connections
My call is K1BBS.route K1PAR 1.0.0.0
route K2PAR 2.0.0.0 dThen suppose K1USR at K1PAR does a connect to K1BBS.
Quoted 8 lines
What seems to happen is I see packets come in from K1USR to K1BBS. But then when packets go back out, they go back to K2PAR, even though
he's at K1PAR. At least that's what I think is happening.Shouldn't
ax25d.ckeep a record of which IP callsigns came from, so that way when it needs to send a packet back they go to the right place? I'm not 100% sure of this, but it seems like the lookup only checks
the route commands. I only see one call toroute_addinconfig.c.
ax25ipd in it's current version does not learn routes.
In fact, route_add() is only being called from the config file. .../ax25-apps/ax25ipd$ grep route_add *.cconfig.c: route_add(tip, tcall, uport, flags);
routing.c:void route_add(unsigned char *ip, unsigned char *call, int udpport, .../ax25-apps/ax25ipd$
That's why your packet goes out via the default connection (route K2PAR 2.0.0.0 d).
At db0fhn we have since several years a modified version:
...ax25ipd-test/ax25ipd$ grep route_add *.c
config.c: route_add(&tip, htonl(tmask), fqdn, tcall, (flags | AXRT_FORCE_LEARN | (match_all_ssids ? AXRT_MATCH_ALL_SSIDS : 0)));
process.c: if (route_add(ip_addr, 0xffffffffUL, 0, f, 0) < 0) {process.c:fprintf(stderr, "debug: route_add %s failed\n", call_to_a(from_addr(buf))); process.c:fprintf(stderr, "debug: route_add %s ok\n", call_to_a(from_addr(buf))); routing.c:int route_add(ip, netmask, fqdn, call, flags) ...ax25ipd-test/ax25ipd$
The code I wrote is highly stable. But I personaly found the code quite
ugly: ax25ipd became a monster. That's the reason why it did not enter the main stream yet.
From the example ax25ipd.conf:
[..]
# route <destcall> [<destaddr>|<network>] [udp dst-port] [flags] # # Users behind NAT routers may hav a different source-port. # # Valid flags are: # b - allow broadcasts to be transmitted via this route # d - this route is the default route # p - permanent # #route vk2sut-0 44.136.8.68 b #route vk5xxx 44.136.188.221 b #route vk2abc 44.1.1.1 #route db0aaa 127.0.0.1 p #route db0aab 10.1.2.3 udp 20005 # For dyndns hosts: IP may change, but resolving of the hostname # has to point to the same IP address where IP frames come from. # If flag "p" is set, the host is static (resolved once, on startup). #route db0abc db0abc.de # # Autolearn new (not configured) hosts. # Valid flags in this case: "b", "p" (learn once). #route db0abc db0abc.de # # Autolearn new (not configured) hosts. # Valid flags in this case: "b", "p" (learn once). #route * 0.0.0.0/0 b #route * 10.1.0.0/16 #route * 10.2.2.2/32 # accept db0yyy only when coming vom 10.3.3.0/24 #route db0yyy 10.3.3.0/24
At db0fhn, that ax25ipd version is used for various purposes:
root 2648 0.1 0.0 1692 240 ? S Aug19 262:49 /usr/sbin/ax25ipd --nofork -c /etc/ax25/ax25ipd-xnet.conf root 3199 0.0 0.0 3488 732 ? Ss Aug19 101:58 /usr/bin/SCREEN -dmS ax25ipd -c /etc/ax25/ax25ipd.screen root 3201 0.0 0.0 1692 248 pts/1 Ss+ Aug19 31:42 /usr/sbin/ax25ipd --nofork -c /etc/ax25/ax25ipd-pptpvpn.conf root 3202 0.0 0.0 1696 252 pts/2 Ss+ Aug19 68:27 /usr/sbin/ax25ipd --nofork -c /etc/ax25/ax25ipd-openvpn.conf root 3203 0.0 0.0 1696 272 pts/3 Ss+ Aug19 120:03 /usr/sbin/ax25ipd --nofork -c /etc/ax25/ax25ipd-echolink.conf root 3643 0.0 0.0 1692 236 pts/4 Ss+ Aug19 15:45 ax25ipd --nofork -c /etc/ax25/ax25ipd-aprs-db0vox.conf root 3644 0.0 0.0 1692 232 pts/5 Ss+ Aug19 2:12 ax25ipd --nofork -c /etc/ax25/ax25ipd-aprs-db0sao.conf root 3645 0.0 0.0 1692 236 pts/6 Ss+ Aug19 3:16 ax25ipd --nofork -c /etc/ax25/ax25ipd-aprs-db0prt.conf root 3649 0.0 0.0 1692 236 pts/7 Ss+ Aug19 11:33 ax25ipd --nofork -c /etc/ax25/ax25ipd-aprs-db0zka.conf
Btw, the dyndns feature which Bernard Pidoux f6bvp reminded to a few weeks ago is still the my queue.
I've -mostly theoretical- problems with it because it resolves on a periodical basis, which means that if the dns currently is broken, it even affects LAN connections served by ax25ipd by introducing periodical delays.
Bernard changed route_add(), as also my test-version does, but in a slightly different way.
The test-code also implements periodical dyndns resolving, but iirc, it does not work correctly (can't remember).
For informational purpose, I did a diff between the current cvs head and the test version. The test-version startet on an older ax25ipd version and only fixes but no cosmetic changes have been manually applied (also i.e. still not the unix98 pty support). Here it is:
http://db0fhn.efi.fh-nuernberg.de/~dl9sau/ax25ipd-current-to-test--2009-12-07.diff
73,
- Thomas dl9sau
Re: ax25ipd.c routing
Quoted 11 lines
ax25ipd in it's current version does not learn routes.
In fact,route_add()is only being called from the config file. .../ax25-apps/ax25ipd$ greproute_add*.cconfig.c:route_add(tip, tcall, uport, flags);
routing.c:void route_add(unsigned char *ip, unsigned char *call, int udpport, .../ax25-apps/ax25ipd$That's why your packet goes out via the default connection (route K2PAR 2.0.0.0 d).
Thank you. This confirms my understanding of the current issue.
Quoted 11 lines
Btw, the dyndns feature which Bernard Pidoux f6bvp reminded to a few weeks ago is still the my queue.
I've -mostly theoretical- problems with it because it resolves on a periodical basis, which means that if the dns currently is broken, it even affects LAN connections served by ax25ipd by introducing periodical delays.
Bernard changedroute_add(), as also my test-version does, but in a slightly different way.
The test-code also implements periodical dyndns resolving, but iirc, it does not work correctly (can't remember).
Hmm.
What about this for both my and Bernard's issue.
1. If a callsign is received from the ip of a known route but is not the callsign of a known route, or the callsign of the local station, then add this callsign
and the route pointer to a binary tree. If the callsign was previously in the tree, then the new route replaces the old one, if different.
2. in call_to_ip, before it checks the default route, it checks this binary tree for this callsign, and returns the route it came from. If the callsign is not found, the default route is used.
3. Callsigns never expire. The tree just grows. 4. SSID's are matched as unique callsigns. 5. If the callsign is that of a ddns route,
Fork, check dns, and if the ip matches the dns, update the route_table_entry->ip_addr
6. If a process is already forked for updating the ip of a particular route, do not fork another one. Add a variable to route_table_entry to verify this.
Does this make sense? Or are there other issues I'm unaware of?
Quoted 6 lines
For informational purpose, I did a diff between the current cvs head and the test version. The test-version startet on an older ax25ipd version and only fixes but no cosmetic changes have been manually applied (also i.e. still not the unix98 pty support). Here it is:
http://db0fhn.efi.fh-nuernberg.de/~dl9sau/ax25ipd-current-to-test--2009-12-07.diff
Alright, thanks. I'll take a look.
Re: ax25ipd.c routing
Hello,
Quoted 8 lines
What about this for both my and Bernard's issue.
1. If a callsign is received from the ip of a known route but is not the callsign of a known route, or the callsign of the local station, then add this callsign
and the route pointer to a binary tree. If the callsign was previously in the tree, then the new route replaces the old one, if different.
yes. And if not set to "permanent" (p).
Quoted 4 lines
2. in
call_to_ip, before it checks the default route, it checks this binary tree for this callsign, and returns the route it came from. If the callsign is not found, the default route is used.
yes.
Quoted 1 line
3. Callsigns never expire. The tree just grows.
yes.
Quoted 1 line
4. SSID's are matched as unique callsigns.
call + same-ssid unique.
If you like to route i.E. ssid 0 to 15 permanently to a specific host, it's only 16 lines. That's ok.
Quoted 3 lines
5. If the callsign is that of a ddns route, Fork, check dns, and if the ip matches the dns, update the
route_table_entry->ip_addr
No. Don't fork.
The best solution is a posix thread, which does periodicaly the resolving, and to use a mutex-lock in the special case an IP address is currently being looked up.
Quoted 3 lines
6. If a process is already forked for updating the ip of a particular route, do not fork another one. Add a variable to
route_table_entryto verify this.
A single thread is sufficient.
73,
- Thomas
Re: ax25ipd.c routing
Hi,
Excuse me if I'm barking up the wrong tree.
I've been using ax25ipd for many years and haven't observed any routing problems. For many years the system ran fbb (40 ports - ax25, rose and telnet) and fpacnode, as well as xastir (aprs).
I was a beta tester for some modifications implemented by vk5asf back in 2005 and haven't used the stock sources since then. I know that f6bvp has also introduced some fixes. I always get my sources from the f6bvp web site.
Also, I don't remember how far back it was introduced, or by whom, but specifying an ssid of zero causes that route to respond to any ssid from that callsign. I used a mixture of generic (-0) and directed ssid's.
Quoted 1 line
From my ax25ipd.conf.
route vk2tv-3 gizmo udp 10093 d
route vk2tv-8 gizmo udp 10093 b
route kp4djt-0 w4bgh.no-ip.org udp 10095 b route k4gbb-9 k4gbb.serveftp.com udp 10093 route k4gbb-12 k4gbb.serveftp.com udp 10094 route k4gbb-14 k4gbb.serveftp.com udp 10093 b route f6bvp-0 82.66.61.83 udp 10093 b route gb7yb-0 62.49.59.169 udp 10093 b route gb7ydx-1 gb7ydx.ath.cx udp 10093 b #route kd4yal-0 kd4yal.servebbs.org udp 10093 b route kd4yal-0 97.97.181.223 udp 10093 b route f4bwt-0 62.147.157.243 udp 10093 b route vk2dot-0 220.245.50.125 udp 93 b route vk2xb-0 122.252.16.174 udp 10093 b route vk7hdm-0 203.55.215.234 udp 93 b route g3ldi-0 84.92.112.67 udp 10093 b route ti2has-0 201.200.228.134 udp 10093 b route w4min-0 74.174.224.115 udp 10093 b route vk2wet-0 tankremote.no-ip.org udp 10093 b #route vk2bvo 44.1.1.1
Ray vk2tv
Quoted 65 lines · Thomas Osterried
Hello,
Quoted 9 lines
What about this for both my and Bernard's issue.
1. If a callsign is received from the ip of a known route but is not the callsign of a known route, or the callsign of the local station, then add this callsign
and the route pointer to a binary tree. If the callsign was previously in the tree, then the new route replaces the old one, if different.yes. And if not set to "permanent" (p).
Quoted 5 lines
2. in
call_to_ip, before it checks the default route, it checks this binary tree for this callsign, and returns the route it came from. If the callsign is not found, the default route is used.yes.
Quoted 2 lines
3. Callsigns never expire. The tree just grows.
yes.
Quoted 2 lines
4. SSID's are matched as unique callsigns.
call + same-ssid unique.
If you like to route i.E. ssid 0 to 15 permanently to a specific host, it's only 16 lines. That's ok.Quoted 4 lines
5. If the callsign is that of a ddns route, Fork, check dns, and if the ip matches the dns, update the
route_table_entry->ip_addrNo. Don't fork.
The best solution is a posix thread, which does periodicaly the resolving, and to use a mutex-lock in the special case an IP address is currently being looked up.Quoted 4 lines
6. If a process is already forked for updating the ip of a particular route, do not fork another one. Add a variable to
route_table_entryto verify this.A single thread is sufficient.
73,
- Thomas
--
To unsubscribe from this list: send the line "unsubscribe linux-hams" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: ax25ipd.c routing
Quoted 3 lines
Cathryn, do you have the possibility to do a packet-trace?
Alright, here's a case where it doesn't work. I connect to my partner's system at gvcity.ampr.org. His callsign is KG6BAJ. I log into his system via telnet with my call KE6I. He's running "Xrouter v186b". I'm connected to 'port 6' on his system, so I do the command.
C 6 KE6I-9
This is a trace from my side with stock ax25ipd. His site connects to mine using my call KE6I-15. My side is trying to send the packet back, but they're all going to the default route, so it keeps trying and never gets a response. On the connecting side, I just see a timeout. From gvcity.ampr.org I never see the 'uronode' message.
axip: fm KE6I-15 to KE6I-9 ctl SABM+
axip: fm KE6I-9 to KE6I-15 ctl UA-
axip: fm KE6I-9 to KE6I-15 ctl I00^ pid=F0(Text) len 102 0000 URONode v1.0.7 - Welcome to XX#XX-#.Welcome KE6I in Berkeley Cal 0040 ifornia. Type 'CONV' for live chat...
axip: fm KE6I-9 to KE6I-15 ctl I01+ pid=F0(Text) len 4
0000 .=>
axip: fm KE6I-15 to KE6I-9 ctl SABM+
axip: fm KE6I-9 to KE6I-15 ctl UA-
axip: fm KE6I-9 to KE6I-15 ctl I00^ pid=F0(Text) len 102 0000 URONode v1.0.7 - Welcome to XX#XX-#.Welcome KE6I in Berkeley Cal 0040 ifornia. Type 'CONV' for live chat...
axip: fm KE6I-9 to KE6I-15 ctl I01+ pid=F0(Text) len 4
0000 .=>
axip: fm KE6I-15 to KE6I-9 ctl SABM+
axip: fm KE6I-9 to KE6I-15 ctl UA-
axip: fm KE6I-9 to KE6I-15 ctl I00^ pid=F0(Text) len 102 0000 URONode v1.0.7 - Welcome to XX#XX-#.Welcome KE6I in Berkeley Cal 0040 ifornia. Type 'CONV' for live chat...
axip: fm KE6I-9 to KE6I-15 ctl I01+ pid=F0(Text) len 4
0000 .=>
axip: fm KE6I-15 to KE6I-9 ctl SABM+
axip: fm KE6I-9 to KE6I-15 ctl UA-
axip: fm KE6I-9 to KE6I-15 ctl I00^ pid=F0(Text) len 102 0000 URONode v1.0.7 - Welcome to XX#XX-#.Welcome KE6I in Berkeley Cal 0040 ifornia. Type 'CONV' for live chat...
axip: fm KE6I-9 to KE6I-15 ctl I01+ pid=F0(Text) len 4
0000 .=>
axip: fm KE6I-15 to KE6I-9 ctl SABM+
axip: fm KE6I-9 to KE6I-15 ctl UA-
axip: fm KE6I-9 to KE6I-15 ctl I00^ pid=F0(Text) len 102 0000 URONode v1.0.7 - Welcome to XX#XX-#.Welcome KE6I in Berkeley Cal 0040 ifornia. Type 'CONV' for live chat...
axip: fm KE6I-9 to KE6I-15 ctl I01+ pid=F0(Text) len 4
0000 .=>
axip: fm KE6I-15 to KE6I-9 ctl SABM+
axip: fm KE6I-9 to KE6I-15 ctl UA-
axip: fm KE6I-9 to KE6I-15 ctl I00^ pid=F0(Text) len 102 0000 URONode v1.0.7 - Welcome to XX#XX-#.Welcome KE6I in Berkeley Cal 0040 ifornia. Type 'CONV' for live chat...
axip: fm KE6I-9 to KE6I-15 ctl I01+ pid=F0(Text) len 4
0000 .=>
axip: fm KE6I-15 to KE6I-9 ctl SABM+
axip: fm KE6I-9 to KE6I-15 ctl UA-
axip: fm KE6I-9 to KE6I-15 ctl I00^ pid=F0(Text) len 102 0000 URONode v1.0.7 - Welcome to XX#XX-#.Welcome KE6I in Berkeley Cal 0040 ifornia. Type 'CONV' for live chat...
axip: fm KE6I-9 to KE6I-15 ctl I01+ pid=F0(Text) len 4
0000 .=>
axip: fm KE6I-15 to KE6I-9 ctl SABM+
axip: fm KE6I-9 to KE6I-15 ctl UA-
axip: fm KE6I-9 to KE6I-15 ctl I00^ pid=F0(Text) len 102 0000 URONode v1.0.7 - Welcome to XX#XX-#.Welcome KE6I in Berkeley Cal 0040 ifornia. Type 'CONV' for live chat...
axip: fm KE6I-9 to KE6I-15 ctl I01+ pid=F0(Text) len 4
0000 .=>
axip: fm KE6I-15 to KE6I-9 ctl SABM+
axip: fm KE6I-9 to KE6I-15 ctl UA-
axip: fm KE6I-9 to KE6I-15 ctl I00^ pid=F0(Text) len 102 0000 URONode v1.0.7 - Welcome to XX#XX-#.Welcome KE6I in Berkeley Cal 0040 ifornia. Type 'CONV' for live chat...
axip: fm KE6I-9 to KE6I-15 ctl I01+ pid=F0(Text) len 4
0000 .=>
axip: fm KE6I-15 to KE6I-9 ctl SABM+
axip: fm KE6I-9 to KE6I-15 ctl UA-
axip: fm KE6I-9 to KE6I-15 ctl I00^ pid=F0(Text) len 102 0000 URONode v1.0.7 - Welcome to XX#XX-#.Welcome KE6I in Berkeley Cal 0040 ifornia. Type 'CONV' for live chat...
axip: fm KE6I-9 to KE6I-15 ctl I01+ pid=F0(Text) len 4
0000 .=>
I did make the change as I mentioned. It's not too difficult as most of the bits and pieces already exist in the test version.
In this case, the connection works because the return packets
go to the right place. I see the 'uronode' message and am
able to disconnect without error.
axip: fm KE6I-15 to KE6I-9 ctl SABM+
axip: fm KE6I-9 to KE6I-15 ctl UA-
axip: fm KE6I-9 to KE6I-15 ctl I00^ pid=F0(Text) len 102 0000 URONode v1.0.7 - Welcome to XX#XX-#.Welcome KE6I in Berkeley Cal 0040 ifornia. Type 'CONV' for live chat...
axip: fm KE6I-9 to KE6I-15 ctl I01+ pid=F0(Text) len 4
0000 .=>
axip: fm KE6I-15 to KE6I-9 ctl RR2-
axip: fm KE6I-15 to KE6I-9 ctl I20^ pid=F0(Text) len 2
0000 ?.
axip: fm KE6I-9 to KE6I-15 ctl I12^ pid=F0(Text) len 177
0000 Commands:.?, BBS, Bye, Connect, CONVers, Escape, Finger, Help, H 0040 Ost, Info.INTerfaces, Links, MHeard, MSg, Nodes, Ping, Quit, Rou 0080 tes, SEssions, Status.Telnet, Users, Version, Who
axip: fm KE6I-9 to KE6I-15 ctl I13+ pid=F0(Text) len 4 0000 .=>
axip: fm KE6I-15 to KE6I-9 ctl RR4-
axip: fm KE6I-15 to KE6I-9 ctl I41^ pid=F0(Text) len 2 0000 b.
axip: fm KE6I-9 to KE6I-15 ctl I24^ pid=F0(Text) len 24 0000 KE6I-15 de XX#XX-#.73!
axip: fm KE6I-9 to KE6I-15 ctl DISC+
axip: fm KE6I-15 to KE6I-9 ctl UA-
Here's my ax25ipd.conf file
socket ip
mode tnc
device /dev/ttyq7
#device /dev/ptyad
mycall KE6I-9
speed 9600
loglevel 4
broadcast QST-0 NODES-0
# route WH6IO 71.198.33.249 # route WH6IO-8 71.198.33.249 d route WH6IO-8 75.106.121.56 route WH6IO 75.106.121.56 route AA6HF-4 44.17.0.128* route AA6HF 44.17.0.128 d route KG6BAJ-2 44.2.14.1 route KG6BAJ-1 44.2.14.1 route KG6BAJ 44.2.14.1
Stock ax25ipd works for all outgoing connections from Linux. Also if kg6baj connects to me from his system using his callsign it works correctly because the return packets go back to him. It's only the users his system that have trouble connecting. That's the problem I see here.
Re: ax25ipd.c routing
In reply to a message not in the archivehttp://www.mataga.net/mataga/ax25ipdke6i.diff
Here's a link to the change I made to ax25ipd. This is a diff
versus the rc2 version. It hasn't been tested that much,
but it does work for me.
It's pretty basic. It reads ip addresses and callsigns using code taken from the test version. But then it stores the matching route/Callsign in a btree, and uses this btree to retrieve the correct ip during sending. It does fix the issue shown in the logs I created earlier.
It doesn't deal with the route IP's changing. Currently, I just print a message when this happens. It only addresses the issue of user callsigns.
Re: ax25ipd.c routing
In reply to a message not in the archivehttp://hamradio.ke6i.com/ax25ipddyn.patch
I made another patch. This one against 0.0.8.rc2 again. This combines my original change with the dynamic DNS patch.
I know this is one of those 'big patches' that everyone hates, so, sorry. I tested this a bit, but I think I'll let this run on my AX25 system for about a week before I try to make it official.
Mostly, I'm posting this in case anyone is curious. This does the change, as requested for the DNS patch, to make it use a thread. I use pthread_create to create the thread. Also when IP's are changed or referenced, the code uses pthread_mutex_lock to protect the change. I had to touch a few places in the code for this.
This is my idea for the 'when to check dns' issue.
1. If a packet comes in with the callsign of a listed route, that does not match the expected IP, trigger a DNS lookup, provided a DNS lookup has not happened within 5 minutes.
2. Otherwise check DNS every hour. 60*60 seconds.
3. If the 'P' flag is set never check DNS.
This is not really well-tested, though I have seen IP's update via DNS in the log. I believe that a packet should come in relatively soon after an ip change and this should allow for a relatively quick
response. The 5 minute delay is to prevent DNS from getting
hit too hard if a lot of these packets arrive.
The 1 hour check is a fallback, in the event that both systems are set to Dynamic DNS, and both change at about the same time, or if other mysterious circumstances occur.
I tried to save the idea of the original dyndns patch of checking DNS later if DNS fails on startup. In this situation, I set the IP to 0. A check is added to prevent packets from being sent to ip=0.
PATCH 1/1 ax25ipd
I've been sitting on this code for about a week, and it's been running fine here. I've made a few small changes, mostly to the comments.
1. This patch adds the ability to route packets over axip links that are not from the gateway callsign.
2. Integrates the Dynamic DNS patch and uses mutex and a thread as suggested.
3. If DNS fails during startup for a route, the IP of a route is set
to 0. Then later, after about an hour or so, DNS for the route is checked again.
4. ax25ipd.conf has two new flags for routes. l and p.
route KE6I-1 0.0.0.0 l
The route to KE6I-1 will be updated based on the IP addresses of incoming packets.
route KE6I-2 ke6i.ampr.org p
the 'p' flag forces the code to not recheck DNS later for
this route. If DNS fails at startup, however, DNS will
be checked until it succeeds, and then DNS will not be checked again.
ax25ipd should route as before, except in the case when packets not from the callsign of the route but from the same IP would have gone to the default route, they now will go to the ip from which they originate. (Ugh, that's an awkward sentence.)
Anyway, let me know what you think, good or bad.
Binary files ax25ipd/ax25ipd and ax25ipddyn/ax25ipd differ
ax25ipd.h +14 -3
@@ -118,6 +118,11 @@#define AXRT_BCAST 1#define AXRT_DEFAULT 2 +#define AXRT_PERMANENT 4 +#define AXRT_LEARN 8 + + +#define IPSTORAGESIZE 6/* Bytes needed for call_to_ip */ /* start external prototypes */ /* end external prototypes */
@@ -133,12 +138,16 @@/* routing.c */ void route_init (void ); -void route_add (unsigned char *,unsigned char *,int ,unsigned int ); +void route_add (char *,unsigned char *,unsigned char *,int ,unsigned int ); +int route_ipmatch (struct sockaddr_in *,unsigned char *); +unsigned char *retrieveip (unsigned char *,unsigned char *); +void route_process (struct sockaddr_in *,unsigned char *);void bcast_add (unsigned char *); -unsigned char *call_to_ip (unsigned char *); +unsigned char *call_to_ip (unsigned char *,unsigned char *);int is_call_bcast (unsigned char *);void send_broadcast (unsigned char *,int );void dump_routes (void ); +void update_dns (unsigned );/* config.c */ void config_init (void );
@@ -151,11 +160,13 @@/* process.c */ void process_init (void );void from_kiss (unsigned char *,int ); -void from_ip (unsigned char *,int ); +void from_ip (unsigned char *,int ,struct sockaddr_in *);/* void do_broadcast(void); where did this go ?? xxx */ void do_beacon (void );int addrmatch (unsigned char *,unsigned char *); +int addrcompare (unsigned char *,unsigned char *);unsigned char *next_addr (unsigned char *); +unsigned char *from_addr (unsigned char *);void add_crc (unsigned char *,int );void dump_ax25frame (char *,unsigned char *,int );
Binary files ax25ipd/ax25ipd.o and ax25ipddyn/ax25ipd.o differ Binary files ax25ipd/bpqether.o and ax25ipddyn/bpqether.o differ
config.c +31 -8
@@ -292,6 +292,8 @@return 0 ; }else if (strcmp (p,"route" ) ==0 ) { +char *thost; + uport =0 ; flags =0 ;
@@ -305,15 +307,26 @@ q =strtok (NULL ," \t\n\r" );if (q ==NULL )return -1 ; - he =gethostbyname (q); -if (he !=NULL ) { -memcpy (tip, he->h_addr_list[0 ],4 ); - }else {/* maybe user specified a numeric addr? */ - j =inet_addr (q); -if (j ==-1 ) -return -5 ;/* if -1, bad deal! */ + thost =strdup (q); + j =inet_addr (q); +if (j !=-1 ){/* maybe user specified a numeric addr? */ + flags |=AXRT_PERMANENT ;/* Prevent useless dns check on dotted ip */ memcpy (tip, (char *) &j,4 ); +if (!j){/* IP of 0.0.0.0. Learn from incoming packets */ + flags |=AXRT_LEARN ; + } + } +else { + he =gethostbyname (q); +if (he !=NULL ) { +memcpy (tip, he->h_addr_list[0 ],4 ); + }else { + j =inet_addr ("0.0.0.0" );/* try to rescue this idea of checking later.*/ +memcpy (tip, (char *) &j,4 ); +fprintf (stderr,"ax25ipd: %s host IP address unknown - will probe it again later\n" ,thost); + } } +while ((q =strtok (NULL ," \t\n\r" )) !=NULL ) {if (strcmp (q,"udp" ) ==0 ) {
@@ -334,9 +347,19 @@if (strchr (q,'d' )) { flags |=AXRT_DEFAULT ; } + +/* Test for "permanent" flag */ +if (strchr (q,'p' )) { + flags |=AXRT_PERMANENT ; + } +/* Test for "learn" flag */ +if (strchr (q,'l' )) { + flags |=AXRT_LEARN ; + } } } -route_add (tip, tcall, uport, flags); +route_add (thost, tip, tcall, uport, flags); +free (thost);return 0 ; }else if (strcmp (p,"broadcast" ) ==0 ) {
Binary files ax25ipd/config.o and ax25ipddyn/config.o differ Binary files ax25ipd/crc.o and ax25ipddyn/crc.o differ
.deps/routing.Po +8 -1
@@ -52,7 +52,8 @@ /usr/include/termios.h /usr/include/bits/termios.h \ /usr/include/sys/termios.h /usr/include/sys/time.h \ /usr/local/include/netax25/daemon.h /usr/include/syslog.h \ - /usr/include/sys/syslog.h /usr/include/bits/syslog-path.h + /usr/include/sys/syslog.h /usr/include/bits/syslog-path.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h /usr/include/stdio.h:
@@ -277,3 +278,9 @@ /usr/include/sys/syslog.h: /usr/include/bits/syslog-path.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/bits/sched.h:
io.c +7 -3
@@ -378,10 +378,11 @@if (nb ==0 ) {fflush (stdout);fflush (stderr); +update_dns (60 *60 );// Once/hour /* just so we go back to the top of the loop! */ continue ; } - +update_dns (60 *60 );// once/hour if (FD_ISSET (ttyfd, &readfds)) { do { n = read(ttyfd, buf, MAX_FRAME);
@@ -418,7 +419,7 @@LOGL4 ("udpdata from=%s port=%d l=%d\n" , (char *)inet_ntoa (from. sin_addr),ntohs (from. sin_port), n); stats.udp_in++;if (n >0 ) -from_ip (buf, n); +from_ip (buf, n, &from); } }/* if udp_mode */
@@ -434,7 +435,7 @@LOGL4 ("ipdata from=%s l=%d, hl=%d\n" , (char *)inet_ntoa (from. sin_addr), n, hdr_len); stats.ip_in++;if (n > hdr_len) -from_ip (buf + hdr_len, n - hdr_len); +from_ip (buf + hdr_len, n - hdr_len, &from); }#ifdef USE_ICMP if (FD_ISSET (icmpsock, &readfds)) {
@@ -461,6 +462,9 @@if (l <=0 )return ; +if (* (unsigned *) targetip ==0 ){/* If the ip is set to 0 don't send anything. I'm not sure what sending to 0 does, but I don't like the idea. */ +return ; + }memcpy ((char *) &to.sin_addr, targetip,4 ); memcpy((char *) &to.sin_port,
Binary files ax25ipd/io.o and ax25ipddyn/io.o differ Binary files ax25ipd/kiss.o and ax25ipddyn/kiss.o differ
Makefile +1 -1
@@ -92,7 +92,7 @@ AX25_LIB = -lax25 CC = gcc CCDEPMODE = depmode=gcc3 -CFLAGS = -g -O2 -Wall +CFLAGS = -g -O2 -Wall -pthread CPP = gcc -E CPPFLAGS = CYGPATH_W = echo
process.c +59 -2
100 lines not on this page · raw message
Binary files ax25ipd/process.o and ax25ipddyn/process.o differ
routing.c +251 -7
336 lines not on this page · raw message
Binary files ax25ipd/routing.o and ax25ipddyn/routing.o differ
run.bat +2 -0
@@ -0,0 +1,2 @@ +killall ax25ipd +./ax25ipd -c /etc/ax25/ax25ipd.conf
PATCH 1/1 call.c
This is a patch to call.c. This is against ax25-apps-0.0.8-rc2. Only one file is changed, call.c
1. Now supports UTF8 or IBM850 as the encoding style over AX25. 1a. Attention was paid to make sure that wide characters worked with East Asian fonts.
2. Now the screen can be resized.
correctly. The program no longer crashes when it is resized.
3. Added a scrollback buffer. Use the up and down arrow keys or the page up/page down keys to scroll through history. After the screen begins scrolling, press 'up arrow' to view history.
4. Many visual quirks have been fixed.
I tested with East-Asian fonts myself, and I tested with international latin characters by dragging from charmap. My US keyboard has no Alt-GR key, so I'm not sure
how to type them directly here. I've been using
this myself for the last week or so, and I can't find anything wrong, but, you know how that goes.
I did check on gnome-terminal, and xterm, and also konsole. It seems to behave about the same on all of these, though, the keyboard is mapped slightly different with the number pad with some terminal emulators. This was compiled on a Fedora 12 system everything updated by me.
This version is now dependent on iconv and wide character versions of ncurses, which I think should be everywhere these days.
call.c +730 -250
@@ -35,7 +35,14 @@#include <sys/wait.h> #include <termios.h> #include <unistd.h> -#include <curses.h> +#define __USE_XOPEN +#include <wchar.h> +#include <wctype.h> +#define _XOPEN_SOURCE_EXTENDED 1 +#include <ncurses.h> +#include <locale.h> +#include <iconv.h> +#include <sys/ioctl.h> #include <netax25/ax25.h> #include <netrom/netrom.h>
@@ -78,10 +85,13 @@static char *mycall =NULL ;static int stdin_is_tty =1 ; +static iconv_t ibm850toutf8 =0 ,wcharttoibm850 =0 , wcharttoutf8 =0 , utf8towchart =0 ;int interrupted = FALSE; +static int sigwinchsignal = FALSE;int paclen =0 ;int fd; +int curson =1 ;#define GP_FILENAME_SIZE 255 typedef struct {
@@ -98,7 +108,7 @@WINDOW *ptr;int max_y;int max_x; -char string[MAX_BUFLEN ]; +wchar_t string[MAX_BUFLEN ];unsigned long bytes;int curs_pos; } t_win;
@@ -107,6 +117,229 @@#define SLAVEMODE 002/* Menu mode */ #define RAWMODE 004/* mode used by earlier versions */ +#define ORIGINALENCODING 0 +#define UTF8ENCODING 1 + +#define SCROLLBACKSIZE 5000 + +typedef struct { +char *str;int len; +}scrollbackstruct ; + + +static scrollbackstruct scrollback[SCROLLBACKSIZE ]; +static int topscroll=0 , lastscroll =0 , scrolledup=0 , eatchar =0 ; +static char inbuf[MAX_BUFLEN ];static int inbuflen =0 , inbufwid =0 ; +static char incharbuf[6 ];static int incharbuflen =0 ; +void statline (int mode,char *s); + +void addscrollline (char *s,int len) +{ + scrollback[lastscroll].str =malloc (len); +memcpy (scrollback[lastscroll].str, s, len); + scrollback[lastscroll].len = len; +if (++lastscroll >=SCROLLBACKSIZE )lastscroll =0 ; +if (lastscroll == topscroll){ +free (scrollback[topscroll].str); +if (++topscroll >=SCROLLBACKSIZE )topscroll =0 ; + } +} + +// Notes: Japanese, Chinese and Korean characters mostly take up two +// characters in width. These characters return 2 via +// wcwidth to let the code know that they require two +// spaces. Mono-space fonts/ncurses seems to work correctly with +// East Asian characters. +// +// There are also some characters that return a wcwidth of 0. I'm +// not sure about all of them, but some of the 0 width characters +// add a mark above or below a character. In order for these marks +// to appear correctly, the previous character and the overstrike +// must be drawn together. using wmove and drawing the accent doesn't +// work. +// +// There are some other characters that have functions, and these +// are not supported using a print to the screen. South Asian +// fonts are complicated. I don't believe south asian fonts work +// correctly from the Linux command line (as of late 2009). They +// print but don't combine. The result is distorted. +// +// Many characters, as of 12/09, are too wide for a single space +// in the font, although they return a wcwidth of 1. I suspect +// this is due to these characters not being part of the mono-spaced +// font and are instead pulled from an alternate font. These +// characters also glitch in xterm, vim and other ncurses +// software. I suspect this is actually a font bug, and any character +// that returns wcwidth=1 in a monospaced font should be +// monospaced. +// + + +int widthchar (char *s,size_t bytes,int xpos) +{ +wchar_t c;int width; +char *outbuf=(char *) &c; +size_t outsize =sizeof (wchar_t); +// Note: Actually need to check if bad UTF8 characters show as ? +if (iconv (utf8towchart, &s, &bytes, &outbuf, &outsize)<0 )return 0 ; +if (c ==9 ){ +return 8 - (xpos &7 ); + } + width =wcwidth (c); +if (width <0 )return 0 ; +return width; +} + + +int completecharlen (char *s) +{ +unsigned ut = (unsigned char )s[0 ];int clen; +if (ut <=0x80 )clen =1 ; +else if ((ut >=192 ) && (ut <192 +32 ))clen =2 ; +else if ((ut >=224 ) && (ut <224 +16 ))clen =3 ; +else if ((ut >=240 ) && (ut <240 +8 ))clen =4 ; +else if ((ut >=248 ) && (ut <248 +4 ))clen =5 ; +else if ((ut >=252 ) && (ut <252 +2 ))clen =6 ; +else clen =1 ;// bad +return clen; +} + + +// Must check for COLS while redrawing from history. Or otherwise the text +// wraps around and does strange things. +int waddnstrcolcheck (WINDOW *win,char *s,int len,int twidth) +{ +int n; +for (twidth =0 ,n=0 ;n<len;){ +int cwidth =completecharlen (&s[n]), width; +if (n + cwidth > len)return twidth;// Error condition + width =widthchar (&s[n], cwidth, twidth); +if (twidth+width >COLS )return twidth;// +waddnstr (win, &s[n], cwidth); + n += cwidth; + twidth += width; + } +return twidth; +} + +// Update a line on the screen from the backscroll buffer. +void updateline (int screeny,int yfrom,t_win *win_in,int mode,t_win *win_out) +{ +wmove (win_in->ptr, screeny,0 ); +if (yfrom == lastscroll){ +int twidth =0 ; +if (inbuflen >0 ) + twidth =waddnstrcolcheck (win_in->ptr, inbuf, inbuflen,0 ); +if (mode ==SLAVEMODE ){ +char obuf[MAX_BUFLEN ]; +char *inbuf = (char *)win_out->string, *outbuf = obuf; +size_t insize = win_out->bytes *sizeof (wchar_t), outsize =MAX_BUFLEN ; +iconv (wcharttoutf8, &inbuf, &insize, &outbuf, &outsize); +waddnstrcolcheck (win_in->ptr, obuf,MAX_BUFLEN - outsize, twidth); + win_out->curs_pos = win_out->bytes; + } + } +else { +waddnstrcolcheck (win_in->ptr, scrollback[yfrom].str, scrollback[yfrom].len,0 ); + } +} + +// Cursor in SLAVE mode while scrolling looks broken. +// Cursor in TALK mode is always good, because it's on the bottom window +void checkcursor (int mode) +{ +int newcursor; +if ((mode ==SLAVEMODE ) && scrolledup)newcursor =0 ; +else newcursor =1 ; +if (curson != newcursor){ +curs_set (newcursor); + curson = newcursor; + } +} + +/* For CJK, it's important to keep the cursor always on the input +* window. Otherwise the display is confused */ +static void restorecursor (int mode,t_win *win_out) +{ +checkcursor (mode); +if (mode !=RAWMODE ){ +int x,y; +getyx (win_out->ptr, y, x);// Must restore input cursor location. +wmove (win_out->ptr,y, x); +wrefresh (win_out->ptr); + } +} + +void redrawscreen (t_win *win_in,int mode,t_win *win_out) +{ +int y, storedlines; +if (lastscroll >= topscroll) storedlines = lastscroll - topscroll; +else storedlines = lastscroll +SCROLLBACKSIZE - topscroll; +// Note it's stored lines + 1 extra line for text input. +for (y=0 ;(y<=win_in->max_y) && (y <= storedlines);y++){ +int linefrom; +if (storedlines <= win_in->max_y){// This is a little confusing. + linefrom = topscroll + y;// The screen scrolls top down at start + } +else linefrom = lastscroll -scrolledup - (win_in->max_y) + y; +while (linefrom <0 )linefrom +=SCROLLBACKSIZE ; +while (linefrom >=SCROLLBACKSIZE )linefrom -=SCROLLBACKSIZE ; +updateline (y,linefrom , win_in, mode, win_out); + } +checkcursor (mode); +} + +void scrolltext (t_win *win_in,int lines,int mode,t_win *win_out) +{ +int topline, storedlines; +int y, err; +int wasscrolledup; +if (scrolledup + lines <0 ){ + lines = -scrolledup; + } +// storedlines = Lines stored in buffer. +if (lastscroll >= topscroll) storedlines = lastscroll - topscroll; +else storedlines = lastscroll +SCROLLBACKSIZE - topscroll; +// The max scrolling we can do is the # of lines stored - the +// screen size. + topline = storedlines - win_in->max_y; +if (topline <0 )topline =0 ; +if (scrolledup + lines > topline){ + lines = topline - scrolledup; + } +if (!lines)return ; + wasscrolledup = scrolledup; + scrolledup += lines; + err=wscrl (win_in->ptr, -lines); +scrollok (win_in->ptr, FALSE); +if (lines >0 ){ +for (y=0 ;y<lines;y++){ +int linefrom = lastscroll -scrolledup - (win_in->max_y) + y; +while (linefrom <0 )linefrom +=SCROLLBACKSIZE ; +while (linefrom >=SCROLLBACKSIZE )linefrom -=SCROLLBACKSIZE ; +updateline (y,linefrom , win_in, mode, win_out); + } + } +else { +for (y=-lines-1 ;y>=0 ;y--){ +int linefrom = lastscroll -scrolledup - y; +while (linefrom <0 )linefrom +=SCROLLBACKSIZE ; +while (linefrom >=SCROLLBACKSIZE )linefrom -=SCROLLBACKSIZE ; +updateline (win_in->max_y - y,linefrom , win_in, mode, win_out); + } + + } +scrollok (win_in->ptr, TRUE); +checkcursor (mode); +wrefresh (win_in->ptr); +if (wasscrolledup && !scrolledup){ +statline (mode,"" ); + } +else if (!wasscrolledup && scrolledup){ +statline (mode,"Viewing Scrollback" ); + } +} +void usage (void ) {fprintf (stderr,"usage: call [-b l|e] [-d] [-h] [-m s|e] [-p paclen] [-r] [-s mycall] [-t] [-v] [-w window] port callsign [[via] digipeaters...]\n" );
@@ -149,6 +382,73 @@ } + +/* Return the with of this character in character blocks. (Normal = 1, CJK=2) +* Also for control chracters, return the width of the replacement string. +* */ +static int wcwidthcontrol (wchar_t c) +{ +int width; +cchar_t cc = {0 }; +wchar_t *str; + cc.chars[0 ] = c; + str =wunctrl (&cc); +if (!str)return 0 ; + width =wcswidth (str,wcslen (str)); +return width; +} + +/* Return a string to print for a wchar_t. Expand control characters. +* Strings returned by wunctrl don't like to be freed. It seems. */ +static wchar_t *wunctrlwchar (wchar_t c) +{ +cchar_t cc = {0 }; +wchar_t *str; + cc.chars[0 ] = c; + str =wunctrl (&cc); +return str; +} + +// For some reason wins_nwstr fails on fedora 12 on some characters +// but waddnstr works. +// Draw the entire input buffer when adding text. +// The fonts that do overstrike fail when written one char at a time. +void drawinbuf (WINDOW *w,wchar_t *string,int bytes,int cur_pos) +{ +int n, x, cursorx, xpos, ypos, width; +getyx (w, ypos, xpos);// Assume cursor to be at position of current char to draw. + x = xpos;cursorx = xpos; +// cur_pos-1 = the chracter that was just added. +for (n=cur_pos-2 ;n>=0 ;n--){// Move x position to start of string or 0 + width =wcwidthcontrol (string[n]); +if (x >= width)x -= width; +else x =0 ; + } +wmove (w, ypos, x); +for (n=0 ;n<bytes;n++){ +char obuf[MAX_BUFLEN ]; +char *inbuf, *outbuf = obuf; +size_t insize, outsize =MAX_BUFLEN ; +wchar_t *str;int len, width; +if (n == cur_pos){ + cursorx = x; + } + str =wunctrlwchar (string[n]); +if (!str)continue ; + inbuf = (char *) str; + len =wcslen (str); + insize = len *sizeof (wchar_t); + width =wcswidth (str, len); +iconv (wcharttoutf8, &inbuf, &insize, &outbuf, &outsize); +waddnstr (w, obuf,MAX_BUFLEN -outsize); + x += width; + } +if (cur_pos < bytes){ +wmove (w,ypos, cursorx); + } +} + +/* Convert linear UNIX date to a MS-DOS time/date pair. */ static char *unix_to_sfbin_date_string (time_t gmt)
@@ -387,6 +687,13 @@return (fd); } + +static void cmd_sigwinch (int sig) +{ +signal (SIGWINCH , cmd_sigwinch); + sigwinchsignal = TRUE; +} +void cmd_intr (int sig) {signal (SIGQUIT , cmd_intr);
@@ -404,7 +711,7 @@if (oldlen >0 ) {move (0 ,STATW_STAT );attron (A_REVERSE ); -for (cnt =0 ; cnt < oldlen; cnt++) +for (cnt =STATW_STAT ; cnt <COLS ; cnt++)addch (' ' ); oldlen =0 ;attroff (A_REVERSE );
@@ -417,21 +724,18 @@fflush (stdout);return ; } -if (strlen (s) >80 -STATW_STAT ) - s[80 -STATW_STAT ] ='\0' ; +if (COLS <=STATW_STAT )return ; + l =strlen (s); +if (l >COLS -STATW_STAT ) + l =COLS -STATW_STAT ;move (0 ,STATW_STAT );attron (A_REVERSE ); -addstr (s); - -if (oldlen >strlen (s)) { - l = oldlen -strlen (s); -for (cnt =0 ; cnt < l; cnt++) -addch (' ' ); - } +addnstr (s, l); +for (cnt =STATW_STAT +l;cnt <COLS ;cnt++)addch (' ' );attroff (A_REVERSE ); - oldlen =strlen (s); + oldlen = l;refresh (); }
@@ -752,8 +1056,11 @@ {int cnt;char idString[11 ]; -sprintf (idString," %8s " , call[0 ]); +struct winsize winsz = {0 }; +if ((ioctl (0 ,TIOCGWINSZ , &winsz) >=0 ) && winsz.ws_row && winsz.ws_col) +resizeterm (winsz.ws_row, winsz.ws_col); +sprintf (idString," %8s " , call[0 ]);if ((win =initscr ()) ==NULL )return -1 ;
@@ -763,7 +1070,8 @@addch (ACS_VLINE );addstr ("--------" );addch (ACS_VLINE ); -for (cnt =STATW_STAT ; cnt <=80 ; cnt++) +move (0 ,STATW_STAT ); +for (cnt =STATW_STAT ; cnt <COLS ; cnt++)addch (' ' );attroff (A_REVERSE );
@@ -771,8 +1079,8 @@raw ();nodelay (win, TRUE);keypad (win, TRUE); + curson =1 ;refresh (); -return 0 ; }
@@ -793,7 +1101,8 @@ win_out->curs_pos =0 ; win_in->bytes =0 ; win_in->curs_pos =0 ; - +redrawscreen (win_in,SLAVEMODE , win_out); +wrefresh (win_in->ptr);return 0 ; }
@@ -824,15 +1133,16 @@scrollok (win_out->ptr, TRUE);wclear (win_out->ptr); -wrefresh (win_out->ptr);wclear (win_in->ptr); -wrefresh (win_in->ptr); win_out->bytes =0 ; win_out->curs_pos =0 ; win_in->bytes =0 ; win_out->curs_pos =0 ; - +redrawscreen (win_in,TALKMODE , win_out); +restorecursor (TALKMODE , win_out); +wrefresh (win_in->ptr); +wrefresh (win_out->ptr);return 0 ; }
@@ -882,165 +1192,201 @@ }break ; } - + scrolledup =0 ;return newmode; } -void writeincom (int mode,t_win * win_in,unsigned char buf[],int bytes) +static void reinit_mode (int mode,wint * wintab,t_win * win_in, +t_win * win_out,char *call[]) { -int cnt; +switch (mode) { +case RAWMODE : +break ; -if (mode &RAWMODE ) { -write (STDOUT_FILENO , buf, bytes); -return ; - } -for (cnt =0 ; cnt < bytes; cnt++) { -switch (buf[cnt]) { -case 201 : -case 218 : -waddch (win_in->ptr,ACS_ULCORNER ); -break ; -case 187 : -case 191 : -waddch (win_in->ptr,ACS_URCORNER ); -break ; -case 200 : -case 192 : -waddch (win_in->ptr,ACS_LLCORNER ); -break ; -case 188 : -case 217 : -waddch (win_in->ptr,ACS_LRCORNER ); -break ; -case 204 : -case 195 : -waddch (win_in->ptr,ACS_LTEE ); -break ; -case 185 : -case 180 : -waddch (win_in->ptr,ACS_RTEE ); -break ; -case 203 : -case 194 : -waddch (win_in->ptr,ACS_TTEE ); -break ; -case 202 : -case 193 : -waddch (win_in->ptr,ACS_BTEE ); -break ; -case 205 : -case 196 : -waddch (win_in->ptr,ACS_HLINE ); -break ; -case 186 : -case 179 : -waddch (win_in->ptr,ACS_VLINE ); -break ; -case 129 : -waddch (win_in->ptr,252 );/*u umlaut */ -break ; -case 132 : -waddch (win_in->ptr,228 );/*a umlaut */ -break ; -case 142 : -waddch (win_in->ptr,196 );/*A umlaut */ -break ; -case 148 : -waddch (win_in->ptr,246 );/*o umlaut */ -break ; -case 153 : -waddch (win_in->ptr,214 );/*O umlaut */ -break ; -case 154 : -waddch (win_in->ptr,220 );/*U umlaut */ +case TALKMODE :// Clear the screen and re-init. Which looks awful. +wclear (win_out->ptr); +wrefresh (win_out->ptr); +wclear (win_in->ptr); +// wrefresh(win_in->ptr); + wintab->next =0 ; +endwin (); +start_screen (call); +start_talk_mode (wintab, win_in, win_out); +restorecursor (mode, win_out);break ; -case 225 : -waddch (win_in->ptr,223 );/*sz */ + +case SLAVEMODE :// Also fix me. +wclear (win_out->ptr); +//wrefresh(win_out->ptr); + wintab->next =0 ; +endwin (); +start_screen (call); +start_slave_mode (wintab, win_in, win_out); +restorecursor (mode, win_out);break ; -default : - { -if (buf[cnt] >127 ) -waddch (win_in->ptr,'.' ); -else -waddch (win_in->ptr, buf[cnt]); + } +} + + +void waddnstrcrcheck (t_win *win_in,char *buf,int bytes,int draw,int mode,t_win *win_out) +{ +int n; +for (n=0 ;n<bytes;n++){ +int width; + incharbuf[incharbuflen++] = buf[n]; +if (completecharlen (incharbuf) > incharbuflen)continue ; +if (eatchar && (incharbuf[0 ] =='\n' )){ + eatchar =0 ; + incharbuflen =0 ; +continue ; + } + width =widthchar (incharbuf, incharbuflen, inbufwid); + eatchar =0 ; +if (draw) { +if (win_in)waddnstr (win_in->ptr, incharbuf, incharbuflen); +else write (STDOUT_FILENO , incharbuf, incharbuflen); + } +if (incharbuf[0 ] =='\n' )incharbuflen =0 ; +else if (width + inbufwid <=COLS ){ +if (inbuflen + incharbuflen <=MAX_BUFLEN ){ +memcpy (&inbuf[inbuflen], incharbuf, incharbuflen); + inbuflen += incharbuflen; } + incharbuflen =0 ; + inbufwid += width; +if (inbufwid >=COLS )eatchar =1 ; +continue ;// Skip to next line when width goes over. + } +addscrollline (inbuf, inbuflen); +if (incharbuflen){ +memcpy (&inbuf[0 ], incharbuf, incharbuflen); + inbuflen = incharbuflen; + incharbuflen =0 ; + inbufwid = width; + } +else { + inbuflen =0 ; + inbufwid =0 ; + } +if (scrolledup && win_in && win_out){ + scrolledup++;// scrolledup is relative to bottom line +scrolltext (win_in,0 , mode, win_out); } } +if (draw && win_in)wrefresh (win_in->ptr); + +} -/* waddnstr(win_in->ptr, buf, bytes); */ -wrefresh (win_in->ptr); +void writeincom (int mode,int encoding,t_win * win_in,unsigned char buf[],int bytes,t_win *win_out) +{ +if (mode &RAWMODE )waddnstrcrcheck (0 , (char *)buf, bytes,1 , mode,0 ); +else if (encoding ==UTF8ENCODING ) +waddnstrcrcheck (win_in, (char *)buf, bytes,scrolledup ==0 , mode, win_out); +else { +char *inbuf = (char *) buf, out[MAX_BUFLEN ], *outbuf=out; +size_t insize = bytes, outsize =MAX_BUFLEN ; +iconv (ibm850toutf8, &inbuf, &insize, &outbuf, &outsize); +waddnstrcrcheck (win_in, out,MAX_BUFLEN -outsize,scrolledup ==0 , mode, win_out); + }return ; } - +static void writeincomstr (int mode,int encoding,t_win * win_in,char buf[],t_win *win_out) +{ +int len; + len =strlen (buf); +writeincom (mode, encoding, win_in, (unsigned char *)buf, len, win_out); +} + +int outstring (char *buf,wchar_t *string,int bytes,int encoding) +{ +char *inbuf = (char *) string, *outbuf = buf; +size_t insize = bytes *sizeof (wchar_t), outsize =MAX_BUFLEN -1 ; +if (encoding ==UTF8ENCODING ){ +iconv (wcharttoutf8, &inbuf, &insize, &outbuf, &outsize); + } +else { +iconv (wcharttoibm850, &inbuf, &insize, &outbuf, &outsize); + + } + buf[(MAX_BUFLEN -1 )-outsize] ='\0' ; +return (MAX_BUFLEN -1 )-outsize; +} +int getstring (wint * wintab,char text[],char buf[]) { -int c; +wchar_t c;int ypos =0 , xpos =0 ;int bytes =0 ; - +wchar_t wbuf[MAX_BUFLEN ];WINDOW *win =winopen (wintab,3 ,COLS ,10 ,0 , TRUE); +int done =0 ;wmove (win,1 ,2 );waddstr (win, text);wrefresh (win);do { - c =getch (); -if (c !=ERR ) { -switch (c) { -case KEY_BACKSPACE : -case 127 : - { -getyx (win, ypos, xpos); -if (xpos >0 && bytes >0 ) { -wmove (win, ypos, --xpos); -waddch (win,' ' ); -wmove (win, ypos, xpos); - bytes--; - } - } -break ; -case (int )'\n' : -case (int )'\r' : -case KEY_ENTER : - { -waddch (win,'\n' ); - buf[bytes++] = (char )'\n' ; -wrefresh (win); - buf[bytes] =0 ; - } -break ; -default : - { -waddch (win, (char ) c); - buf[bytes++] = (char ) c; +int r; +wint_t ci; + r =get_wch (&ci); +if (r !=ERR ) { + c = (wchar_t ) ci; +if (((r ==KEY_CODE_YES ) && (c ==KEY_BACKSPACE ))|| + ((r ==OK ) && ((c==127 )|| (c==8 )))){ +getyx (win, ypos, xpos); +if (bytes >0 ) { +int width, j; + width =wcwidthcontrol (wbuf[bytes-1 ]); +for (j=0 ;j<width;j++)mvwdelch (win, ypos, xpos-width); + xpos -= width; +wmove (win, ypos, xpos); + bytes--; } } +else if (( (r==KEY_CODE_YES ) && (c ==KEY_ENTER ))|| + ( (r ==OK ) && ((c=='\n' ) || (c=='\r' )))){ +int out_cnt; + wbuf[bytes++] = (wchar_t )'\n' ; + out_cnt =outstring (buf, wbuf, bytes,UTF8ENCODING ); + done =1 ; + } +else if (r ==KEY_CODE_YES );// Put in code for other KEYCODES here +else if (bytes+2 <MAX_BUFLEN ){ +//int width; +//width = wins_nwchrmy(win, c); +//getyx(win, ypos, xpos); +//wmove(win, ypos, xpos+width); + wbuf[bytes++] = c; +drawinbuf (win, wbuf, bytes, bytes); + }wrefresh (win); } } -while (c !='\n' && c !='\r' && c !=KEY_ENTER ); +while (!done);delwin (win);winclose (wintab);return 0 ; }int readoutg (t_win * win_out,wint * wintab,menuitem * top,char buf[], -int keyesc) +int keyesc,int mode,int encoding,t_win *win_in) { -int out_cnt; -int c; +int out_cnt, r; +wint_t ci;wchar_t c;int ypos =0 , xpos =0 ;int value; - c =getch (); -if (c ==ERR ) + r =get_wch (&ci); +if (r ==ERR )return 0 ; - + c = (wchar_t ) ci;if (c == keyesc) { -if ((value =top_menu (wintab, top,1 )) ==0 ) +if ((value =top_menu (wintab, top,1 )) ==0 ){ +restorecursor (mode, win_out);return 0 ; + } +restorecursor (mode, win_out); buf[0 ] ='~' ;switch (value) {case 0x01 :
@@ -1059,6 +1405,7 @@getstring (wintab,"Please enter filename: " , &buf[2 ]); +restorecursor (mode, win_out);return strlen (buf); }case 0x12 :
@@ -1083,6 +1430,7 @@getstring (wintab,"Please enter filename: " , buf +2 ); +restorecursor (mode, win_out);return strlen (buf); }case 0x21 :
@@ -1106,97 +1454,164 @@wrefresh (win_out->ptr);return 2 ; } -switch (c) { -case KEY_BACKSPACE : -case 127 : - { +if (((r ==KEY_CODE_YES ) && (c ==KEY_BACKSPACE ))|| + ((r ==OK ) && ((c==127 )|| (c==8 )))){ +if ((mode ==SLAVEMODE ) && scrolledup)return 0 ; +while (win_out->curs_pos >0 ){ +int width;int j;getyx (win_out->ptr, ypos, xpos); -if (win_out->bytes >0 ) { -if (win_out->curs_pos < win_out->bytes) { -mvwaddnstr (win_out->ptr, ypos, - --xpos, - &win_out-> - string[win_out-> - curs_pos], - win_out->bytes - - win_out->curs_pos); -waddch (win_out->ptr,' ' ); -memmove (&win_out-> - string[win_out->curs_pos - -1 ], - &win_out->string[win_out-> - curs_pos], - win_out->bytes - - win_out->curs_pos); - }else -mvwaddch (win_out->ptr, ypos, - --xpos,' ' ); - -wmove (win_out->ptr, ypos, xpos); - win_out->bytes--; - win_out->curs_pos--; - } - } -break ; -case KEY_LEFT : -if (win_out->curs_pos >0 ) { + width =wcwidthcontrol (win_out->string[win_out->curs_pos-1 ]); +for (j=0 ;j<width;j++)mvwdelch (win_out->ptr, ypos, xpos-width); + xpos -= width; +wmove (win_out->ptr, ypos, xpos); +if (win_out->curs_pos < win_out->bytes) { +memmove (&win_out-> + string[win_out->curs_pos -1 ], + &win_out->string[win_out-> curs_pos], + (win_out->bytes - + win_out->curs_pos) *sizeof (wchar_t)); + } + win_out->bytes--; win_out->curs_pos--; -getyx (win_out->ptr, ypos, xpos); -wmove (win_out->ptr, ypos, xpos -1 ); +if (width)break ; } -break ; -case KEY_RIGHT : -if (win_out->curs_pos < win_out->bytes) { + } +else if (( (r==KEY_CODE_YES ) && (c ==KEY_ENTER ))|| + ( (r ==OK ) && ((c=='\n' ) || (c=='\r' )))){ +if ((mode ==SLAVEMODE ) && scrolledup)return 0 ; +while (win_out->curs_pos < win_out->bytes) {// Move to end of the line +int width; + width =wcwidthcontrol (win_out->string[win_out->curs_pos]); win_out->curs_pos++;getyx (win_out->ptr, ypos, xpos); -wmove (win_out->ptr, ypos, xpos +1 ); - } -break ; -case KEY_ENTER : -case (int )'\n' : -case (int )'\r' : - { -if (win_out->curs_pos < win_out->bytes) { -getyx (win_out->ptr, ypos, xpos); -wmove (win_out->ptr, ypos, - xpos + win_out->bytes - - win_out->curs_pos); +wmove (win_out->ptr, ypos, xpos + width); } -waddch (win_out->ptr,'\n' ); - win_out->string[win_out->bytes++] = (char )'\n' ; -wrefresh (win_out->ptr); -strncpy (buf, win_out->string, win_out->bytes); -wrefresh (win_out->ptr); - out_cnt = win_out->bytes; - win_out->bytes =0 ; - win_out->curs_pos =0 ; -return out_cnt; +waddch (win_out->ptr,'\n' ); + win_out->string[win_out->bytes++] = (wchar_t )'\n' ; +wrefresh (win_out->ptr); + out_cnt =outstring (buf, win_out->string, win_out->bytes, encoding); +if (mode ==SLAVEMODE ){ +char obuf[MAX_BUFLEN ]; +char *inbuf = (char *)win_out->string, *outbuf = obuf; +size_t insize = win_out->bytes *sizeof (wchar_t), outsize =MAX_BUFLEN ; +iconv (wcharttoutf8, &inbuf, &insize, &outbuf, &outsize); +waddnstrcrcheck (win_in, obuf,MAX_BUFLEN -outsize,0 , mode, win_out); + } + win_out->bytes =0 ; + win_out->curs_pos =0 ; +return out_cnt; + } +else if (r ==KEY_CODE_YES ){ +switch (c){ +case KEY_LEFT :// Character of 0 width +while (win_out->curs_pos >0 ) { +int width; + win_out->curs_pos--; + width =wcwidthcontrol (win_out->string[win_out->curs_pos]); +getyx (win_out->ptr, ypos, xpos); +wmove (win_out->ptr, ypos, xpos - width); +if (width)break ;// Skip to non-width + } +break ; +case KEY_RIGHT : + { +int skipped =0 ;// Skip over 0 length characters +while (win_out->curs_pos < win_out->bytes) { +int width; + width =wcwidthcontrol (win_out->string[win_out->curs_pos]); +if (width){ +if (skipped)break ; + skipped =1 ; + } + win_out->curs_pos++; +getyx (win_out->ptr, ypos, xpos); +wmove (win_out->ptr, ypos, xpos + width); + } +break ; + } +case KEY_UP : +scrolltext (win_in,1 , mode, win_out); +break ; +case KEY_DOWN : +scrolltext (win_in,-1 , mode, win_out); +break ; +case KEY_NPAGE : +scrolltext (win_in, -win_in->max_y, mode, win_out); +break ; +case KEY_PPAGE : +scrolltext (win_in, win_in->max_y, mode, win_out); +break ; +case KEY_HOME : +while (win_out->curs_pos >0 ) { +int width; + win_out->curs_pos--; + width =wcwidthcontrol (win_out->string[win_out->curs_pos]); +getyx (win_out->ptr, ypos, xpos); +wmove (win_out->ptr, ypos, xpos - width); + } +break ; +case KEY_END : +while (win_out->curs_pos < win_out->bytes) {// Move to end of the line +int width; + width =wcwidthcontrol (win_out->string[win_out->curs_pos]); + win_out->curs_pos++; +getyx (win_out->ptr, ypos, xpos); +wmove (win_out->ptr, ypos, xpos + width); + } +break ; +case KEY_DC :{ +int skipped =0 ; +if ((mode ==SLAVEMODE ) && scrolledup)return 0 ; +while (win_out->curs_pos < win_out->bytes){ +int width;int j; +getyx (win_out->ptr, ypos, xpos); + width =wcwidthcontrol (win_out->string[win_out->curs_pos]); +if (width){ +if (skipped)break ; + skipped =1 ; + } +for (j=0 ;j<width;j++)mvwdelch (win_out->ptr, ypos, xpos); +if (win_out->curs_pos +1 < win_out->bytes) { +memmove (&win_out-> string[win_out->curs_pos], + &win_out->string[win_out-> curs_pos+1 ], + (win_out->bytes - (win_out->curs_pos+1 )) *sizeof (wchar_t)); + } + win_out->bytes--; + } +break ; + } +case KEY_RESIZE : +break ; +case KEY_BACKSPACE : +break ; +case KEY_ENTER : +break ; +default : +break ; } + } +else switch (c) { +case 8 : +case 127 : +case '\r' : +case '\n' :break ;default : - { -waddch (win_out->ptr, (char ) c); +if ((mode ==SLAVEMODE ) && scrolledup)return 0 ;// Don't try to edit while scrolled up in SLAVEmode. +// It's just not possible because the cursor is off screen +if (win_out->bytes <MAX_BUFLEN ) {if (win_out->curs_pos < win_out->bytes) { -getyx (win_out->ptr, ypos, xpos); -waddnstr (win_out->ptr, - &win_out->string[win_out-> - curs_pos], - win_out->bytes - - win_out->curs_pos);memmove (&win_out-> string[win_out->curs_pos +1 ], - &win_out->string[win_out-> - curs_pos], - win_out->bytes - - win_out->curs_pos); - win_out->string[win_out->curs_pos] = - (char ) c; -wmove (win_out->ptr, ypos, xpos); - }else - win_out->string[win_out->bytes] = (char ) c; - + &win_out->string[win_out-> curs_pos], + (win_out->bytes - + win_out->curs_pos) *sizeof (wchar_t)); + } + win_out->string[win_out->curs_pos] = c; win_out->bytes++; win_out->curs_pos++; +drawinbuf (win_out->ptr, win_out->string, win_out->bytes, win_out->curs_pos); +break ; } }wrefresh (win_out->ptr);
@@ -1465,8 +1880,8 @@return ; } - -int cmd_call (char *call[],int mode) + +int cmd_call (char *call[],int mode,int encoding) {menuitem con[] = { {"~Reconnect" ,'R' ,M_ITEM , (void *)0x01 },
@@ -1530,8 +1945,8 @@char *c, *t;int extrach =0 ;t_gp gp; -t_win win_in; -t_win win_out; +t_win win_in = {0 }; +t_win win_out = {0 };WINDOW *swin =0 ;int cnt;int crc =0 ;
@@ -1548,12 +1963,14 @@if ((fd =connect_to (call)) ==-1 )return FALSE; - + interrupted = FALSE; + sigwinchsignal = FALSE;signal (SIGQUIT , cmd_intr);signal (SIGINT ,SIG_IGN );signal (SIGTSTP ,SIG_IGN ); - +signal (SIGWINCH , cmd_sigwinch); +fcntl (fd,F_SETFL ,O_NONBLOCK );fcntl (STDIN_FILENO ,F_SETFL ,O_NONBLOCK );
@@ -1572,26 +1989,37 @@fflush (stdout); } } - +while (TRUE) { -struct timeval tv; +struct timespec tv; +sigset_t sigmask; tv.tv_sec =0 ; - tv.tv_usec =10 ; + tv.tv_nsec =10000 ;FD_ZERO (&sock_read);FD_SET (STDIN_FILENO , &sock_read);FD_SET (fd, &sock_read);FD_ZERO (&sock_write); - +sigemptyset (&sigmask);if (uploadfile !=-1 )FD_SET (fd, &sock_write); -if (select (fd +1 , &sock_read, &sock_write,NULL , (uploadfile ==-1 && downloadfile ==-1 ) ?NULL : &tv) ==-1 ) { +if (pselect (fd +1 , &sock_read, &sock_write,NULL , (uploadfile ==-1 && downloadfile ==-1 ) ?NULL : &tv, &sigmask) ==-1 ) {if (!interrupted && errno ==EAGAIN )continue ; -if (!interrupted) -perror ("select" ); -break ; +if ((errno ==EINTR ) && sigwinchsignal){ +// Just process screen resize here. +reinit_mode (mode, &wintab, &win_in, + &win_out, call); + sigwinchsignal =0 ; +continue ; + } +else { +if (!interrupted){ +perror ("select" ); + } +break ; + } }if (FD_ISSET (fd, &sock_read)) {/* bytes = read(fd, buf, 511); */
@@ -1629,8 +2057,9 @@convert_cr_lf (buf, bytes);if (!sevenplus) { -writeincom (mode, &win_in, - (unsigned char * ) buf, bytes); +writeincom (mode, encoding, &win_in, + (unsigned char * ) buf, bytes, &win_out); +restorecursor (mode, &win_out); }else {for (cnt =0 ; cnt < bytes; cnt++)
@@ -1744,7 +2173,7 @@ }else { bytes =readoutg (&win_out, &wintab, top, buf, -0x1d ); +0x1d , mode, encoding, &win_in);if (bytes ==-1 ) {wclear (win_in.ptr);wrefresh (win_in.ptr);
@@ -1809,24 +2238,26 @@case '?' :case 'h' :case 'H' : -printf ("\nTilde escapes:\n" ); -printf (". close\n" ); -printf ("~ send ~\n" ); -printf ("r reconnect\n" ); -printf ("! shell\n" ); -printf ("Z suspend program. Resume with \"fg\"\n" ); -printf ("s Stop upload\n" ); -printf ("o Open log\n" ); -printf ("c Close log\n" ); -printf ("0 Switch GUI to \"RAW\" (line) mode - already here ;)\n" ); -printf ("1 Switch GUI to \"Slave\" mode\n" ); -printf ("2 Switch GUI to \"Talk\" (split) mode\n" ); -printf ("u Upload\n" ); -printf ("a Upload (autobin protocol)\n" ); -printf ("b Upload binary data (crlf conversion)\n" ); -printf ("yd YAPP Download\n" ); -printf ("yu YAPP Upload\n" ); -fflush (stdout); +writeincomstr (mode, encoding, &win_in,"\nTilde escapes:\n" , &win_out); +writeincomstr (mode, encoding, &win_in,". close\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"~ send ~\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"r reconnect\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"! shell\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"Z suspend program. Resume with \"fg\"\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"s Stop upload\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"o Open log\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"c Close log\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"0 Switch GUI to \"RAW\" (line) mode - already here ;)\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"1 Switch GUI to \"Slave\" mode\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"2 Switch GUI to \"Talk\" (split) mode\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"u Upload\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"a Upload (autobin protocol)\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"b Upload binary data (crlf conversion)\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"yd YAPP Download\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"yu YAPP Upload\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"i IBM850 encoding\n" , &win_out); +writeincomstr (mode, encoding, &win_in,"8 UTF-8 encoding\n" , &win_out); +restorecursor (mode, &win_out);continue ;case 'S' :case 's' :
@@ -1839,6 +2270,7 @@statline (mode,"No upload in progress" ); } +restorecursor (mode, &win_out);continue ;case 'A' :case 'a' :
@@ -1849,6 +2281,7 @@if (uploadfile !=-1 ) {statline (mode,"Already uploading" ); +restorecursor (mode, &win_out);continue ; } if ((t =
@@ -1860,12 +2293,14 @@if (*t =='\0' ) {statline (mode,"Upload requires a filename" ); +restorecursor (mode, &win_out);continue ; } uploadfile =open (t,O_RDONLY );if (uploadfile ==-1 ) {statline (mode,"Unable to open upload file" ); +restorecursor (mode, &win_out);continue ; } if (lseek(uploadfile, 0L, SEEK_END)
@@ -1963,6 +2398,7 @@ upldp =-1 ; upllen =0 ; } +restorecursor (mode, &win_out);break ;case 'b' :case 'B' :
@@ -2001,6 +2437,7 @@statline (mode, s); }else statbits (mode,'L' ,1 ); +restorecursor (mode, &win_out);continue ;case 'C' :case 'c' :
@@ -2012,10 +2449,12 @@statline (mode,"Log file not open" ); } +restorecursor (mode, &win_out);continue ;case 'Y' :case 'y' :cmd_yapp (buf +2 , bytes -2 ); +restorecursor (mode, &win_out);continue ;case '~' : bytes--;
@@ -2045,9 +2484,21 @@ &wintab, &win_in, &win_out, call);continue ; +case '8' : + encoding =UTF8ENCODING ; +statline (mode,"UTF-8 encoding" ); +restorecursor (mode, &win_out); +continue ; +case 'i' : +case 'I' : + encoding =ORIGINALENCODING ; +statline (mode,"IBM850 encoding" ); +restorecursor (mode, &win_out); +continue ;default :statline (mode,"Unknown '~' escape. Type ~h for a list" ); +restorecursor (mode, &win_out);continue ; } }
@@ -2068,8 +2519,10 @@if (uploadfile !=-1 ) {statline (mode,"Ignored. Type ~s to stop upload" ); +restorecursor (mode, &win_out);continue ; } +convert_lf_cr (buf, bytes);while (offset != bytes) {
@@ -2098,6 +2551,7 @@winclose (&wintab);statline (mode,"Upload complete: 0 bytes" ); +restorecursor (mode, &win_out);continue ; }if (upldp ==-1 ) {
@@ -2112,6 +2566,7 @@sprintf (s,"Upload complete: %ld bytes" , uplpos); +restorecursor (mode, &win_out);statline (mode, s);continue ; }
@@ -2124,6 +2579,7 @@"Error reading upload file: upload aborted at %ld bytes" , uplpos);statline (mode, s); +restorecursor (mode, &win_out);continue ; }if (!binup)
@@ -2142,6 +2598,7 @@if (errno !=EWOULDBLOCK && errno !=EAGAIN ) {sprintf (s,"Write error during upload. Connection lost" );statline (mode, s); +restorecursor (mode, &win_out);perror ("write" );break ; }
@@ -2192,18 +2649,27 @@ } } +void iconvclose (void ) +{ +iconv_close (ibm850toutf8); +iconv_close (wcharttoibm850); +iconv_close (wcharttoutf8); +iconv_close (utf8towchart); +}int main (int argc,char **argv) {int p;int mode =TALKMODE ; +int encoding =UTF8ENCODING ;// Maybe controversial? +setlocale (LC_ALL ,"" );if (!isatty (STDIN_FILENO )) stdin_is_tty =0 ;setlinebuf (stdin); -while ((p =getopt (argc, argv,"b:dhm:p:rs:Stvw:" )) !=-1 ) { +while ((p =getopt (argc, argv,"b:dhm:p:rs:Stvw:i8" )) !=-1 ) {switch (p) {case 'b' :if (*optarg !='e' && *optarg !='l' ) {
@@ -2240,6 +2706,7 @@ }break ;case 'r' : +COLS =80 ;// This is used to format the scrollback buffer, which is stored in raw mode =RAWMODE ;break ;case 's' :
@@ -2274,6 +2741,12 @@ } }break ; +case 'i' : + encoding =ORIGINALENCODING ; +break ; +case '8' : + encoding =UTF8ENCODING ; +break ;case '?' :case ':' :usage ();
@@ -2283,6 +2756,13 @@if (optind == argc || optind == argc -1 ) {usage (); } + + ibm850toutf8 =iconv_open ("UTF8" ,"IBM850" ); + wcharttoibm850 =iconv_open ("IBM850" ,"WCHAR_T" ); + wcharttoutf8 =iconv_open ("UTF8" ,"WCHAR_T" ); + utf8towchart =iconv_open ("WCHAR_T" ,"UTF8" ); +atexit (iconvclose); + port = argv[optind];if (ax25_config_load_ports () ==0 ) {
@@ -2331,7 +2811,7 @@printf ("GW4PTS AX.25 Connect v1.11\n" );fflush (stdout); } -while (cmd_call (argv + optind +1 , mode)) { +while (cmd_call (argv + optind +1 , mode, encoding)) {if (!be_silent) {printf ("Wait 60 sec before reconnect\n" );fflush (stdout);