I'm not sure that I understand the question. What IP do you want to get? The one your computer is assigned, the IP address of the DHCP server, ...?
Are you trying to grab packets and extract some piece of data from them? If so, you're doing something a little more advanced than belongs in this forum and I would suggest going to the linux networking or linux software forums (which one depends on what you're doing).