How to write a C program to obtain the first NIC name ?

How to write a C program to obtain the first NIC name ?

Post by Joe » Sat, 20 May 2000 04:00:00



Hi, every friend:

     How to write a C program to obtain the first NIC name ?

    Some people tell me that I can  obatin  the first NIC name by  using
  shell script to processthe result of  "ifconfig -a" instruction.
  howerver, this is not a good  method. because different OS
  have differnt ifconfig specification.

     Have any  C function call can solve my problem ?  Please give me a C
     program example.

 In gerneral, The first  NIC (Network Interface card)  of RedHat 6.X is
"eth0", but the first NIC name of FreeBSD is always different  in different
PCs .

  In our research, I must write a shell script to use  "ifconfig"
instruction to change  IP address dynamically.  The "ifconfig" instrution
needs the
first NIC name.
   [ex] my computer IP is 1.1.1.1.
          I want to change my compute IP form 1.1.1.1 to 1.1.1.2.
          I can  do the following instrtion:
                #ifconfig eth0 1.1.1.2
                              ^^^
                             the question is how to write a C program to
obtain the first NIC name ?

            Joe  2000/5/19
            National Taiwan University

 
 
 

1. How to write a C program to obtain the first NIC name ?

Hi, every friend:

     How to write a C program to obtain the first NIC name ?

     Some people tell me that I can  obatin  the first NIC name by  using
shell script
      to processthe result of  "ifconfig -a" instruction.  howerver, this is
not a good
     method. because different OS have differnt ifconfig specification.

     Have any  C function call can solve my problem ?  Please give me a C
program
      example.

 In gerneral, The first  NIC (Network Interface card)  of RedHat 6.X is
"eth0", but the first NIC name of FreeBSD is always different  in different
PCs .

  In our research, I must write a shell script to use  "ifconfig"
instruction
to change  IP address dynamically.  The "ifconfig" instrution needs the
first NIC
name.
   [ex] my computer IP is 1.1.1.1.
          I want to change my compute IP form 1.1.1.1 to 1.1.1.2.
          I can  do the following instrtion:
                #ifconfig eth0 1.1.1.2
                              ^^^
                             the question is how to write a C program to
obtain the first NIC name ?

            Joe  2000/5/19
            National Taiwan University

2. 2.5.59{-mm2} with contest

3. How to write a shell script to obtain the first NIC name ?

4. Bringing a background process into the foreground

5. How to write a shell script to obatin first NIC name?

6. strange stack trace

7. apache, day one, hour one, minute one, local write permission !?!?!?!?

8. freebsd cleanup

9. Getting 'named' to listen to one NIC

10. Multiple programs writing to one file

11. How to let a program be the only one with write-permission i a directory

12. Network monitoring programs..how to write one..

13. what is the name of the tar fix program to make one relative?