Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    How to Send Mac Address From Client to Server

    Hii everyone. My name is Lieyza. I'm a master student, and i have one task to be finish. Now, I need a help on my C programming coding. I have to send the Mac Address of the Client to the Server. I already do the socket programming but there is still a problem to show up the Mac Add at the Server. Here is my coding to get the Mac Address at the Client Side:


    int sd, i;
    float a_macadd1, a_macadd2, a_macadd3, a_macadd4, a_macadd5, a_macadd6;
    struct ifreq ir;

    sd=socket(PF_INET, SOCK_STREAM, 0);
    memset(&ir, 0, sizeof(ir));

    strcpy(ir.ifr_name, "wlan0");
    ioctl(sd, SIOCGIFHADDR, &ir);

    printf ( "The Mac Address is = %02d : %02d : %02d : %02d : %02d : %02d : %02d \n", ir.ifr_hwaddr.sa_data[0],

    printf ( " Want to send = %02d : %02d : %02d : %02d : %02d : %02d : %02d \n, a_macadd1, a_macadd2, a_macadd3, a_macadd4, a_macadd5, a_macadd6);


    Then, when i run it at terminal (Client Side) the answer show is like this:

    The Mac Address is 00 : 19 : 02 : 11 : 52 : 34
    Want to send 00 : 00 : 00 1077084160 : 00 : 1073741824

    Then, the programming to show the Mac Add of the Client at the Server is like this :


    float a_macadd1, a_macadd2, a_macadd3, a_macadd4, a_macadd5, a_macadd6;

    printf (" The Mac Address of the Client is %02d : %02d : %02d : %02d : %02d : %02d : %02d \n, a_macadd1, a_macadd2, a_macadd3, a_macadd4, a_macadd5, a_macadd6);


    and at the terminal, the answer show like this :

    The Mac Address of the Client is 00 : -1090542844 : -2147483648 : -1090551438 : -2147483648 : -1074489359

    why this happend? and when i run it again, it give a different answer like this :

    The Mac Address of the Client is 00 : -1090582268 : -2147483648 : -10906518628 : -2147483648 : -1074489171

    WHY? can anybody help me? how to write a coding using C programming to send the Mac address of the client to the server? i'm really need a help.. please help me.......


  2. #2
    My question to you is: Why?

    MAC addresses are already delivered at the network layer in the stack, and are not always the MAC address of the actual client or server. When packets are crossing boundaries through routers, the MAC address of the router will be inserted in place of the MAC of the actual machine.

    If you can explain why you're trying to do this, you're likely to have more of a chance getting help.

  3. #3

    why i need to know bcoz..

    I need to know.. which client are sending the data to the server.. that is why i need to know the MAC address of the client. Because, there are many clients sending data to the server at one time.. but, i have to know.. from which the server are prosessing at that time. And, i need to transfer the a session to other clients so i need to play around at the MAC address. Example if the mac address is XX:XX:XX:XX:XX:XX then.. the session will transfer to client that have mac address YY:YY:YY:YY:YY:YY

  4. $spacer_open
  5. #4
    What you describe is already accounted for...

    The IP Address and source port of the machine is a unique identifier for each client out there, and for each session established to the server. Once the connection has been established, it is customary to generate a unique session ID within the server-side of the application for tracking of the specific session.

    Attempting to even acquire the MAC address from the client may be a violation of local security policy on the machine and may prohibit your application from working. In addition, you could inadvertently cause communications problems between the server and the client if the MAC address of your client is not the actual MAC address being used at the network level (and very often times, there is a REASON for them to be different).

    Based on your very limited description, and your use of the notion "because I need to", I would suggest you look at alternative means to accomplish what you need to do to ensure that your programming needs will be while maintaining the integrity of the environment overall.

  6. #5

    Alternative means to accomplish sending mac addr to server

    meburdick suggested looking at alternative means to accomplish what Lieyza197 was trying to do.

    I wonder what alternative means I could look into since I am trying to do somethign similar to what Lieyza197 was trying to do.

    I am trying to make sure that a person asking to view my website is coming from a PC that has been "authorized". And the method i was going to consider what that the PC would first have to tell me its MAC address, then my server would consider it approved and in the future only approved PC could access my site. This would also allow my to know which approved PCs are accessing the site. The PCs (client) would "opt in", that is, they would initiate this authorization process, and they would always be initiating the "session. The owner of the PC would be aware of and agree to what ever it took to make this happen.

    Any suggestions?

  7. #6
    It sounds to me like you could possibly leverage cookies, or something like PKI. A lot of it depends on what kind of application you're building, whether there's user intervention, and what kinds of security requirements do you have for the client machine (which is very often determined by the "rules" of the entity owning the machine - home users are usually fairly lax while corporations are often very strict).

    You could pass code to the end station, execute it to generate a private key / public key pair, have private key / public key pieces on the server running the application, and use them to ship information back and forth to determine that the machines are who they say they are. You could also use client and server certificates.

    In general, my counsel is to do three things:

    1) Truly understand the "problem" so that you can focus on addressing it. Clearly identify the needs of your application.

    2) Don't re-invent the wheel unless you have to. If you can leverage existing technologies, especially if they are no-cost, do so.

    3) Don't "break the rules". If you find yourself having to create your own code to do something, don't do it in such a way that is way over-engineered or violates best practices.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts