| 137 | |
| 138 | |
| 139 | static int |
| 140 | neigh_ip4_add(uint32_t ip, uint64_t mac) |
| 141 | { |
| 142 | struct neigh_ipv4_config *v4_config; |
| 143 | int rc = -EINVAL; |
| 144 | |
| 145 | v4_config = find_neigh4_entry(ip, mac); |
| 146 | |
| 147 | if (!v4_config) { |
| 148 | v4_config = malloc(sizeof(struct neigh_ipv4_config)); |
| 149 | if (!v4_config) |
| 150 | return -ENOMEM; |
| 151 | } |
| 152 | |
| 153 | v4_config->ip = ip; |
| 154 | v4_config->mac = mac; |
| 155 | v4_config->is_used = true; |
| 156 | |
| 157 | if (!graph_status_get()) |
| 158 | goto exit; |
| 159 | |
| 160 | rc = ip4_rewrite_node_add(v4_config); |
| 161 | if (rc) |
| 162 | goto free; |
| 163 | |
| 164 | exit: |
| 165 | TAILQ_INSERT_TAIL(&neigh4, v4_config, next); |
| 166 | return 0; |
| 167 | free: |
| 168 | free(v4_config); |
| 169 | return rc; |
| 170 | } |
| 171 | |
| 172 | static int |
| 173 | neigh_ip6_add(uint8_t *ip, uint64_t mac) |
no test coverage detected