Revision 376bcba4 mininet/node.py

View differences:

mininet/node.py
6 6
flush = sys.stdout.flush
7 7

  
8 8
from mininet.logging_mod import lg
9
from mininet.util import quietRun
9
from mininet.util import quietRun, macColonHex, ipStr
10 10

  
11 11
class Node(object):
12 12
    '''A virtual network node is simply a shell in a network namespace.
......
160 160
        self.intfs += [intfName]
161 161
        return intfName
162 162

  
163
    def setMAC(self, intf, mac):
164
        '''Set the MAC address for an interface.
165

  
166
        @param mac MAC address as unsigned int
167
        '''
168
        mac_str = macColonHex(mac)
169
        result = self.cmd(['ifconfig', intf, 'down'])
170
        result += self.cmd(['ifconfig', intf, 'hw', 'ether', mac_str])
171
        result += self.cmd(['ifconfig', intf, 'up'])
172
        return result
173

  
174
    def setARP(self, ip, mac):
175
        '''Add an ARP entry.
176

  
177
        @param ip IP address as unsigned int
178
        @param mac MAC address as unsigned int
179
        '''
180
        ip_str = ipStr(ip)
181
        mac_str = macColonHex(mac)
182
        result = self.cmd(['arp', '-s', ip_str, mac_str])
183
        return result
184

  
163 185
    def setIP(self, intf, ip, bits):
164 186
        '''Set the IP address for an interface.
165 187

  

Also available in: Unified diff