[-autotoss*]
[-nock]
[-ucspi]
+ [-mcd-wait INT]
NODE[:ADDR] [FORCEADDR]
@end example
@command{nncp-call} command under some UCSPI-TCP compatible utility,
that provides read/write channels through 6/7 file descriptors.
+@option{-mcd-wait} options tells to wait up to specified number of
+seconds for the @ref{MCD} packet from the specified @code{NODE}. When
+the packet is received, initiate a call.
+
@option{-autotoss} option runs tosser on node's spool every second
during the call. All @option{-autotoss-*} options is the same as in
@ref{nncp-toss} command.
"flag"
"fmt"
"log"
+ "net"
"os"
+ "regexp"
"strings"
"time"
listOnly = flag.Bool("list", false, "Only list remote packets")
noCK = flag.Bool("nock", false, "Do no checksum checking")
onlyPktsRaw = flag.String("pkts", "", "Recieve only that packets, comma separated")
+ mcdWait = flag.Uint("mcd-wait", 60, "Wait for MCD for specified number of seconds")
rxRate = flag.Int("rxrate", 0, "Maximal receive rate, pkts/sec")
txRate = flag.Int("txrate", 0, "Maximal transmit rate, pkts/sec")
spoolPath = flag.String("spool", "", "Override path to spool")
}
}
+ if *mcdWait > 0 {
+ ifis, err := net.Interfaces()
+ if err != nil {
+ log.Fatalln("Can not get network interfaces list:", err)
+ }
+ for _, ifiReString := range ctx.MCDRxIfis {
+ ifiRe, err := regexp.CompilePOSIX(ifiReString)
+ if err != nil {
+ log.Fatalf("Can not compile POSIX regexp \"%s\": %s", ifiReString, err)
+ }
+ for _, ifi := range ifis {
+ if ifiRe.MatchString(ifi.Name) {
+ if err = ctx.MCDRx(ifi.Name); err != nil {
+ log.Printf("Can not run MCD reception on %s: %s", ifi.Name, err)
+ }
+ }
+ }
+ }
+ addrs = nil
+ for i := int(*mcdWait); i > 0; i-- {
+ nncp.MCDAddrsM.RLock()
+ for _, mcdAddr := range nncp.MCDAddrs[*node.Id] {
+ addrs = append(addrs, mcdAddr.Addr.String())
+ }
+ if len(addrs) > 0 {
+ break
+ }
+ nncp.MCDAddrsM.RUnlock()
+ time.Sleep(time.Second)
+ }
+ if len(addrs) == 0 {
+ log.Fatalf("No MCD packets from the node during %d seconds", *mcdWait)
+ }
+ }
+
var onlyPkts map[[32]byte]bool
if len(*onlyPktsRaw) > 0 {
splitted = strings.Split(*onlyPktsRaw, ",")