Print IP adress - Embedded

This is a discussion on Print IP adress - Embedded ; hi all, I am new to blackfin561 in ethernet application I have connected my board(BF561) to my pc in linux environment through the network, I need to get ip adress of my board which is connected to the switch .how ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Print IP adress

  1. Print IP adress

    hi all,

    I am new to blackfin561 in ethernet application I have connected my
    board(BF561) to my pc in linux environment through the network, I need
    to get ip adress of my board which is connected to the switch .how can
    my pc recognise the board and generate the ip adress.Is there any
    function or program are to be used .answers should be appreciated.


    with regards
    ashu...


  2. Re: Print IP adress



    > ashu...


    Gezundheit!

  3. Re: Print IP adress

    On Oct 22, 6:32 am, ashu wrote:
    > hi all,
    >
    > I am new to blackfin561 in ethernet application I have connected my
    > board(BF561) to my pc in linux environment through the network, I need
    > to get ip adress of my board which is connected to the switch .how can
    > my pc recognise the board and generate the ip adress.Is there any
    > function or program are to be used .answers should be appreciated.


    I assume that your setup consists of a switch connected to the
    network with a DHCP server
    somewhere, the Blackfin board and your computer; I also assume that
    Blackfin
    gets its IP settings through DHCP.

    You could run wireshark or tcpdump on your linux box and watch the
    DHCP broadcast traffic to your board when you power it up. You could
    see all traffic if you placed both your computer and the board on a
    simple hub---a useful thing to have, and I keep a couple of old hubs
    around for just this purpose.


  4. Re: Print IP adress

    ashu wrote:

    > I am new to blackfin561 in ethernet application I have connected my
    > board(BF561) to my pc in linux environment through the network, I need
    > to get ip adress of my board which is connected to the switch


    You may either use ifconfig or the following piece of code
    (exchange "eth0" for the device in use):

    --cut--
    #include
    #include
    #include
    #include
    #include

    int main(int argc, char **argv) {

    struct ifreq myifr;
    struct hostent *h;
    int i;
    char *dot;

    sprintf(myifr.ifr_ifrn.ifrn_name,"%s", "eth0");

    /* get IP address and write to nameip */
    ioctl(socket(AF_INET, SOCK_DGRAM, IPPROTO_IP), SIOCGIFADDR, &myifr);

    dot="";
    for(i=0; i<4;i++) {
    printf("%s%d", dot,
    (unsigned char) myifr.ifr_ifru.ifru_addr.sa_data[2+i]);
    dot=".";
    }
    printf("\n");
    return(0);
    }
    --cut--

    A MAC-Address query is very simular

    Sven

    --
    This APT has Super Cow Powers.
    (apt-get --help on debian woody)

    /me is giggls@ircnet, http://sven.gegg.us/ on the Web

+ Reply to Thread