bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PPP port: Code for setting gateway


From: Daniel E Baumann
Subject: PPP port: Code for setting gateway
Date: Sat, 25 Nov 2000 01:50:37 -0600

Here is the code I wrote for setting the gateway in bundle.c, I welcome any 
comments. Some of this I borrowed from fsysopts.c.

int
bundle_SetRoute(struct bundle *bundle, int cmd, struct in_addr dst,
                struct in_addr gateway, struct in_addr mask, int bang, 
                int ssh)
{
#ifdef __GNU__
  int result = 1;
  error_t err;
 
  /* The file we use as a handle to get FSYS.  */
  char *node_name;
  file_t node;
 
  /* The filesystem we're passing options to.  */
  fsys_t fsys;
  char *opt = strcat("--gateway=", inet_ntoa(gateway));
 
  sprintf(node_name, "%s/%d", _SERVERS_SOCKET, PF_INET);
  node = file_name_lookup (node_name, 0, 0666);
  if (node == MACH_PORT_NULL)
  {
    log_Printf(LogERROR, "HURD: Can't open port to pfinet server, 
file_name_lookup
                failed with %s.\n", strerror(errno));
    error (1, errno, "%s", node_name);
  }
 
   /* Get the filesystem for NODE.  */
  err = file_getcontrol (node, &fsys);
  if (err)
  {
    log_Printf(LogERROR, "HURD: Can't get the filesystem for node %s.", 
node_name);
    error (2, err, "%s", node_name);
  }
 
  err = fsys_set_options (fsys, opt, 1, 1);
  if (err)
  {
    log_Printf(LogERROR, "HURD: Failed to set option %s for node %s.", opt, 
node_name);
    error(5, err, "%s: %s", node_name, opt);
  }
 
  log_Printf(LogDEBUG, "HURD: The pfinet server's gateway is set to %x\n",
              (unsigned)gateway.s_addr);
 
  return result;
 
#else
...
                   
Dan
----------------------------------------------------------------------------
Daniel E. Baumann
E-mail: baumannd@msoe.edu (preferred)
        baumannd@users.sourceforge.net
        baumannd@penguinpowered.com
        baumannd@obfuscation.penguinpowered.com (caution: dynamic DNS)

Web location:   http://www.msoe.edu/~baumannd
                http://www.linuxfreak.com/~baumannd

"Life would be so much easier if we could just look at the source code." 

      -- Dave Olson

"...that as we enjoy great advantages from the inventions of others, we should
be glad of an opportunity to serve others by an invention of ours, and this we
should do freely and generously..."

     -- Benjamin Franklin
---------------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]