Exemple #1
0
int
netsnmp_access_arp_container_arch_load(netsnmp_container *container)
{
    int rc = 0, idx_offset = 0;

    rc = _load_v4(container, idx_offset);
    if(rc < 0) {
        u_int flags = NETSNMP_ACCESS_ARP_FREE_KEEP_CONTAINER;
        netsnmp_access_arp_container_free(container, flags);
        return rc;
    }

#if defined (INET6) && 0 /* xx-rks: arp for v6? */
    idx_offset = rc;

    rc = _load_v6(container, idx_offset);
    if(rc < 0) {
        u_int flags = NETSNMP_ACCESS_ARP_FREE_KEEP_CONTAINER;
        netsnmp_access_arp_container_free(container, flags);
    }
#endif

    /*
     * return no errors (0) if we found any interfaces
     */
    if(rc > 0)
        rc = 0;

    return rc;
}
Exemple #2
0
static gboolean
_load(PersistState *self, gboolean all_errors_are_fatal, gboolean load_all_entries)
{
  FILE *persist_file;
  gboolean success = FALSE;

  persist_file = fopen(self->commited_filename, "r");
  if (persist_file)
    {
      SerializeArchive *sa;
      gchar magic[4];
      gint version;

      sa = serialize_file_archive_new(persist_file);
      serialize_read_blob(sa, magic, 4);
      if (memcmp(magic, "SLP", 3) != 0)
        {
          msg_error("Persistent configuration file is in invalid format, ignoring", NULL);
          success = all_errors_are_fatal ? FALSE : TRUE;
          goto close_and_exit;
        }
      version = magic[3] - '0';
      if (version >= 2 && version <= 3)
        {
          success = _load_v23(self, version, sa);
        }
      else if (version == 4)
        {
          success = _load_v4(self, load_all_entries);
        }
      else
        {
          msg_error("Persistent configuration file has an unsupported major version, ignoring",
                    evt_tag_int("version", version),
                    NULL);
          success = TRUE;
        }
    close_and_exit:
      fclose(persist_file);
      serialize_archive_free(sa);
    }
  else
    {
      if (all_errors_are_fatal)
      {
        msg_error("Failed to open persist file!",
                    evt_tag_str("filename", self->commited_filename),
                    evt_tag_str("error", strerror(errno)),
                    NULL);
        success = FALSE;
      }
      else
        success = TRUE;
    }
  return success;
}
Exemple #3
0
int netsnmp_access_arp_load(netsnmp_arp_access *access)
{
    int rc = 0;

    access->generation++;
    rc =_load_v4(access);
    access->gc_hook(access);
    access->synchronized = (rc == 0);

    return rc;
}
Exemple #4
0
/**
 *
 * @retval  0 no errors
 * @retval !0 errors
 */
int netsnmp_arch_ipaddress_container_load (netsnmp_container * container, u_int load_flags)
{
    int rc = 0, idx_offset = 0;

    if (!(load_flags & NETSNMP_ACCESS_IPADDRESS_LOAD_IPV6_ONLY))
    {
        rc = _load_v4 (container, idx_offset);
        if (rc < 0)
        {
            u_int flags = NETSNMP_ACCESS_IPADDRESS_FREE_KEEP_CONTAINER;

            netsnmp_access_ipaddress_container_free (container, flags);
        }
    }

#if defined( NETSNMP_ENABLE_IPV6 )

    if (!(load_flags & NETSNMP_ACCESS_IPADDRESS_LOAD_IPV4_ONLY))
    {
        if (rc < 0)
            rc = 0;

        idx_offset = rc;

        rc = _load_v6 (container, idx_offset);
        if (rc < 0)
        {
            u_int flags = NETSNMP_ACCESS_IPADDRESS_FREE_KEEP_CONTAINER;

            netsnmp_access_ipaddress_container_free (container, flags);
        }
    }
#endif

    /*
     * return no errors (0) if we found any interfaces
     */
    if (rc > 0)
        rc = 0;
    return rc;
}