Networking Forums

Networking Forums > Computer Networking > Linux Networking > how to get mac address of my system

Reply
Thread Tools Display Modes

how to get mac address of my system

 
 
RajaSekhar.Kavuri
Guest
Posts: n/a

 
      04-07-2005, 12:54 PM
hai,

can any one tell me or give me the source code to get the
mac address of my linux machine without using the ifconfig command . i
need it to be done by c programming.

Thanking you,
K.Rajasekhar

 
Reply With Quote
 
 
 
 
peter smith
Guest
Posts: n/a

 
      04-08-2005, 12:13 AM
RajaSekhar.Kavuri wrote:

> can any one tell me or give me the source code to get the
> mac address of my linux machine without using the ifconfig command . i
> need it to be done by c programming.


SIOCGIFHWADDR is the ioctl request you're after. You could have a look at
this code: http://pont.net/socket/prog/getMAC.c ... but it's rather out of
date.

Pete
--
"Linux Network Security", the ultimate book on protecting your network from
intruders. http://www.charlesriver.com/Books
BookDetail.aspx?productID=99214
 
Reply With Quote
 
Clive Dove
Guest
Posts: n/a

 
      04-08-2005, 07:48 AM
peter smith wrote:

> RajaSekhar.Kavuri wrote:
>
>> can any one tell me or give me the source code to get the
>> mac address of my linux machine without using the ifconfig command .
>> i need it to be done by c programming.

>
> SIOCGIFHWADDR is the ioctl request you're after. You could have a look
> at this code: http://pont.net/socket/prog/getMAC.c ... but it's rather
> out of date.
>
> Pete


When your teacher sets these homework assignments, the idea is that you
should do your own research and not ask us to do your homework for you.

--
Clive

 
Reply With Quote
 
Jim
Guest
Posts: n/a

 
      04-08-2005, 02:47 PM
Clive Dove wrote:
>
> peter smith wrote:
>
> > RajaSekhar.Kavuri wrote:
> >
> >> can any one tell me or give me the source code to get
> >> the
> >> mac address of my linux machine without using the ifconfig command
> >> . i need it to be done by c programming.

> >
> > SIOCGIFHWADDR is the ioctl request you're after. You could have a
> > look at this code: http://pont.net/socket/prog/getMAC.c ... but
> > it's rather out of date.
> >
> > Pete

>
> When your teacher sets these homework assignments, the idea is that
> you should do your own research and not ask us to do your homework
> for you.
>


I'd have said that asking someone is a starting point for research.

 
Reply With Quote
 
Keith Keller
Guest
Posts: n/a

 
      04-08-2005, 07:32 PM
On 2005-04-08, Jim <(E-Mail Removed)> wrote:
> Clive Dove wrote:
>>
>> > RajaSekhar.Kavuri wrote:
>> >
>> >> can any one tell me or give me the source code to get
>> >> the
>> >> mac address of my linux machine without using the ifconfig command
>> >> . i need it to be done by c programming.

>>
>> When your teacher sets these homework assignments, the idea is that
>> you should do your own research and not ask us to do your homework
>> for you.

>
> I'd have said that asking someone is a starting point for research.


I'd have said that asking for source code is asking people to do his
homework for him. If he'd asked "where is this sort of thing
documented" then it'd have been a starting point for research.

--keith

--
kkeller-(E-Mail Removed)
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
see X- headers for PGP signature information

 
Reply With Quote
 
Tauno Voipio
Guest
Posts: n/a

 
      04-08-2005, 09:01 PM
Keith Keller wrote:
> On 2005-04-08, Jim <(E-Mail Removed)> wrote:
>
>>Clive Dove wrote:
>>
>>>>RajaSekhar.Kavuri wrote:
>>>>
>>>>
>>>>> can any one tell me or give me the source code to get
>>>>> the
>>>>>mac address of my linux machine without using the ifconfig command
>>>>>. i need it to be done by c programming.
>>>
>>>When your teacher sets these homework assignments, the idea is that
>>>you should do your own research and not ask us to do your homework
>>>for you.

>>
>>I'd have said that asking someone is a starting point for research.

>
>
> I'd have said that asking for source code is asking people to do his
> homework for him. If he'd asked "where is this sort of thing
> documented" then it'd have been a starting point for research.
>


.... and the answer to that is:

W. Richard Stevens, UNIX Network Programming.

--

Tauno Voipio
tauno voipio (at) iki fi


 
Reply With Quote
 
Raqueeb Hassan
Guest
Posts: n/a

 
      04-11-2005, 01:27 AM
> I'd have said that asking someone is a starting point for research.

Yes, Tauno Voipio is right. To be more precise, it has two volumes ....

1. UNIX Network Programming, Volume 1, Second Edition: Networking APIs:
Sockets and XTI, Prentice Hall, 1998.
2. UNIX Network Programming, Volume 2, Second Edition: Interprocess
Communications, Prentice Hall, 1999.

And you might look inside the source code of ifconfig.c ....
http://darwinsource.opendarwin.org/1...roj/ifconfig.c

Raqueeb Hassan
Bangladesh

 
Reply With Quote
 
Floyd L. Davidson
Guest
Posts: n/a

 
      04-11-2005, 05:02 AM
"Raqueeb Hassan" <(E-Mail Removed)> wrote:
>> I'd have said that asking someone is a starting point for research.

>
>Yes, Tauno Voipio is right. To be more precise, it has two volumes ....
>
>1. UNIX Network Programming, Volume 1, Second Edition: Networking APIs:
>Sockets and XTI, Prentice Hall, 1998.
>2. UNIX Network Programming, Volume 2, Second Edition: Interprocess
>Communications, Prentice Hall, 1999.
>
>And you might look inside the source code of ifconfig.c ....
>http://darwinsource.opendarwin.org/1...roj/ifconfig.c
>
>Raqueeb Hassan
>Bangladesh


yeah sure.

I *do* remember the first time I wanted the answer to that
question myself. I looked in all the right places... and
ifconfig uses the netkit library, which is far too convoluted
even for someone who is well practiced at tracing code. It just
is *not* a timely way to learn that particular item.

The answer is in fact in Stevens books (actually, without
looking to see, I'd bet it's only in Volume 1), and isn't too
horribly obscured. It still takes some doing to unravel if I
remember right, but of course the person needs *have* Stevens
available. (Granted that everyone who is going to learn *any*
part of unix programming _should_ obtain all of Stevens' books,
but...)

I have *no* problem with posting (over and over again) that
short demo program which does just about nothing other than show
how to acquire information (MAC addresses and other data) about
configured interfaces. For someone learning network
programming, it presents the entire set of requirements as one
bundle. And for someone who is doing homework, there is *no*
way they can copy that snippet directly into a homework project
*without* having to figure out what it does first.

The process of trying to make use of the example code in some
other program is going to be a fabulous learning experiece. And
isn't that exactly what tutorials are for???

--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) (E-Mail Removed)
 
Reply With Quote
 
Raqueeb Hassan
Guest
Posts: n/a

 
      04-11-2005, 12:46 PM
<snip>

> but of course the person needs *have* Stevens
> available. (Granted that everyone who is going to learn *any*
> part of unix programming _should_ obtain all of Stevens' books,
> but...)



You see, when I started to code some sort of socket programming, I
could no longer see without these books of Stevens. I know for sure
there's loads of thing on the net, but, sometimes real thing doesn't
come free! Mr. Floyd, yes, I'll have a copy of your program. Thanks for
the demo code.


--
Raqueeb Hassan
Bangladesh

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cases where the system can not assign the IP address to match the MAC address. cp Windows Networking 2 11-21-2006 07:22 AM
system does not renew ip address david Broadband Hardware 1 07-18-2006 03:31 AM
MASQ system not pinging outside address lekkie.aydot@gmail.com Linux Networking 0 05-18-2005 10:43 AM
how to get mac address of my system RajaSekhar.Kavuri Linux Networking 1 04-07-2005 02:23 PM
how to get mac address of my system RajaSekhar.Kavuri Linux Networking 0 04-07-2005 12:43 PM



1 2 3 4 5 6 7 8 9 10 11