/* This file is part of Lcrzo.
*/

int lcrzo_priv_conf_init_rarpcache(void)
#if defined LCRZODEF_SYSTEM_Linux
{ int ret, c;
  FILE *pf;
  lcrzo_ips ips;
  lcrzo_ipl ipl;
  lcrzo_etha etha;

  /*ouverture du procfs*/
  pf=fopen("/proc/net/rarp", "r");
  if (pf==NULL) 
  { /* because rarp may not exist on the system */
    lcrzo_err_purge();
    return (LCRZO_ERR_OK);
  }

  /*on passe l'entete*/
  c=fgetc(pf);
  while ( c!=0x0A && c!=EOF ) c=fgetc(pf);

  /*on lit les entrees*/
  while(!feof(pf))
  { lcrzo_eths ethsat[5];
    int nb;
    nb=fscanf(pf, "%16s %20s %20s %20s %20s %20s\n", ips,
	      ethsat[0], ethsat[1], ethsat[2], ethsat[3], ethsat[4]);
    ret=lcrzo_etha_init_eths(ethsat[nb-2], etha);
    if ( ret!=LCRZO_ERR_OK ) continue;
    ret=lcrzo_ipl_init_ips(ips, &ipl);
    if ( ret!=LCRZO_ERR_OK ) continue;
    lcrzo_efr(lcrzo_priv_conf_arp_add_system("", etha, ipl, LCRZO_FALSE), 
	      fclose(pf));
  }
  ret=fclose(pf);
  if ( ret == -1 ) return(LCRZO_ERR_FUFCLOSE);
  return(LCRZO_ERR_OK);
}
#elif defined LCRZODEF_SYSTEM_FreeBSD || defined LCRZODEF_SYSTEM_Solaris || defined LCRZODEF_SYSTEM_OpenBSD || defined LCRZODEF_SYSTEM_Windows
{ return(LCRZO_ERR_IEUNIMPLEMENTED);
}
#else
 #error "Unknown value for LCRZODEF_SYSTEM"
#endif

/*-------------------------------------------------------------*/
int lcrzo_priv_conf_rarpcache_debug_fprint(LCRZOFILE *pf)
{ return(LCRZO_ERR_OK);
  pf=pf;
}

