[TASK] do not send multicast request (#121)

This commit is contained in:
Martin/Geno 2018-03-11 20:21:35 +01:00
parent c660e175f0
commit 1a4b078bbf
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
4 changed files with 21 additions and 2 deletions

View File

@ -25,6 +25,9 @@ ifname = "br-ffhb"
# ip address which is used for sending # ip address which is used for sending
# (optional - without definition used a address of ifname) # (optional - without definition used a address of ifname)
ip_address = "fd2f:5119:f2d::5" ip_address = "fd2f:5119:f2d::5"
# disable sending multicast respondd request
# (for receiving only respondd packages e.g. database respondd)
#send_no_request = false
# multicast address to destination of respondd # multicast address to destination of respondd
# (optional - without definition used batman default ff02::2:1001) # (optional - without definition used batman default ff02::2:1001)
multicast_address = "ff05::2:1001" multicast_address = "ff05::2:1001"

View File

@ -21,6 +21,7 @@ collect_interval = "1m"
[[respondd.interfaces]] [[respondd.interfaces]]
ifname = "br-ffhb" ifname = "br-ffhb"
#ip_address = "fe80::..." #ip_address = "fe80::..."
#send_no_request = false
#multicast_address = "ff02::2:1001" #multicast_address = "ff02::2:1001"
#port = 10001 #port = 10001
``` ```
@ -100,6 +101,7 @@ It is possible to have multiple interfaces, just add this group again with new p
[[respondd.interfaces]] [[respondd.interfaces]]
ifname = "br-ffhb" ifname = "br-ffhb"
#ip_address = "fe80::..." #ip_address = "fe80::..."
#send_no_request = false
#multicast_address = "ff02::2:1001" #multicast_address = "ff02::2:1001"
#port = 10001 #port = 10001
``` ```
@ -124,6 +126,16 @@ ip_address = "fe80::..."
``` ```
{% endmethod %} {% endmethod %}
### send_no_request
{% method %}
Disable sending multicast respondd request.
For receiving only respondd packages e.g. database respondd.
{% sample lang="toml" %}
```toml
send_no_request = true
```
{% endmethod %}
### multicast_address ### multicast_address
{% method %} {% method %}
Multicast address to destination of respondd. Multicast address to destination of respondd.

View File

@ -18,7 +18,6 @@ import (
// Collector for a specificle respond messages // Collector for a specificle respond messages
type Collector struct { type Collector struct {
connections []multicastConn // UDP sockets connections []multicastConn // UDP sockets
port int
queue chan *Response // received responses queue chan *Response // received responses
db database.Connection db database.Connection
@ -30,6 +29,7 @@ type Collector struct {
type multicastConn struct { type multicastConn struct {
Conn *net.UDPConn Conn *net.UDPConn
SendRequest bool
MulticastAddress net.IP MulticastAddress net.IP
} }
@ -89,6 +89,7 @@ func (coll *Collector) listenUDP(iface InterfaceConfig) {
coll.connections = append(coll.connections, multicastConn{ coll.connections = append(coll.connections, multicastConn{
Conn: conn, Conn: conn,
SendRequest: !iface.SendNoRequest,
MulticastAddress: net.ParseIP(multicastAddress), MulticastAddress: net.ParseIP(multicastAddress),
}) })
@ -163,8 +164,10 @@ func (coll *Collector) sendOnce() {
func (coll *Collector) sendMulticast() { func (coll *Collector) sendMulticast() {
log.Println("sending multicasts") log.Println("sending multicasts")
for _, conn := range coll.connections { for _, conn := range coll.connections {
if conn.SendRequest {
coll.sendPacket(conn.Conn, conn.MulticastAddress) coll.sendPacket(conn.Conn, conn.MulticastAddress)
} }
}
} }
// Send unicast packets to nodes that did not answer the multicast // Send unicast packets to nodes that did not answer the multicast

View File

@ -25,6 +25,7 @@ type SiteConfig struct {
type InterfaceConfig struct { type InterfaceConfig struct {
InterfaceName string `toml:"ifname"` InterfaceName string `toml:"ifname"`
IPAddress string `toml:"ip_address"` IPAddress string `toml:"ip_address"`
SendNoRequest bool `toml:"send_no_request"`
MulticastAddress string `toml:"multicast_address"` MulticastAddress string `toml:"multicast_address"`
Port int `toml:"port"` Port int `toml:"port"`
} }