Sponsored Content
Top Forums Programming C program : how to list interfaces with a valid IP ? Post 302158687 by brolon on Wednesday 16th of January 2008 05:05:56 AM
Old 01-16-2008
Quote:
Originally Posted by cbkihong
Having an IP address does not mean the routing is good enough to be able to send or receive anything over the interface.

I have been able to do so with getifaddrs() on Linux. Not sure other Unix flavours. Go search for manpage for that function.
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);
...

 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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. 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

7. 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

8. 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

9. 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
ifup(8) 																   ifup(8)

NAME
ifup - bring a network interface up ifdown - take a network interface down SYNOPSIS
ifup [-nv] [--no-act] [--verbose] [-i FILE|--interfaces=FILE] [--allow CLASS] -a|IFACE... ifup -h|--help ifup -V|--version ifdown [-nv] [--no-act] [--verbose] [-i FILE|--interfaces=FILE] [--allow CLASS] -a|IFACE... DESCRIPTION
The ifup and ifdown commands may be used to configure (or, respectively, deconfigure) network interfaces based on interface definitions in the file /etc/network/interfaces. OPTIONS
A summary of options is included below. -a, --all If given to ifup, affect all interfaces marked auto. Interfaces are brought up in the order in which they are defined in /etc/net- work/interfaces. If given to ifdown, affect all defined interfaces. Interfaces are brought down in the order in which they are currently listed in the state file. Only interfaces defined in /etc/network/interfaces will be brought down. --force Force configuration or deconfiguration of the interface. -h, --help Show summary of options. --allow=CLASS Only allow interfaces listed in an allow-CLASS line in /etc/network/interfaces to be acted upon. -i FILE, --interfaces=FILE Read interface definitions from FILE instead of from /etc/network/interfaces. -e PATTERN, --exclude=PATTERN Exclude interfaces from the list of interfaces to operate on by the PATTERN. Notice that the PATTERN can be a full interface name or substrings that match interfaces. Users could easily have unexpected behaviour if they use a small string to do the match. -n, --no-act Don't configure any interfaces or run any "up" or "down" commands. --no-mappings Don't run any mappings. See interfaces(5) for more information about the mapping feature. -V, --version Show copyright and version information. -v, --verbose Show commands as they are executed. EXAMPLES
ifup -a Bring up all the interfaces defined with auto in /etc/network/interfaces ifup eth0 Bring up interface eth0 ifup eth0=home Bring up interface eth0 as logical interface home ifdown -a Bring down all interfaces that are currently up. NOTES
ifup and ifdown are actually the same program called by different names. The program does not configure network interfaces directly; it runs low level utilities such as ip to do its dirty work. FILES
/etc/network/interfaces definitions of network interfaces See interfaces(5) for more information. /var/run/network/ifstate current state of network interfaces KNOWN BUGS
/LIMITATIONS The program keeps records of whether network interfaces are up or down. Under exceptional circumstances these records can become inconsis- tent with the real states of the interfaces. For example, an interface that was brought up using ifup and later deconfigured using ifcon- fig will still be recorded as up. To fix this you can use the --force option to force ifup or ifdown to run configuration or deconfigura- tion commands despite what it considers the current state of the interface to be. The file /var/run/network/ifstate must be writable for ifup or ifdown to work properly. On Ubuntu the /var/run location is a temporary filesystem which is always writable and thrown away on shutdown. You can also use the --force option to run configuration or deconfigura- tion commands without updating the file. Note that the program does not run automatically: ifup alone does not bring up interfaces that appear as a result of hardware being installed and ifdown alone does not bring down interfaces that disappear as a result of hardware being removed. To automate the configura- tion of network interfaces you need to install other packages such as hotplug(8) or ifplugd(8). AUTHOR
The ifupdown suite was written by Anthony Towns <aj@azure.humbug.org.au>. SEE ALSO
interfaces(5), ip(8), ifconfig(8). IFUPDOWN
22 May 2004 ifup(8)
All times are GMT -4. The time now is 10:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy