Пример #1
0
static void
rttmo(struct avl_node * node, long param, int depth)
{
   RTMIB rt = (RTMIB)node;

   /* only time out the routes with type "other". Entries set by RIP,
    * SNMP, users, etc., should have their own mechanisms for cleanup.
    */
   if(rt->ipRouteProto != IPRP_OTHER)
      return;

   if (!btreeRoot)
	   return;

   /* Check timestamp to see when this was last used */
   if((rt->ipRouteAge < rtb_delctick) ||
      (rt->ipRouteAge > cticks))     /* catch cticks wrapping */
   {
      ip_addr key;      /* for pass to avlremove() */

       /* If the cached route is the one being deleted then clear the cache */
      if (rt == cachedRoute)
         cachedRoute = NULL;
    
	  ((RTMIB)node)->ipRouteNextHop = 0; /* clear route */
      key = htonl(((RTMIB)node)->ipRouteDest);     /* pass key in machine endian */
	  avlremove((struct avl_node **)&btreeRoot, (void*)&key);
   }
   USE_ARG(depth);
   USE_ARG(param);
}
Пример #2
0
VFILE* 
md_fopen(char * name, char * mode)
{
   USE_ARG(mode);
   USE_ARG(name);
   return NULL;
}
Пример #3
0
int
t_getsockopt(long s,
   int   level,
   int   name,
   void *   arg,
   int   arglen)

{
   struct socket *   so;
   int   err;

   so = LONG2SO(s);
   SOC_CHECK(so);
   USE_ARG(level);
   USE_ARG(arglen);

   LOCK_NET_RESOURCE (NET_RESID);

   INET_TRACE (INETM_SOCKET,
    ("INET: getsockopt: name %x val %x valsize %d\n",
    name, val));

   /* is it a level IP_OPTIONS call? */
   if (level != IP_OPTIONS)
   {
      if ((err = sogetopt (so, name, arg)) != 0) 
      {
         so->so_error = err;
         UNLOCK_NET_RESOURCE (NET_RESID);
         return SOCKET_ERROR;
      }
   }
   else
   {
      /* level 1 options are for the IP packet level.
       * the info is carried in the socket CB, then put 
       * into the PACKET.
       */
      if (name == IP_TTL_OPT)
      {
         if (!so->so_optsPack) *(int *)arg = IP_TTL;
         else *(int *)arg = (int)so->so_optsPack->ip_ttl;
      }
      else if (name == IP_TOS)
      {
         if (!so->so_optsPack) *(int *)arg = IP_TOS_DEFVAL;
         else *(int *)arg = (int)so->so_optsPack->ip_tos;
      }
      else
      {
         UNLOCK_NET_RESOURCE (NET_RESID);
         return SOCKET_ERROR;
      }
   }   
   so->so_error = 0;

   UNLOCK_NET_RESOURCE (NET_RESID);
   return 0;
}
Пример #4
0
int
md_fseek(VFILE * vfd, long offset, int mode)
{
   USE_ARG(vfd);     /* supress compiler warnings */
   USE_ARG(offset);
   USE_ARG(mode);
   return 0;
}
Пример #5
0
void ftpc_callback(void *fc,int logstate, int cmdstate)
{
   /*
   dprintf("logstate=%d, cmdstate=%d\n",logstate,cmdstate);
   */

   USE_VOID(fc);
   USE_ARG(logstate);
   USE_ARG(cmdstate);
}
Пример #6
0
int
em_fwrite(char * buf, unsigned size1, unsigned size2, void * fd)
{
   int      error;

   dtrap();

   USE_ARG(buf);
   USE_ARG(size1);
   USE_ARG(size2);
   error = em_verify((EOFILE*)fd);
   if(error)
      return error;
   return 0;
}
Пример #7
0
unsigned
digest_get_prefix(unsigned hashalg, uint8_t *prefix, size_t size)
{
    USE_ARG(size);
    if (prefix == NULL) {
        return 0;
    }
    switch (hashalg) {
    case MD5_HASH_ALG:
        memcpy(prefix, prefix_md5, sizeof(prefix_md5));
        return sizeof(prefix_md5);
    case SHA1_HASH_ALG:
        memcpy(prefix, prefix_sha1, sizeof(prefix_sha1));
        return sizeof(prefix_sha1);
    case SHA256_HASH_ALG:
        memcpy(prefix, prefix_sha256, sizeof(prefix_sha256));
        return sizeof(prefix_sha256);
    case SHA512_HASH_ALG:
        memcpy(prefix, prefix_sha512, sizeof(prefix_sha512));
        return sizeof(prefix_sha512);
    default:
        printf("digest_get_prefix: unknown hash algorithm: %d\n", hashalg);
        return 0;
    }
}
Пример #8
0
int
mcastlist(struct in_multi * multi_ptr)
{
   USE_ARG(multi_ptr);

   return 0;
}
Пример #9
0
void
netpgp_deallocate(void *ptr, size_t size)
{
#ifdef _KERNEL
    kmem_free(ptr, size);
#else
    USE_ARG(size);
    free(ptr);
#endif
}
Пример #10
0
int
vfs_sync_close(void * xfd)
{
   /* more compiler warning suppression */
   unsigned long *fd = xfd;

   USE_ARG(fd);
   /* this close can't fail, so return 0 */
   return 0;
}
Пример #11
0
int    
md_fwrite(char * buf, unsigned size, unsigned items, VFILE * vfd)
{
   if (vfd->file->name[0] == 'm')   /* memory device */
      return 0;   /* not writable device */

   vfd->cmploc += (items * size);   /* adjust location */

   USE_ARG(buf);     /* supress compiler warnings */

   return (items);
}
Пример #12
0
int
lb_reg_type(unshort type, struct net * netp)
{
   if (type == htons(0x0800))
      acceptIP = TRUE;
   else if(type == htons(0x0806))
      acceptIP = TRUE;
   else
      return -1;  /* this is an error - we only do ARP and IP */

   USE_ARG(netp);
   return 0;
}
Пример #13
0
/* FUNCTION: bsd_select()
 *
 * Synchronous I/O multiplexing (for sockets)
 *
 * PARAM1: nfds; IN - the number of fds to be checked in each set (readfds,
 *               writefds, exceptfds): not used in this release
 * PARAM2: readfds; IN/OUT - fd set containing descriptors to be examined
 *                  for readiness to read (i.e. received data is present
 *                  and can be retreived by recv() or recvfrom() without
 *                  blocking); on successful return, will contain 
 *                  only those descriptors that are ready to read
 * PARAM3: writefds; IN/OUT - fd set containing descriptors to be examined
 *                   for readiness to write (e.g. send() or sendto() could
 *                   succeed without blocking, or socket has connect()ed);
 *                   on successful return, will contain only those 
 *                   descriptors that are ready to write
 * PARAM4: exceptfds; IN/OUT - fd set containing descriptors to be examined
 *                    for exceptional conditions (i.e. out-of-band data
 *                    pending on socket); on successful return
 * PARAM5: timeout; IN - ptr to a struct timeval, which should be set to
 *                  indicate the maximum interval to wait for any 
 *                  descriptor(s) to become ready; may be NULL, indicating 
 *                  that select() can wait indefinitely for any descriptor(s) 
 *                  to become ready
 * RETURNS: if successful, the number of ready file descriptors in all
 *          the fd sets (may be 0 if the timeout expired), or -1 if an
 *          error occured.  The error would be available via bsd_errno(s).
 */
int 
bsd_select(int nfds,
           fd_set * readfds,
           fd_set * writefds,
           fd_set * exceptfds,
           BSD_TIMEVAL_T * timeout)
{
   long ltv;    /* timeout expressed in ticks */
   long tps;    /* local copy of TPS */

   USE_ARG(nfds);

   if (timeout != NULL)
   {
      /* This turning of a struct timeval into a tick-count timeout
       * assumes that TPS (ticks-per-second) is a reasonably small
       * integer, and that tv_usec may be anywhere from 0 to one
       * million (i.e. any number of microseconds up to one second).
       * So we scale tv_usec from microseconds to something reasonable
       * based on TPS, multiply it by TPS, then scale it the rest of
       * the way to ticks-per-second.
       */
      tps = TPS;
      if (tps >= 1000)
      {
         ltv = (((timeout->tv_usec + 50) / 100) * tps) / 10000;
      }
      else if (tps >= 100)
      {
         ltv = (((timeout->tv_usec + 500) / 1000) * tps) / 1000;
      }
      else if (tps >= 10)
      {
         ltv = (((timeout->tv_usec + 5000) / 10000) * tps) / 100;
      }
      else
      {
         ltv = (((timeout->tv_usec + 50000) / 100000) * tps) / 10;
      }
      ltv += (timeout->tv_sec * TPS);
   }
   else {
      /*
       * NULL timeout: wait indefinitely in t_select()
       */
      ltv = -1;
   }

   return (t_select(readfds, writefds, exceptfds, ltv));
}
Пример #14
0
char * 
wi_getdate(wi_sess * sess)
{
   time_t      timeval;
   struct tm * gmt;

   USE_ARG(sess);
   timeval = time(NULL);
   gmt = gmtime(&timeval);

   sprintf(datebuf, "%s, %u %s %u %u:%u:%u GMT",
      day[gmt->tm_wday],
      gmt->tm_mday,
      month[gmt->tm_mon],
      gmt->tm_year + 1900, /* Windows year is based on 1900 */
      gmt->tm_hour,
      gmt->tm_min,
      gmt->tm_wday);

   return datebuf;
}
Пример #15
0
static void
rtdel(struct avl_node * node, long param, int depth)
{
   struct RtMib * n = (struct RtMib *)node;
   ip_addr key;

   if (!btreeRoot)
	   return;

   if(n->ifp == (struct net *)param)
   {
      /* If the cached route is the one being deleted then clear the cache */
      if (n == cachedRoute)
         cachedRoute = NULL;
      /* delete the entry n. */
	  n->ipRouteNextHop = 0; /* clear route */
      key = htonl(n->ipRouteDest);     /* pass key in machine endian */
      avlremove((struct avl_node **)&btreeRoot, (void*)&key);
      rtdeletions++;
   }
   USE_ARG(depth);
}
Пример #16
0
void 
netmain_init(void)
{
   int   e;
   int   i;
   char *   msg;
#ifdef IP_V6
   ip6_addr host;
#endif

   printf("\n%s\n", name);
   printf("Copyright 1997-2006 by InterNiche Technologies. All rights reserved. \n");

#ifndef SUPERLOOP
   /* call this to do pre-task setup including intialization of port_prep */
   msg = pre_task_setup();
   if (msg)
      panic(msg);
#endif

#ifdef INCLUDE_NVPARMS     /* system uses InterNiche NV system */
   e = get_nv_params();    /* get flash parameters into data structs */
   if (e)
   {
      printf("fatal error (%d) reading NV parameters.\n", e);
      panic("nv");
   }

   /* set static iface IP info up from stored parameters. These may 
   be overwritten from command line parms or DHCP later. */
   for (i = 0; i < STATIC_NETS; i++)
   {
      netstatic[i].n_ipaddr = inet_nvparms.ifs[i].ipaddr;
      netstatic[i].snmask = inet_nvparms.ifs[i].subnet;
      netstatic[i].n_defgw = inet_nvparms.ifs[i].gateway;
#ifdef IP_MULTICAST
      /* Create a dummy entry for the Ethernet interface mcastlist */
      /* If this entry is set to NULL, multicast is not supported  */
      /* on this interface */
      netstatic[i].n_mcastlist = mcastlist;
#endif   /* IP_MULTICAST */
#ifdef IP_V6
      IP6CPY(&host, &inet_nvparms.ifs[i].ipv6addr);
      if ( (host.addr[0] == 0xFE) && (host.addr[1] == 0xC0))
      {
         netstatic[i].v6addrs[IPA_SITE] = ip6_mkaddr(&netstatic[i], 
            IPA_SITE, &host);
      }
      else if ( (host.addr[0] == 0xFE) && (host.addr[1] == 0x80) )
      {
         printf ("[IPV6 init]error : bad IPV6 address\n");
      }
      else if (host.addr[0] != 0)
      {
         netstatic[i].v6addrs[IPA_GLOBAL] = ip6_mkaddr(&netstatic[i], 
            IPA_GLOBAL, &host );
      }
#endif
   }

#ifdef DNS_CLIENT
   /* set DNS client's server list from nvparms information */
   MEMCPY(dns_servers, inet_nvparms.dns_servers, sizeof(dns_servers));

#ifdef DNS_CLIENT_UPDT
   MEMCPY(soa_mname, inet_nvparms.dns_zone_name, sizeof(soa_mname));
#endif   /* DNS_CLIENT_UPDT */

#endif   /* DNS_CLIENT */

#ifdef USE_COMPORT
   comportcfg.comport = comport_nvparms.comport;
   comportcfg.LineProtocol = comport_nvparms.LineProtocol;
#endif   /* USE_COMPORT */
#endif   /* INCLUDE_NVPARMS */

#ifndef INCLUDE_NVPARMS
#ifdef USE_COMPORT
   comportcfg.comport = 0x01;
   comportcfg.LineProtocol = PPP;   /* Default to PPP */
#endif   /* USE_COMPORT */
#endif   /* INCLUDE_NVPARMS */

   msg = ip_startup();
   if (msg)
   {
      printf("inet startup error: %s\n", msg);
      panic("IP");
   }

#if defined(MEMDEV_SIZE) && defined(VFS_FILES)
   init_memdev(); /* init the mem and null test devices */
#endif

#ifdef IP_MULTICAST
#ifdef INCLUDE_TCP
   /* call the IP multicast test program */
   u_mctest_init();
#endif
#endif  

   /* clear debugging flags. Port can optionally turn them
    * back on in post_task_setup();
    * NDEBUG = UPCTRACE | IPTRACE | TPTRACE ;  
    */
   NDEBUG = 0;    

   /* print IP address of the first interface - for user's benefit */
   printf("IP address of %s : %s\n" , ((NET)(netlist.q_head))->name,
      print_ipad(((NET)(netlist.q_head))->n_ipaddr));
 
#ifndef SUPERLOOP
   /* call this per-target routine after basic tasks & net are up */
   msg = post_task_setup();
   if (msg)
      panic(msg);
#endif

#ifdef PING_APP
   ping_init();
#endif   /* PING_APP */

#ifdef RAWIPTEST
   raw_test_init();
#endif   /* RAWIPTEST */

#if defined(TFTP_CLIENT) || defined(TFTP_SERVER)
   tftp_init();
#endif   /* TFTP */

#ifdef TESTMENU
   install_menu(testmenu);
#endif   /* TESTMENU */

#ifdef USE_AUTOIP
   Upnp_init();      /* start Auto IP before DHCP client */
#endif   /* USE_AUTOIP */

#ifdef DHCP_CLIENT
	if( POWERUP_CONFIG_DHCP_ENABLED )
   		dhc_setup();   /* kick off any DHCP clients */
#endif   /* DHCP_CLIENT */

#ifdef DHCP_SERVER
#ifdef INCLUDE_NVPARMS
   if(dhserve_nvparms.ServeDHCP)
#endif
   {
      e = dhcp_init();
      if(e)
      {
         dprintf("Error %d starting DHCP server.\n",e);
      }
      else
      {
         exit_hook(dhcpsrv_cleanup);
         dprintf("Started DHCP server\n");
      }
   }
#endif /* DHCP_SERVER */

#ifdef IN_MENUS
   printf(prompt);
#endif

#ifdef UDPSTEST
   e=udp_echo_init();
   if ( e == SUCCESS )
   {
      exit_hook(udp_echo_cleanup);
   }
   else
      dprintf("Error %d starting UDP Echo server.\n",e);
#endif

#ifdef RIP_SUPPORT
   e=rip_init();
   if ( e == SUCCESS )
   {
      exit_hook(rip_cleanup);
   }
   else
      dprintf("Error %d starting RIP server.\n",e);
#endif

#ifdef INICHE_SYSLOG
   e =syslog_init();
   if (e == SUCCESS)
      exit_hook(closelog);
   else
      dprintf("Error %d initializing syslog client.\n",e);
#endif

#ifdef FTP_CLIENT
   fc_callback=ftpc_callback;
#endif

/* The following initializations take place when SUPERLOOP is enabled.
 * Otherwise they would be done in the respective task.
 */

#ifdef SUPERLOOP

#ifdef INCLUDE_SNMP
   e = snmp_init();
   if (e == SUCCESS)
      exit_hook(snmp_cleanup);
   else
      dprintf("Error %d initializing SNMP agent.\n",e);
#endif   /* INCLUDE_SNMP */

#ifdef WEBPORT
   e = http_init(); /* start up http server */
   if (e)
      dprintf("Error %d starting HTTP server.\n",e);
#endif   /* WEBPORT */

#ifdef FTP_SERVER
   e = ftps_init();
   if ( e == SUCCESS )
   {
      exit_hook(ftps_cleanup);
   }
   else
      dprintf("Error %d starting FTP server.\n",e);
#endif   /* FTP_SERVER */

#ifdef TELNET_SVR
   e=tel_init();
   if ( e == SUCCESS )
   {
      exit_hook(tel_cleanup);
   }
   else
      dprintf("Error %d starting TELNET server.\n",e);
#endif

#ifdef TCP_ECHOTEST
   e=tcp_echo_init();
   if ( e == SUCCESS )
   {
      exit_hook(tcp_echo_cleanup);
   }
   else
      dprintf("Error %d starting TCP Echo server.\n",e);
#endif
#ifdef TCP_CIPHERTEST
   e=tcp_cipher_init();
   if ( e == SUCCESS )
   {
      exit_hook(tcp_cipher_cleanup);
   }
   else
      dprintf("Error %d starting TCP cipher server.\n",e);
#endif
#ifdef USE_CRYPTOENG
   e = ce_init();
   if(e != 0)
   {
      dprintf("ce_init() failed\n");
      panic("prep_modules");
   }
#endif

#ifdef SMTP_ALERTS
   smtp_init ();
#endif

#endif   /* SUPERLOOP */

   USE_ARG(e);    /* Avoid compiler warnings */
   USE_ARG(i);

} /* end of netmain_init() */
Пример #17
0
/* FUNCTION: bsd_i_sockoptlen()
 *
 * Get the minimum length of a named socket option
 *
 * PARAM1: level; IN - the level of the option
 * PARAM2: name; IN - the name of the option
 * RETURNS: minimum length of the named socket option, in bytes
 */
int 
bsd_i_sockoptlen(int level,
                 int name)
{
   USE_ARG(level);

   switch (name)
   {
   case SO_BIO:
   case SO_NBIO:
      /* these don't use an option value */
      return 0;
   case SO_LINGER:
      /* this option is a struct linger */
      return sizeof(struct linger);
   case SO_RCVTIMEO:
   case SO_SNDTIMEO:
      /* these options are type short */
      return sizeof(short);
   case SO_KEEPALIVE:
   case SO_DONTROUTE:
   case SO_BROADCAST:
   case SO_REUSEADDR:
   case SO_OOBINLINE:
   case SO_SNDBUF:
   case SO_RCVBUF:
   case SO_NONBLOCK:
   case SO_ERROR:
   case SO_TYPE:
      /* these options are type int */
      return sizeof(int);
#ifdef TCP_ZEROCOPY
   case SO_CALLBACK:
      /* this option is a pointer to a function returning int */
      return sizeof(int (*)());
#endif /* TCP_ZEROCOPY */
#ifdef IP_MULTICAST
   case IP_MULTICAST_IF:
      /* this option is type ip_addr */
      return sizeof(ip_addr);
   case IP_MULTICAST_TTL:
   case IP_MULTICAST_LOOP:
      /* these options are type u_char */
      return sizeof(u_char);
   case IP_ADD_MEMBERSHIP:
   case IP_DROP_MEMBERSHIP:
      /* these options are struct ip_mreq */
      return sizeof(struct ip_mreq);
#endif /* IP_MULTICAST */
   case IP_TOS:
/*
 * Altera Niche Stack Nios port modification:
 * IP_TTL_OPT == SOREUSEADDR. This causes a build erro
 * due to duplicate cases. Removing this one. They both
 * return the same value (sizeof(int)).
 */
  // case IP_TTL_OPT:
      return sizeof(int);
   default:
      /* we don't know what type these options are */
      return 0;
   }
   
}
Пример #18
0
int
t_setsockopt(long s,
   int   level,
   int   name,
   void * arg,
   int arglen)
{
   struct socket *   so;
   int   err;

   so = LONG2SO(s);
   SOC_CHECK(so);
   USE_ARG(arglen);

   LOCK_NET_RESOURCE (NET_RESID);

   so->so_error = 0;
   INET_TRACE (INETM_SOCKET,
    ("INET: setsockopt: name %x val %x valsize %d\n",
    name, val));

   /* is it a level IP_OPTIONS call? */
   if (level != IP_OPTIONS)
   {
      if ((err = sosetopt (so, name, arg)) != 0) 
      {
         so->so_error = err;
         UNLOCK_NET_RESOURCE (NET_RESID);
         return SOCKET_ERROR;
      }
   }
   else
   {
   /* level 1 options are for the IP packet level.
    * the info is carried in the socket CB, then put 
    * into the PACKET.
    */
      if (!so->so_optsPack)
      {
         so->so_optsPack = (struct ip_socopts *) SOCOPT_ALLOC (sizeof(struct ip_socopts *));
         if (!so->so_optsPack) 
         {
            so->so_error = ENOMEM;
            UNLOCK_NET_RESOURCE (NET_RESID);
            return SOCKET_ERROR;
         }
      }
      
      if (name == IP_TTL_OPT)
         so->so_optsPack->ip_ttl = (u_char)(*(int *)arg);
      else
      if (name == IP_TOS)
         so->so_optsPack->ip_tos = (u_char)(*(int *)arg);
	   else
	   if (name == IP_SCOPEID)
            so->so_optsPack->ip_scopeid = (u_char)(*(u_int *)arg);
      else
      {
         UNLOCK_NET_RESOURCE (NET_RESID);
         return SOCKET_ERROR;
      }   
   }

   UNLOCK_NET_RESOURCE (NET_RESID);
   return 0;
}
Пример #19
0
int    
md_unlink(char * filename)
{
   USE_ARG(filename);     /* supress compiler warnings */
   return 0;
}
Пример #20
0
long   
md_ftell(VFILE * vfd)
{
   USE_ARG(vfd);     /* supress compiler warnings */
   return MEMDEV_SIZE;
}
Пример #21
0
struct in_multi * 
in_addmulti(ip_addr *ap, struct net *netp, int addrtype)
{
   struct in_multi *inm = (struct in_multi *)NULL;
   int error;

   /* check for good addr. */
   if ((ap == (ip_addr *)NULL) || (*ap == 0))
      return ((struct in_multi *)NULL);  

   ENTER_CRIT_SECTION(netp);

   /* See if address already in list. */
#ifdef IP_V6
   if(addrtype == 6)
      inm = v6_lookup_mcast((ip6_addr*)ap, netp);
#endif
#ifdef IP_V4
   if(addrtype != 6)
      inm = lookup_mcast(*ap, netp);
#endif

   if (inm != (struct in_multi *)NULL) 
   {
      /* Found it; just increment the reference count. */
      ++inm->inm_refcount;
   }
   else
   {
      /*
       * New address; allocate a new multicast record
       * and link it into the interface's multicast list.
       */
      inm = (struct in_multi *)INM_ALLOC(sizeof(*inm));

      if (inm == (struct in_multi *)NULL) 
      {
         EXIT_CRIT_SECTION(netp);
         return ((struct in_multi *)NULL);
      }
#ifdef IP_V6
      if(addrtype == 6)
         IP6CPY(&inm->ip6addr, (struct in6_addr *)ap);
#endif
#ifdef IP_V4
      if(addrtype != 6)
         inm->inm_addr = *ap;
#endif
      inm->inm_netp = netp;
      inm->inm_refcount = 1;
      inm->inm_next = netp->mc_list;
      netp->mc_list = inm;

      /*
       * If net has a multicast address registration routine then ask
       * the network driver to update its multicast reception
       * filter appropriately for the new address.
       */
      if(netp->n_mcastlist)
         error = netp->n_mcastlist(inm);
      else
         error = 0;
#if defined (IGMP_V1) || defined (IGMP_V2)
      /*
       * Let IGMP know that we have joined a new IP multicast group.
       */
      if (inm->inm_addr) igmp_joingroup(inm);
#endif      
   }

   EXIT_CRIT_SECTION(netp);
   USE_ARG(error);

   return (inm);
}
Пример #22
0
void   
md_fclose(VFILE * vfd)
{
   USE_ARG(vfd);
}