@conf.commands.register
def sr1(x, promisc=None, filter=None, iface=None, nofilter=0, *args, **kargs):
 if (not kargs.has_key('timeout')):
  kargs['timeout'] = (-1)
 s = conf.L3socket(promisc=promisc, filter=filter, nofilter=nofilter, iface=iface)
 (a, b) = sndrcv(s, x, *args, **kargs)
 s.close()
 if (len(a) > 0):
  return a[0][1]
 else:
  return None

@ conf . commands . register def sr1 ( x , promisc = None , filter = None , iface = None , nofilter = 0 , * args , ** kargs ) : if ( not kargs . has_key ( 'timeout' ) ) : kargs [ 'timeout' ] = ( - 1 ) s = conf . L3socket ( promisc = promisc , filter = filter , nofilter = nofilter , iface = iface ) ( a , b ) = sndrcv ( s , x , * args , ** kargs ) s . close ( ) if ( len ( a ) > 0 ) : return a [ 0 ] [ 1 ] else : return None
send packets at layer 3 and return only the first answer nofilter: put 1 to avoid use of bpf filters retry: if positive .