home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / comm / amitcp-3.0ß2.lha / AmiTCP / src / util / ifconfig / ifconfig.c next >
C/C++ Source or Header  |  1994-02-24  |  25KB  |  881 lines

  1. static char rcsid[] =
  2.   "$Id: ifconfig.c,v 3.1 1994/02/22 03:28:22 ppessi Exp $";
  3. /*
  4.  * ifconfig.c --- Configure Network Interfaces
  5.  *
  6.  * Author: Pekka Pessi <Pekka.Pessi@hut.fi>
  7.  *
  8.  * Copyright © 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
  9.  *            Helsinki University of Technology, Finland.
  10.  *            All rights reserved.
  11.  *
  12.  * Created      : Sat May 15 04:12:15 1993 ppessi
  13.  * Last modified: Tue Feb 22 01:35:17 1994 ppessi
  14.  */
  15.  
  16. #include "ifconfig_rev.h"
  17. static const char version[] = VERSTAG " "
  18.      "Copyright © 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>\n"
  19.                       "Helsinki University of Technology, Finland.\n"
  20.                       "All rights reserved.\n"
  21. "@(#) Copyright © 1983 The Regents of the University of California.\n"
  22.                       "All rights reserved.\n";
  23.  
  24. /****** netutil.doc/ifconfig ************************************************
  25.  
  26.    NAME
  27.         ifconfig - configure network interface parameters
  28.  
  29.    VERSION
  30.         $Id: ifconfig.c,v 3.1 1994/02/22 03:28:22 ppessi Exp $
  31.  
  32.    SYNOPSIS
  33.         ifconfig interface address_family [address [dest_address]] [params]
  34.         ifconfig interface [address_family]
  35.  
  36.    DESCRIPTION
  37.         ifconfig is used to assign an address to a network interface and/or
  38.         configure network interface parameters.  ifconfig must be used at
  39.         boot time to define the network address of each interface present on
  40.         a machine.  It can also be used at other times to redefine an
  41.         interface's address or other operating parameters.
  42.  
  43.    PARAMETERS
  44.         interface     A string of the interface name concatenated with unit
  45.                       numver, for example `eth0'.  The AmiTCP/IP network
  46.                       interfaces are defined in the `AmiTCP:db/interface'
  47.                       file.  For example, a interface sl corresponds by
  48.                       default to `Devs:networks/rhcslip.device'.
  49.  
  50.         address_family
  51.  
  52.                       Name of protocol on which naming scheme is based.  An
  53.                       interface can receive transmissions in differing
  54.                       protocols, each of which may require separate naming
  55.                       schemes.  Therefore, it is necessary to specify the
  56.                       address_family, which may affect interpretation of the
  57.                       remaining parameters on the command line.  The only
  58.                       address family currently supported is inet (DARPA-
  59.                       Internet family).
  60.  
  61.         address       Either a host name present in the host name database,
  62.                       (SEE hosts), or a DARPA Internet address
  63.                       expressed in Internet standard "dot notation".  The
  64.                       host number can be omitted on 10-Mbyte/second Ethernet
  65.                       interfaces (which use the hardware physical address),
  66.                       and on interfaces other than the first.
  67.  
  68.         dest_address  Address of destination system.  Consists of either a
  69.                       host name present in the host name database, hosts(4),
  70.                       or a DARPA Internet address expressed in Internet
  71.                       standard "dot notation".
  72.  
  73.    SWITCHES
  74.         The following operating parameters can be specified:
  75.  
  76.          up           Mark an interface "up". Enables interface after an
  77.                       "ifconfig down."  Occurs automatically when setting the
  78.                       address on an interface.  Setting this flag has no
  79.                       effect if the hardware is "down".
  80.  
  81.          down         Mark an interface "down".  When an interface is marked
  82.                       "down", the system will not attempt to transmit
  83.                       messages through that interface. If possible, the
  84.                       interface will be reset to disable reception as well.
  85.                       This action does not automatically disable routes
  86.                       using the interface.
  87.  
  88.         arp           Enable the use of Address Resolution Protocol in
  89.                       mapping between network level addresses and link-level
  90.                       addresses (default).
  91.  
  92.         -arp          Disable the use of Address Resolution Protocol.
  93.  
  94.          metric n     Set the routing metric of the interface to n, default
  95.                       0.  The routing metric is used by the routing protocol
  96.                       (see gated).  Higher metrics have the effect of making
  97.                       a route less favorable; metrics are counted as
  98.                       additional hops to the destination network or host.
  99.  
  100.          debug        Enable driver-dependent debugging code. This usually
  101.                       turns on extra console error logging.
  102.  
  103.         -debug        Disable driver-dependent debugging code.
  104.  
  105.          netmask mask (Inet only) Specify how much of the address to reserve
  106.                       for subdividing networks into sub-networks.  mask
  107.                       includes the network part of the local address, and
  108.                       the subnet part which is taken from the host field of
  109.                       the address.  mask can be specified as a single hexa-
  110.                       decimal number with a leading 0x, with a dot-notation
  111.                       Internet address, or with a pseudo-network name listed
  112.                       in the file AmiTCP:db/networks.  `mask' contains 1's
  113.                       for each bit position in the 32-bit address that are
  114.                       to be used for the network and subnet parts, and 0's
  115.                       for the host part.  mask should contain at least the
  116.                       standard network portion, and the subnet field should
  117.                       be contiguous with the network portion.
  118.  
  119.         broadcast    (Inet only) Specify the address that represents
  120.                       broadcasts to the network.  The default broadcast
  121.                       address is the address with a host part of all 1's.
  122.  
  123.         The command:
  124.  
  125.              ifconfig interface/unit
  126.  
  127.         with no optional command arguments supplied displays the current
  128.         configuration for interface.  If address_family is specified,
  129.         ifconfig reports only the details specific to that address family.
  130.  
  131.    DIAGNOSTICS
  132.         Messages indicating that the specified interface does not exist, the
  133.         requested address is unknown, or the user is not privileged and
  134.         tried to alter an interface's configuration.
  135.  
  136.    EXAMPLES
  137.         ifconfig lo0 127.0.0.1
  138.  
  139.                 This command marks internal loopback device "UP", and
  140.                 attach an inet address 127.0.0.1 to it.
  141.  
  142.         ifconfig cslip0 inet 193.102.4.144 193.102.4.129
  143.  
  144.                 This command starts the CSLIP driver, attach an
  145.                 address 193.102.4.144 (our internet address) and a
  146.                 destination address 193.102.4.129 (the internet
  147.                 address of the host you are connecting) to it.
  148.  
  149.         ifconfig eth0 inet 193.124.100.64 netmask 255.255.255.192 -arp
  150.  
  151.                 This command loads an ethernet driver (by default for the
  152.                 Commodore A2065 Ethernet adapter unit 0), marks it "up",
  153.                 disables ARP protocol for it, attaches an inet address
  154.                 193.124.100.65 to it and sets its netmask to
  155.                 255.255.255.192.  A bitwise logical and of netmask and
  156.                 address for the interface forms a subnet address, in this
  157.                 case 193.124.100.64.  All packets aimed to hosts with same
  158.                 subnet address (that is hosts 193.124.100.64 -
  159.                 193.124.100.127) are routed to this interface.
  160.  
  161.    FILES
  162.         AmiTCP:db/interfaces
  163.  
  164.    SEE ALSO
  165.         netstat, hosts, arp, "net/if.h", "net/sana2tags.h"
  166.  
  167. *****************************************************************************
  168. *
  169. */
  170.  
  171. /*
  172.  * Copyright © 1983 Regents of the University of California.
  173.  * All rights reserved.
  174.  *
  175.  * Redistribution and use in source and binary forms, with or without
  176.  * modification, are permitted provided that the following conditions
  177.  * are met:
  178.  * 1. Redistributions of source code must retain the above copyright
  179.  *    notice, this list of c