Debian Codegraph @

agent/mibgroup/ip-mib/data_access/arp_common.c

raw
1 /*
2 * Arp MIB architecture support
3 *
4 * $Id$
5 */
6 #include <net-snmp/net-snmp-config.h>
7 #include <net-snmp/net-snmp-includes.h>
8
9 #include <net-snmp/agent/net-snmp-agent-includes.h>
10 #include <net-snmp/data_access/arp.h>
11
12 /**---------------------------------------------------------------------*/
13 /*
14 * arp_entry functions
15 */
16 /**
17 */
18 netsnmp_arp_entry *
19 netsnmp_access_arp_entry_create(void)
20 {
21 netsnmp_arp_entry *entry =
22 SNMP_MALLOC_TYPEDEF(netsnmp_arp_entry);
23
24 if (NULL == entry)
25 return NULL;
26
27 entry->oid_index.len = 1;
28 entry->oid_index.oids = &entry->ns_arp_index;
29
30 return entry;
31 }
32
33 /**
34 */
35 void
36 netsnmp_access_arp_entry_free(netsnmp_arp_entry * entry)
37 {
38 free(entry);
39 }
40
41 /**---------------------------------------------------------------------*/
42 /*
43 * Utility routines
44 */
45
46 /**
47 * Update given entry with new data. Calculate new arp_last_updated, if any
48 * field is changed.
49 */
50 void netsnmp_access_arp_entry_update(netsnmp_arp_entry *entry,
51 netsnmp_arp_entry *new_data)
52 {
53 int modified = 0;
54
55 entry->generation = new_data->generation;
56 if (entry->arp_ipaddress_len != new_data->arp_ipaddress_len
57 || memcmp(entry->arp_ipaddress, new_data->arp_ipaddress, entry->arp_ipaddress_len) != 0 ) {
58 modified = 1;
59 entry->arp_ipaddress_len = new_data->arp_ipaddress_len;
60 memcpy(entry->arp_ipaddress, new_data->arp_ipaddress, sizeof(entry->arp_ipaddress));
61 }
62 if (entry->arp_physaddress_len != new_data->arp_physaddress_len ||
63 memcmp(entry->arp_physaddress, new_data->arp_physaddress, entry->arp_physaddress_len) != 0) {
64 modified = 1;
65 entry->arp_physaddress_len = new_data->arp_physaddress_len;
66 memcpy(entry->arp_physaddress, new_data->arp_physaddress, sizeof(entry->arp_physaddress_len));
67 }
68 if (entry->arp_state != new_data->arp_state) {
69 modified = 1;
70 entry->arp_state = new_data->arp_state;
71 }
72 if (entry->arp_type != new_data->arp_type) {
73 modified = 1;
74 entry->arp_type = new_data->arp_type;
75 }
76 if (entry->flags != new_data->flags) {
77 modified = 1;
78 entry->flags = new_data->flags;
79 }
80
81 if (modified)
82 entry->arp_last_updated = netsnmp_get_agent_uptime();
83 }