<commit_before>-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

-- ARP address resolution (RFC 826)

-- Given a remote IPv4 address, try to find out its MAC address.
-- If resolution succeeds:
-- All packets coming through the 'south' interface (ie, via the network card)
-- are silently forwarded (unless dropped by the network card).
-- All packets coming through the 'north' interface (the lwaftr) will have
-- their Ethernet headers rewritten.

module(..., package.seeall)

local bit      = require("bit")
local ffi      = require("ffi")
local packet   = require("core.packet")
local link     = require("core.link")
local lib      = require("core.lib")
local datagram = require("lib.protocol.datagram")
local ethernet = require("lib.protocol.ethernet")
local ipv4     = require("lib.protocol.ipv4")
local alarms = require("lib.yang.alarms")

alarms.add_to_inventory {
  [{alarm_type_id='arp-resolution'}] = {
    resource={'nic-v4'},
    has_clear=true,
    description='Raise up if ARP app cannot resolve IP address',
  }
}
local resolve_alarm = alarms.declare_alarm {
   [{resource='nic-v4', alarm_type_id='arp-resolution'}] = {
      perceived_severity = 'critical',
		alarm_text = 'Make sure you can ARP resolve IP addresses on NIC',
	},
}

local C = ffi.C
local receive, transmit = link.receive, link.transmit
local htons, ntohs = lib.htons, lib.ntohs

local ether_header_t = ffi.typeof [[
/* All values in network byte order.  */
struct {
   uint8_t  dhost[6];
   uint8_t  shost[6];
   uint16_t type;
} __attribute__((packed))
]]
local arp_header_t = ffi.typeof [[
/* All values in network byte order.  */
struct {
   uint16_t htype;      /* Hardware type */
   uint16_t ptype;      /* Protocol type */
   uint8_t  hlen;       /* Hardware address length */
   uint8_t  plen;       /* Protocol address length */
   uint16_t oper;       /* Operation */
   uint8_t  sha[6];     /* Sender hardware address */
   uint8_t  spa[4];     /* Sender protocol address */
   uint8_t  tha[6];     /* Target hardware address */<commit_msg>Remove tabs<commit_after>-- Use of this source code is governed by the Apache 2.0 license; see COPYING.

-- ARP address resolution (RFC 826)

-- Given a remote IPv4 address, try to find out its MAC address.
-- If resolution succeeds:
-- All packets coming through the 'south' interface (ie, via the network card)
-- are silently forwarded (unless dropped by the network card).
-- All packets coming through the 'north' interface (the lwaftr) will have
-- their Ethernet headers rewritten.

module(..., package.seeall)

local bit      = require("bit")
local ffi      = require("ffi")
local packet   = require("core.packet")
local link     = require("core.link")
local lib      = require("core.lib")
local datagram = require("lib.protocol.datagram")
local ethernet = require("lib.protocol.ethernet")
local ipv4     = require("lib.protocol.ipv4")
local alarms = require("lib.yang.alarms")

alarms.add_to_inventory {
  [{alarm_type_id='arp-resolution'}] = {
    resource={'nic-v4'},
    has_clear=true,
    description='Raise up if ARP app cannot resolve IP address',
  }
}
local resolve_alarm = alarms.declare_alarm {
   [{resource='nic-v4', alarm_type_id='arp-resolution'}] = {
      perceived_severity = 'critical',
      alarm_text = 'Make sure you can ARP resolve IP addresses on NIC',
   },
}

local C = ffi.C
local receive, transmit = link.receive, link.transmit
local htons, ntohs = lib.htons, lib.ntohs

local ether_header_t = ffi.typeof [[
/* All values in network byte order.  */
struct {
   uint8_t  dhost[6];
   uint8_t  shost[6];
   uint16_t type;
} __attribute__((packed))
]]
local arp_header_t = ffi.typeof [[
/* All values in network byte order.  */
struct {
   uint16_t htype;      /* Hardware type */
   uint16_t ptype;      /* Protocol type */
   uint8_t  hlen;       /* Hardware address length */
   uint8_t  plen;       /* Protocol address length */
   uint16_t oper;       /* Operation */
   uint8_t  sha[6];     /* Sender hardware address */
   uint8_t  spa[4];     /* Sender protocol address */
   uint8_t  tha[6];     /* Target hardware address */
{'fraction_non_alphanumeric': 0.12143202709240446, 'fraction_numerical': 0.01451378809869376, 'mean_word_length': 3.280538302277433, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3999296', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1313, 'n_words': 417}