Ignore:
Timestamp:
Feb 1, 2010 10:43:24 AM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
b73cc45
Parents:
2edec46
Message:

Initial docs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedkit/gateway_lib.pm

    r2edec46 r2b35261  
    33package gateway_lib;
    44
     5# Package stuff to keep the caller's namespace clean, but allow additions if
     6# they need it.
    57require Exporter;
    68@ISA=qw(Exporter);
     
    1719use File::Copy;
    1820
     21# Standard locations of these commands (FreeBSD)
    1922my $IFCONFIG = "/sbin/ifconfig";
    2023my $ROUTE = "/sbin/route";
     
    2225my $FINDIF = "/usr/local/etc/emulab/findif";
    2326
     27# Takes an ssh config file and a reference to a hash of keys whose values must
     28# be set a specific way.  Replaces existing entries with the set values.
    2429sub set_sshd_params {
    2530    my($keys, $file) = @_;
     
    4449}
    4550
     51# Append the given keyfile to the given authorised key file.
    4652sub import_key {
    4753    my($keyfile, $authkeys) = @_;
     
    5763}
    5864
    59 
     65# Keep trying to look up the given hostname until successful.  If timeout is
     66# given, die after waiting that long.  If sleep is given, wait that many
     67# seconds between attempts (defaults to 5). 
    6068sub wait_for_DNS {
    61     my($name, $timeout) = @_;
     69    my($name, $timeout, $sleep) = @_;
    6270    my $start = time();
     71    $sleep = 5 unless $sleep;
    6372    my @rv;
    6473
     
    6776        die "Timeout waiting for DNS to get $name\n"
    6877            if ($timeout && time() - $start > $timeout);
    69     }
    70 }
    71 
     78        sleep($sleep) unless @rv;
     79    }
     80}
     81
     82# Get the external access parameters (interface, address, netmask, mac address,
     83# and next hop router) from tmcd in Emulabs that support the DETER tunnelip
     84# extension.
    7285sub deter_tunnelip {
    7386    # To parse tmcc
     
    8093
    8194
    82     # Parse out the info about tunnelips
     95    # Parse out the info about tunnelips.  Format is usually one line of
     96    # ATTR=VALUE.  Multiple lines are possible.
    8397    $tmcc->reader("$TMCC tunnelip");
    8498    while (<$tmcc>) {
     
    101115}
    102116
     117
     118# Configure the given interface with the given IP address and netmask.
    103119sub configure_outgoing_iface {
    104     my ($interface, $ip, $netmask, $mac) = @_;
     120    my ($interface, $ip, $netmask) = @_;
    105121
    106122    my @ifconfig = ($IFCONFIG, $interface, $ip);
     
    111127}
    112128
     129# Add a route to the destination through the router.  If wait is given, do not
     130# attempt to add the route until DNS has the hostname in it.  If timeout is
     131# given, only wait that many seconds for DNS to acquire it.
    113132sub add_route {
    114133    my($routedest, $router, $wait, $timeout) = @_;
     
    138157}
    139158
     159# Connect the tap($tapno) interface to $iface at the link level.  Remove any IP
     160# addresses assigned to interface to avoid confusing the routing system.  We're
     161# very tolerant of errors as the bridge and other interfaces may already exist
     162# when this is called.
    140163sub bind_tap_to_iface {
    141164    my($tapno, $iface) = @_;
     
    163186}
    164187
     188# Return the IP addresses accociated with this interface (as a list)
    165189sub iface_to_addr {
    166190    my($iface) = @_;
     
    176200}
    177201
     202# Return the interface that packets to this host (IP or DNS) would be sent on.
    178203sub dest_to_iface {
    179204    my($dest) =@_;
     
    193218}
    194219
     220# Return the interface bound to this IP address.  If there are more than one,
     221# the first one returned by ifconfig is the one returned.
    195222sub addr_to_iface {
    196223    my($addr) = @_;
Note: See TracChangeset for help on using the changeset viewer.