473,797 Members | 3,144 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Find Interface name

hi all,
i trying to find the intferface name using this coding ,but that is
not working ,,,if anybody this pervious..pleas e help to find the
interface name using Linux C.

//CODE
ioctl(sd, SIOCGIFNAME, &ifr);
strncpy(ifname, ifr.ifr_name,IF NAMSIZ);
printf("Interfa ce name :%s\n",ifname);

//
thanks all

Nov 15 '05 #1
4 3617
chellappa wrote:
hi all,
i trying to find the intferface name using this coding ,but that is
not working ,,,if anybody this pervious..pleas e help to find the
interface name using Linux C.

//CODE
ioctl(sd, SIOCGIFNAME, &ifr);
strncpy(ifname, ifr.ifr_name,IF NAMSIZ);
printf("Interfa ce name :%s\n",ifname);


In Standard C, an `int' is guaranteed to be able
to count as high as 32767. Some implementations use
a wider `int', but 32767 is the maximum you can be
absolutely sure of.

If one were to write a program to count the number
of times Chellappa has been told that Standard C has
no networking facilities, the number of times he has
been told to take his networking questions to newsgroups
where networking experts hang out, the number of times
he has been given the names of those newsgroups, and the
number of times he has utterly failed to get the message,
would it be wise to use a mere `int' for the counter?

--
Eric Sosman
es*****@acm-dot-org.invalid
Nov 15 '05 #2
Eric Sosman wrote:
chellappa wrote:
hi all,
i trying to find the intferface name using this coding ,but that is
not working ,,,if anybody this pervious..pleas e help to find the
interface name using Linux C.

//CODE
ioctl(sd, SIOCGIFNAME, &ifr);
strncpy(ifname, ifr.ifr_name,IF NAMSIZ);
printf("Interfa ce name :%s\n",ifname);

In Standard C, an `int' is guaranteed to be able
to count as high as 32767. Some implementations use
a wider `int', but 32767 is the maximum you can be
absolutely sure of.

If one were to write a program to count the number
of times Chellappa has been told that Standard C has
no networking facilities, the number of times he has
been told to take his networking questions to newsgroups
where networking experts hang out, the number of times
he has been given the names of those newsgroups, and the
number of times he has utterly failed to get the message,
would it be wise to use a mere `int' for the counter?


I'd put bets on at least an unsigned long, preferably an unsigned long
long if the implementation supports it.

Joe
Nov 15 '05 #3
Hi,

I don't know about SIOCGIFNAME, but I assume that what you want is
to call ioctl(sd, SIOCGIFCONF, &ifconf) to obtain all the network
interfaces on your system.

Regards,
Ang Way Chuang

Nov 15 '05 #4
In addition, you may also want to look into these 2 functions:

char *if_indextoname (unsigned ifindex, char *ifname);
struct if_nameindex *if_nameindex(v oid);

http://www.opengroup.org/onlinepubs/...dextoname.html
http://www.opengroup.org/onlinepubs/...nameindex.html

I think you should download Single Unix Specification version 3 from
www.opengroup.org if you plan to program in Unix. Hope this answer your
question.

Regards,
Ang Way Chuang

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
2808
by: Steve W. | last post by:
I just read the section (and did the exercise) in the C# Step by Step book that covers Explict Interface Implementation (where you specify in the method implementation the specific interface that you are implementing in the class. Other than to resolve the problem that arises when a class implements two interfaces with the same method signature, what good is it?
5
10378
by: LS | last post by:
Can a WebMethod return an Interface type? Can we pass an interface parameter ? Example : public interface IEntity { long Id { get; set; } string Name { get; set; } }
6
1595
by: jason | last post by:
I found the below example online, while trying to under Interfaces. In layman's terms, can somebody explain what the purpose of this line is: void SportCharacteristics(); //LOCATED IN THE Iball interface. ... I read its a method without an implemetnation.. like an abstract I think.. so how does it serve this project?
5
2312
by: SunnyDrake | last post by:
HI! I wrting some program part of it is XML config parser which contains some commands(for flexibility of engenie). how do i more simple(if it possible not via System.Reflection or System.CodeDom.CodeCastExpression) __problem typecast #1 Desc:i do needed checks but data/commands in XML is dynamic and i don't wanna fix C# code again and again... Sample:foreach (object some in somearray) (some.GetType())some.someaction();
1
4932
by: Shiva48 | last post by:
Thanks to Gannon11 and ro351988- Moderator. I give below the complete Java file and pls help me to rectify the errors. package com.wrox.proj2ee.ch10.app; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import com.wrox.proj2ee.ch12.*// The requesthandlers interface in this package. public class ShowRecordRequesthandler implements RequestHandler
5
1590
by: Random | last post by:
How can I use reflection (or some other method) to find the type of an object that has been passed in to my method under an interface definition? I try to use GetType, but that won't work.
15
2811
by: Xah Lee | last post by:
On Java's Interface Xah Lee, 20050223 In Java the language, there's this a keyword “interface”. In a functional language, a function can be specified by its name and parameter specs. For example: f(3) f(3, )
3
2798
by: =?Utf-8?B?R3JlZyBN?= | last post by:
Hello, I'm running an asp.net, intranet web application using .net framework 1.1 on IIS5.1 / 6.0. Through the web application, I would like to press a button on the web page, have another window (not web-based or part of current application) brought to the front and focused (findwindow api) and have the button scrape the contents of the focused window so the contents can be parsed and entered into the web application. Ideally, I would...
1
5516
by: Fredo | last post by:
I'm getting the following error when I'm running my application (application name changed for the example): Unhandled Exception: System.TypeLoadException: Method get_ImageFile in type MyApp.Plugin.DefaultImageFiles.JPEGImage from assembly MyApp.Plugin.DefaultImageFiles, Version=1.0.2934.26057, Culture=neutral, PublicKeyToken=null does not have an implementation. My application is plugin-based. The class in question does have an...
0
10469
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10209
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9066
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7560
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3750
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2934
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.