lua-users home
lua-l archive

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


Hello all,

I have used Lua a little bit before, (mostly as a higher level scripting language on some embedded processors.)  I want to learn how to use the language better and so I thought I would try a new project in it, but I'm having trouble, and wondering if some wise soul can point me in the right direction.

 
I want to use Lua to create DNS requests and handle the responses --- basically a simple implementation of nslookup.  I'm working on some protocol stuff, so the ability to change the packet around would be helpful here.  But I can't figure out how I get Lua to create the network packet format I need.  I have "Programming in Lua, 2nd. Edition" and while I find it clear and helpful, I can't find the answer.

Is there a way to create the low level structure I want, (complete with some bit mapped fields?)
    0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                      ID                       |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |QR|   Opcode  |AA|TC|RD|RA|   Z    |   RCODE   |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    QDCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    ANCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    NSCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    ARCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

That thing.  If so, how do I go about it.  Pointing me in the right direction is all I'm looking for, I would like to learn the language myself.

Thanks,
Chris Inaico