#!/bin/sh

# This user-defined script is called by IPwatchD daemon when IP conflict occurs.
# Feel free to modify it to suit your needs.

# Name of network device in conflict
DEVICE=$1

# IP address in conflict
IP=$2

# MAC address of conflicting system
MAC=$3

BODY='{"conflict": true, "mac": "'$MAC'"}'

DATA="POST /api/v1/network/report-status/ HTTP/1.1\r\n\
Host: 127.0.0.1:8080\r\n\
Content-Type: application/json\r\n\
Content-Length: ${#BODY}\r\n\
Connection: Close\r\n\r\n\
$BODY"

echo $DATA  | nc6 127.0.0.1 8080

# send GARP after defend-interval (10s)
/opt/rocware/c9/arping-after-ipconflict.sh $IP &

exit 0

