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

This commit is contained in:
Martin/Geno 2018-03-11 20:21:35 +01:00
parent c20e216ed6
commit 4e7e2bad46
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
# (optional - without definition used a address of ifname)
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
# (optional - without definition used batman default ff02::2:1001)
multicast_address = "ff05::2:1001"

View File

@ -21,6 +21,7 @@ collect_interval = "1m"
[[respondd.interfaces]]
ifname = "br-ffhb"
#ip_address = "fe80::..."
#send_no_request = false
#multicast_address = "ff02::2:1001"
#port = 10001
```
@ -100,6 +101,7 @@ It is possible to have multiple interfaces, just add this group again with new p
[[respondd.interfaces]]
ifname = "br-ffhb"
#ip_address = "fe80::..."
#send_no_request = false
#multicast_address = "ff02::2:1001"
#port = 10001
```
@ -124,6 +126,16 @@ ip_address = "fe80::..."
```
{% 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
{% method %}
Multicast address to destination of respondd.

View File

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

View File

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