endian +linux +x86_64

The endian module provides support functions for converting the byte encoding ("endianness") of integers. The following abbreviations are used throughout the module:

Index

Types

type endian;

Globals

let big: endian;
let host: *endian;
let little: endian;

Functions

fn begetu16([]u8) u16;
fn begetu32([]u8) u32;
fn begetu64([]u8) u64;
fn beputu16([]u8, u16) void;
fn beputu32([]u8, u32) void;
fn beputu64([]u8, u64) void;
fn htonu16(u16) u16;
fn htonu32(u32) u32;
fn htonu64(u64) u64;
fn legetu16([]u8) u16;
fn legetu32([]u8) u32;
fn legetu64([]u8) u64;
fn leputu16([]u8, u16) void;
fn leputu32([]u8, u32) void;
fn leputu64([]u8, u64) void;
fn ntohu16(u16) u16;
fn ntohu32(u32) u32;
fn ntohu64(u64) u64;

Types

type endian[link]

type endian = struct {
	getu16: *fn(buf: []u8) u16,
	putu16: *fn(buf: []u8, in: u16) void,
	getu32: *fn(buf: []u8) u32,
	putu32: *fn(buf: []u8, in: u32) void,
	getu64: *fn(buf: []u8) u64,
	putu64: *fn(buf: []u8, in: u64) void,
};

The set of functions used for endian-aware encoding.

Globals

let big[link]

const big: endian;

Big endian; MSB first.

let host[link]

const host: *endian;

The endian functions which map to the host architecture.

let little[link]

const little: endian;

Little endian; LSB first.

Functions

fn begetu16[link]

fn begetu16(buf: []u8) u16;

Reads a u16 from a buffer in big-endian order.

fn begetu32[link]

fn begetu32(buf: []u8) u32;

Reads a u32 from a buffer in big-endian order.

fn begetu64[link]

fn begetu64(buf: []u8) u64;

Reads a u64 from a buffer in big-endian order.

fn beputu16[link]

fn beputu16(buf: []u8, in: u16) void;

Writes a u16 into a buffer in big-endian order.

fn beputu32[link]

fn beputu32(buf: []u8, in: u32) void;

Writes a u32 into a buffer in big-endian order.

fn beputu64[link]

fn beputu64(buf: []u8, in: u64) void;

Writes a u64 into a buffer in big-endian order.

fn htonu16[link]

fn htonu16(in: u16) u16;

Converts a u16 from host order to network order.

fn htonu32[link]

fn htonu32(in: u32) u32;

Converts a u32 from host order to network order.

fn htonu64[link]

fn htonu64(in: u64) u64;

Converts a u64 from host order to network order.

fn legetu16[link]

fn legetu16(buf: []u8) u16;

Reads a u16 from a buffer in little-endian order.

fn legetu32[link]

fn legetu32(buf: []u8) u32;

Reads a u32 from a buffer in little-endian order.

fn legetu64[link]

fn legetu64(buf: []u8) u64;

Reads a u64 from a buffer in little-endian order.

fn leputu16[link]

fn leputu16(buf: []u8, in: u16) void;

Writes a u16 into a buffer in little-endian order.

fn leputu32[link]

fn leputu32(buf: []u8, in: u32) void;

Writes a u32 into a buffer in little-endian order.

fn leputu64[link]

fn leputu64(buf: []u8, in: u64) void;

Writes a u64 into a buffer in little-endian order.

fn ntohu16[link]

fn ntohu16(in: u16) u16;

Converts a u16 from network order to host order.

fn ntohu32[link]

fn ntohu32(in: u32) u32;

Converts a u32 from network order to host order.

fn ntohu64[link]

fn ntohu64(in: u64) u64;

Converts a u64 from network order to host order.