Skip to content

Commit

Permalink
agwpe: Read AGWPE_REVERSE_TO_FROM=true
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhpedersen committed May 7, 2023
1 parent f0b2711 commit 707c6f9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions transport/ax25/agwpe/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"fmt"
"io"
"net"
"os"
"strconv"
"strings"
"time"
)
Expand Down Expand Up @@ -49,8 +51,7 @@ func newConn(p *Port, dstCall string, via ...string) *Conn {
}
}

// TODO: How can we tell?
func notDirewolf() bool { return false }
func reverseToFrom() bool { t, _ := strconv.ParseBool(os.Getenv("AGWPE_REVERSE_TO_FROM")); return t }

// This requires Direwolf >= 1.4, but reliability improved as late as 1.6. It's required in order to flush tx buffers before link teardown.
func (c *Conn) numOutstandingFrames() (int, error) {
Expand All @@ -59,12 +60,14 @@ func (c *Conn) numOutstandingFrames() (int, error) {
}
resp := c.demux.NextFrame(kindOutstandingFramesForConn)

from, to := c.srcCall, c.dstCall

// According to the docs, the CallFrom and CallTo "should reflect the order used to start the connection".
// However, neither Direwolf nor QtSoundModem seems to implement this...
from, to := c.srcCall, c.dstCall
if c.inbound && notDirewolf() {
if c.inbound && reverseToFrom() {
from, to = to, from
}

f := outstandingFramesForConnFrame(c.p.port, from, to)
if err := c.p.write(f); err != nil {
return 0, err
Expand Down

0 comments on commit 707c6f9

Please sign in to comment.