wuntee
wuntee

Reputation: 12490

Ruby creating binary data from human readable

I am creating a variable that is the payload of an IPv6 packet, and I need to have multiple data formats concatenated to it, and am having some trouble.

Specifically, I have:

64 - unsigned int 1 byte (prefix length)
1100 0000 - binary 1 byte (flags)
86400 - unsigned int, left padded/4 bytes (lifetime)
14400 - unsigned int, left padded/4 bytes (preferred lifetime)
0x00 0x00 0x00 0x00 - reserved/unused 4 bytes

New to ruby - anything will help.

Upvotes: 1

Views: 210

Answers (1)

mu is too short
mu is too short

Reputation: 434985

Are you familiar with pack? That's probably what you'll need to build your packets.

Upvotes: 1

Related Questions