0

Here is my code

from pox.lib.addresses import IPAddr
def ip_atoi(st):
"""
function to convert ip address to integer value
"""
  st=st.split(".")
  return int("%02x%02x%02x%02x"%(int(st[0]),int(st[1]),int(st[2]),int(st[3])),16)
  1. when i run this script in pox controller i am getting error saying

    AttributeError: 'IPAddr' object has no attribute 'split'
    
  • Seems straightforward to me. `st` is an `IPAddr` object, and `IPAddr` objects don't have a `split` method, so it crashes when you try to call `split` on an `IPAddr`. – Kevin May 18 '16 at 13:12
  • 1
    There is a method in the IPAddr class `toStr()`. You should call first `st.toStr()` and then split it. line 294 https://github.com/noxrepo/pox/blob/carp/pox/lib/addresses.py – SotirisTsartsaris May 18 '16 at 13:34

1 Answers1

2

The reason is that st is not a string, but an IPAddr object. What you might want to do instead is:

st = str(st).split(".")
kmaork
  • 5,722
  • 2
  • 23
  • 40