C program : how to list interfaces with a valid IP ?


 
Thread Tools Search this Thread
Top Forums Programming C program : how to list interfaces with a valid IP ?
# 8  
Old 01-16-2008
Quote:
Originally Posted by brolon
Nice function ! That works but I have a problem with the assignment "ifcur = iflist" : error: incompatible types in assignment ?! I don't understand why.

Code:
	
...
struct ifaddrs*		iflist 
,		        ifcur ;
	
if (getifaddrs (&iflist) < 0)
	printf ("* Erreur getifaddrs ! \n") ;

ifcur = iflist ;
	
freeifaddrs(iflist);
...

Your declaration of struct ifaddrs* might be throwing off the compiler when it comes to a struct ifaddrs object and a pointer to that type. The argument to getifaddrs is a pointer to pointer to struct ifaddrs so use &ifcur instead of &iflist and since freeifaddrs takes a unilevel pointer use ifcur.

Code:
...
struct ifaddrs iflist, *ifcur
ifcur = &iflist;

if (getifaddrs (&ifcur) < 0)
	printf ("* Erreur getifaddrs ! \n") ;
	
freeifaddrs(ifcur);
...

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

can't see other interfaces

Hi Guys, I have a Netra240 server with four interfaces. However, when I ran this command dladm show-dev it showed only one interface bge0. Can someone please explain to me how to fix this problem? Thanks guys. (1 Reply)
Discussion started by: cjashu
1 Replies

2. Solaris

Interfaces and Virtual-interfaces queries

Hi Al, In course of understanding networking in Solaris, I have these doubts on Interfaces. Please clarify me. I have done fair research in this site and others but could not be clarified. 1. In the "ifconfig -a" command, I see many interfaces and their configurations. But I see many... (1 Reply)
Discussion started by: satish51392111
1 Replies

3. Shell Programming and Scripting

Selecting files from a list and passing them to a program using csh

I have a list of files, example as shown below n02-z30-dsr65-ndelt0.25-varp0.002-4x3drw-csq.msf n02-z30-dsr65-ndelt0.25-varp0.004-4x3drw-csq.msf n02-z30-dsr65-ndelt0.25-varp0.006-4x3drw-csq.msf n02-z30-dsr65-ndelt0.25-varp0.008-4x3drw-csq.msf... (8 Replies)
Discussion started by: kristinu
8 Replies

4. Ubuntu

How to list my program or package that i compile and installed?

Hi I would like to ask in ubuntu or linux on how to list all my package or software the i installed via source code( compile installed in dir default is /usr/local) just like i solaris in which if you installed a package in ur choosing default root installation dir you can just issue a command... (2 Replies)
Discussion started by: jao_madn
2 Replies

5. Homework & Coursework Questions

Valid Name

Could someone help me by midnight tonight!!! Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Insert a reference to the Bourne shell as the command... (0 Replies)
Discussion started by: cody007
0 Replies

6. Solaris

list of physical net interfaces

hi, Can I listdown all available net interfaces on my system like SF4800 or Netra440. I know there are 4 port physically present but I can't see or list them using either sysdef -v prtconf -vp prtdiag -v dladm kstat may be I'm missing switched on these or may some other command... (8 Replies)
Discussion started by: busyboy
8 Replies

7. UNIX for Advanced & Expert Users

find: 0652-019 The status on /interfaces/eu3/hmsl/EBS/20070722 is not valid.

I am getting this error when i issue find command. Any advice. Regards, Vishal (0 Replies)
Discussion started by: vishal_ranjan
0 Replies

8. Programming

valid code?

hey , everyone. I have a few questions about pieces of code and was wondering if someone could tell me what exactly they did or if they are even valid. bool1 && bool2 || bool3 <---in what order do these get processed? if (! isdigit(c)) <---What does this do? i = j % 3; <---what does this do?... (4 Replies)
Discussion started by: bebop1111116
4 Replies

9. UNIX for Dummies Questions & Answers

interfaces

Hello, which network interface i must sellect during the solaris9 installation le0 or hme0 ? this system is part of the network, it is a standalone system and is not on any domain. thanks for your help, em (1 Reply)
Discussion started by: emsakopa
1 Replies
Login or Register to Ask a Question