/* FUNCTION: ftpc_nvset() * * PARAM1: NV_FILE * fp * * RETURNS: Silent return of 0 for OK */ int ftpc_nvset(NV_FILE * fp) { int i = 0; nv_fprintf(fp, ftpc_nvformats[i++].pattern, ftpc_nvparms.fc_replytmo); nv_fprintf(fp, ftpc_nvformats[i++].pattern, ftpc_nvparms.fc_activity_tmo); return 0; }
/* FUNCTION: comport_nvset() * * PARAM1: NV_FILE * fp * * RETURNS: Silent return of 0 for OK */ int comport_nvset(NV_FILE * fp) { int i = 0; if (comport_nvparms.comport != '1' && comport_nvparms.comport !='2' ) comport_nvparms.comport='1'; nv_fprintf(fp, comport_nvformats[i++].pattern, comport_nvparms.comport); nv_fprintf(fp, comport_nvformats[i++].pattern, (comport_nvparms.LineProtocol == PPP) ? "PPP":"SLIP"); return 0; }
void log_with_type(log_data_t *p, logTypeEnum log_type, char *pstr, int printf_flag) { char timeBuffer[100]; if(log_type > LOG_TYPE_NONE && log_type < LOG_TYPE_MAX_NUM) { if(p == NULL) { return; } if(log_type > p->log_level) { return; } p->log_counts[log_type]++; if(pstr) { convLocalTimeToString(timeBuffer); #ifdef USE_LOGFILE if(p->log_fp) { nv_fprintf(p->log_fp, "%s %lu %s %s\n", logTypeStr[log_type], p->log_counts[log_type], timeBuffer, pstr); } #endif if(printf_flag) { ns_printf(p->pio, "%s %lu %s %s\n", logTypeStr[log_type], p->log_counts[log_type], timeBuffer, pstr); } } } } /* log_with_type() */
/* FUNCTION: vfs_nvset() * * PARAM1: NV_FILE * fp * * RETURNS: Silent return of 0 for OK */ int vfs_nvset(NV_FILE * fp) { int i = 0; nv_fprintf(fp, vfs_nvformats[i++].pattern, vfs_root_path); return 0; }
/* FUNCTION: inet_nvset() * * PARAM1: NV_FILE * fp * * RETURNS: Silent return of 0 for OK */ int inet_nvset(NV_FILE * fp) { int j=0; struct l2b ip; /* structure for IP address conversions */ int iface; /* nets[] index */ /* fill in nvparms from set active values */ /* IP addressing parameters and IGMP mode section: */ for (iface = 0; iface < MAXNETS; iface++) { j = 0; /* inet_nvformats element currently being witten */ nv_fprintf(fp, inet_nvformats[j++].pattern, iface); ip.ip.iplong = inet_nvparms.ifs[iface].ipaddr; nv_fprintf(fp, inet_nvformats[j++].pattern, ip.ip.ipchar[0], ip.ip.ipchar[1], ip.ip.ipchar[2], ip.ip.ipchar[3]); ip.ip.iplong = inet_nvparms.ifs[iface].subnet; nv_fprintf(fp, inet_nvformats[j++].pattern, ip.ip.ipchar[0], ip.ip.ipchar[1], ip.ip.ipchar[2], ip.ip.ipchar[3]); ip.ip.iplong = inet_nvparms.ifs[iface].gateway; nv_fprintf(fp, inet_nvformats[j++].pattern, ip.ip.ipchar[0], ip.ip.ipchar[1], ip.ip.ipchar[2], ip.ip.ipchar[3]); nv_fprintf(fp, inet_nvformats[j++].pattern, (inet_nvparms.ifs[iface].client_dhcp)?"YES":"NO"); #if defined (IP_MULTICAST) && (defined (IGMP_V1) || defined (IGMP_V2)) nv_fprintf(fp, inet_nvformats[j++].pattern, inet_nvparms.ifs[iface].igmp_oper_mode); #endif /* IP_MULTICAST and (IGMPv1 or IGMPv2) */ } #ifdef DNS_CLIENT { int i; for (i = 0; i < MAXDNSSERVERS; i++) { ip.ip.iplong = inet_nvparms.dns_servers[i]; nv_fprintf(fp, inet_nvformats[j++].pattern, ip.ip.ipchar[0], ip.ip.ipchar[1], ip.ip.ipchar[2], ip.ip.ipchar[3]); } } #ifdef DNS_CLIENT_UPDT nv_fprintf(fp, inet_nvformats[j++].pattern, inet_nvparms.dns_zone_name); #endif /* DNS_CLIENT_UPDT */ #endif /* DNS_CLIENT */ return 0; }
void nv_defaults() { int iface = 0; VFILE *fp; int e; /* store default IP info */ #ifdef USE_SMSC91X inet_nvparms.ifs[iface].ipaddr = htonl(0x0a000067); /* 10.0.0.106 */ #ifdef USE_PPPOE inet_nvparms.ifs[iface].subnet = htonl(0xfffe0000); /* 255.254.0.0 */ inet_nvparms.ifs[iface].gateway = htonl(0x00000000); /* 0.0.0.0 */ #else inet_nvparms.ifs[iface].subnet = htonl(0xff000000); /* 255.0.0.0 */ inet_nvparms.ifs[iface].gateway = htonl(0x0a000001); /* 10.0.0.1 */ #endif inet_nvparms.ifs[iface].client_dhcp = 0; dprintf("nv_defaults: set net %d IP to %u.%u.%u.%u\n", iface, PUSH_IPADDR(inet_nvparms.ifs[iface].ipaddr) ); iface++; #endif /* */ #ifdef USE_PPP /* PPP */ inet_nvparms.ifs[iface].ipaddr = htonl(0x00000000); inet_nvparms.ifs[iface].subnet = htonl(0xffffff00); /* 255.255.255.0 */ inet_nvparms.ifs[iface].gateway = htonl(0xc0a80801); /* 192.168.8.1 */ iface++; #ifdef LB_XOVER inet_nvparms.ifs[iface].ipaddr = htonl(0x00000000); inet_nvparms.ifs[iface].subnet = htonl(0x00000000); inet_nvparms.ifs[iface].gateway = htonl(0x00000000); iface++; #endif /* LB_XOVER */ #endif /* USE_PPP */ /* loopback */ inet_nvparms.ifs[iface].ipaddr = htonl(0x00000000); inet_nvparms.ifs[iface].subnet = htonl(0x00000000); inet_nvparms.ifs[iface].gateway = htonl(0x00000000); #ifdef USE_COMPORT comport_nvparms.LineProtocol = 1; #endif /* defined (USE_PPP) || defined(USE_SLIP) */ #ifdef USE_PPP ppp_nvparms.ppp_ConsoleLog = 0; /* Log Modem & PPP events to console */ ppp_nvparms.ppp_FileLog = 0; /* Log Modem & PPP events to file */ ppp_nvparms.ppp_keepalive = 0; /* seconds between PPP echos, 0=disable */ ppp_nvparms.ppp_client_tmo = 500; /* timeout for connects as client */ ppp_nvparms.line_tmo = 300; #ifdef PPP_VJC ppp_nvparms.ppp_request_vj = 1; /* request that the other side do VJ compression */ #endif /* PPP_VJC */ #ifdef PAP_SUPPORT ppp_nvparms.require_pap = 0; #endif /* PAP_SUPPORT */ #ifdef USE_PPPOE strcpy(ppp_nvparms.username, "ppptest2"); strcpy(ppp_nvparms.password, "2ppptest"); strcpy(ppp_nvparms.secret, "2ppptest"); #endif /* USE_PPPOE */ #endif /* USE_PPP */ #ifdef USE_MODEM strcpy(modem_nvparms.dial_phone, "YOUR_ISP_PHONE\n"); strcpy(ppp_nvparms.username, "YOUR_ISP_NAME"); strcpy(ppp_nvparms.password, "YOUR_ISP_PASSWORD"); strcpy(modem_nvparms.modem_init, "AT&D0&C1\n"); strcpy(ppp_nvparms.loginfile, logfilename); strcpy(ppp_nvparms.logservefile, srvfilename); #endif /* USE_MODEM */ #ifdef USE_COMPORT comport_nvparms.comport = '2'; comport_nvparms.LineProtocol = 1; #endif /* USE_COMPORT */ #ifdef NATRT natrt_nvparms.nat_enabled = 1; natrt_nvparms.nat_inet = 1; natrt_nvparms.nat_localnet = 0; natrt_nvparms.tcp_timeout = 300; natrt_nvparms.udp_timeout = 500; #endif /* NATRT */ #ifdef SMTP_ALERTS smtp_nvparms.mserver = htonl(0x00000000); strcpy(smtp_nvparms.rcpt, "\n"); #endif /* SMTP_ALERTS */ #ifdef DNS_CLIENT_UPDT strcpy(inet_nvparms.dns_zone_name, "iniche.com"); /* zone name */ #endif /* DNS_CLIENT_UPDT */ /* create the login script file */ fp = nv_fopen(logfilename, "w+"); if (fp == NULL) dprintf("error creating %s\n", logfilename); else { e = nv_fprintf(fp, "#\n#empty login.nv\n#\n"); if (e < 1) { dprintf("nv_defaults: error writing %s\n", logfilename); } nv_fclose(fp); } /* create the some required NV files */ nv_fopen(srvfilename, "w+"); nv_fopen(natfilename, "w+"); }