lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I'm not doing licensing, instead I have multiple embedded devices that
are identical except for the MAC address. I'm trying to identify the
device. The devices are Linux based so I can write some C code to the
MAC address. I was trying to avoid the C code and the corresponding
build/install complications.

    struct ifreq ifinfo;
    strcpy(ifinfo.ifr_name, "eth0");
    int sd = socket(AF_INET, SOCK_DGRAM, 0);
    int result = ioctl(sd, SIOCGIFHWADDR, &ifinfo);

    if ((result == 0) && (ifinfo.ifr_hwaddr.sa_family == 1)) {
        memcpy(mac_addr, ifinfo.ifr_hwaddr.sa_data, IFHWADDRLEN);
        return true;
    return false;

On Sun, Feb 13, 2011 at 9:11 AM, Thomas Harning Jr. <> wrote:
> For license generation, on OSX you have a UUID that is available and
> shouldn't change (if it does somehow, itunes, for example, breaks
> On windows you could abuse CryptProtectData since it is supposed to
> protect data in a permachine manner... You can uniquely identify a
> mach using that.
> For linux... You'd want to determine how to identify a machine... NICs
> can move, hard drives replaced, motherboards replaced,... What
> constitutes a new machine?  Trying to use the windows activation
> "algorithm" of generating an ID that can still be matched if a few
> components change, but rquire reactivation beyond that.
> Universal license management would require a special library to
> support machine identification.  I could probably assist or take on
> such a task if there is a need in the lua community.  Would prbably
> dev in a plain c library than wrap in lua to make it the most useful
> tool.
> On 2/13/11, Leo Razoumov <> wrote:
>> On Sun, Feb 13, 2011 at 05:37, Axel Kittenberger <> wrote:
>>> MAC is someting ethernet specific, not every network interface has to
>>> have one. Correct me if I'm wrong, but why should a PPP-connection
>>> have a mac adress anyway? Its a point-to-point connection, no need to
>>> address something on Layer 2 in the OSI Modell where Mac belongs to.
>>> Also not every computer must have a "default network interface", what
>>> if you are not connected to the internet and thus not have a default
>>> route? Or you are part of the backbone? (unlikely but possible :-)
>>> I wonder what the usecase is that warrents wanting to know "mac of the
>>> default network interface"?
>> I do not think that there is a universal definition of the "default
>> NIC interface" because its meaning depends on interpretation of the
>> word 'default' in this context. For the sake of sending/receiving IP
>> packets it is natural to assume 'default' being associated with a
>> default route.
>> On the other hand, for the sake of unique machine identification (e.g.
>> proprietary license code generation)  you might consider the first
>> Ethernet MAC.  Do 'ifconfig -a' if on UNIX and pick the NIC you like.
>> --Leo--
> --
> Thomas Harning Jr.

Jon Smirl