Changeset 2b35261 for fedkit/gateway_lib.pm
- Timestamp:
- Feb 1, 2010 10:43:24 AM (14 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- b73cc45
- Parents:
- 2edec46
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedkit/gateway_lib.pm
r2edec46 r2b35261 3 3 package gateway_lib; 4 4 5 # Package stuff to keep the caller's namespace clean, but allow additions if 6 # they need it. 5 7 require Exporter; 6 8 @ISA=qw(Exporter); … … 17 19 use File::Copy; 18 20 21 # Standard locations of these commands (FreeBSD) 19 22 my $IFCONFIG = "/sbin/ifconfig"; 20 23 my $ROUTE = "/sbin/route"; … … 22 25 my $FINDIF = "/usr/local/etc/emulab/findif"; 23 26 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. 24 29 sub set_sshd_params { 25 30 my($keys, $file) = @_; … … 44 49 } 45 50 51 # Append the given keyfile to the given authorised key file. 46 52 sub import_key { 47 53 my($keyfile, $authkeys) = @_; … … 57 63 } 58 64 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). 60 68 sub wait_for_DNS { 61 my($name, $timeout ) = @_;69 my($name, $timeout, $sleep) = @_; 62 70 my $start = time(); 71 $sleep = 5 unless $sleep; 63 72 my @rv; 64 73 … … 67 76 die "Timeout waiting for DNS to get $name\n" 68 77 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. 72 85 sub deter_tunnelip { 73 86 # To parse tmcc … … 80 93 81 94 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. 83 97 $tmcc->reader("$TMCC tunnelip"); 84 98 while (<$tmcc>) { … … 101 115 } 102 116 117 118 # Configure the given interface with the given IP address and netmask. 103 119 sub configure_outgoing_iface { 104 my ($interface, $ip, $netmask , $mac) = @_;120 my ($interface, $ip, $netmask) = @_; 105 121 106 122 my @ifconfig = ($IFCONFIG, $interface, $ip); … … 111 127 } 112 128 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. 113 132 sub add_route { 114 133 my($routedest, $router, $wait, $timeout) = @_; … … 138 157 } 139 158 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. 140 163 sub bind_tap_to_iface { 141 164 my($tapno, $iface) = @_; … … 163 186 } 164 187 188 # Return the IP addresses accociated with this interface (as a list) 165 189 sub iface_to_addr { 166 190 my($iface) = @_; … … 176 200 } 177 201 202 # Return the interface that packets to this host (IP or DNS) would be sent on. 178 203 sub dest_to_iface { 179 204 my($dest) =@_; … … 193 218 } 194 219 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. 195 222 sub addr_to_iface { 196 223 my($addr) = @_;
Note: See TracChangeset
for help on using the changeset viewer.