asn1_enc.c File Reference


Functions

void snmp_asn1_enc_length_cnt (u16_t length, u8_t *octets_needed)
void snmp_asn1_enc_u32t_cnt (u32_t value, u16_t *octets_needed)
void snmp_asn1_enc_s32t_cnt (s32_t value, u16_t *octets_needed)
void snmp_asn1_enc_oid_cnt (u8_t ident_len, s32_t *ident, u16_t *octets_needed)
err_t snmp_asn1_enc_type (struct pbuf *p, u16_t ofs, u8_t type)
err_t snmp_asn1_enc_length (struct pbuf *p, u16_t ofs, u16_t length)
err_t snmp_asn1_enc_u32t (struct pbuf *p, u16_t ofs, u8_t octets_needed, u32_t value)
err_t snmp_asn1_enc_s32t (struct pbuf *p, u16_t ofs, u8_t octets_needed, s32_t value)
err_t snmp_asn1_enc_oid (struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident)
err_t snmp_asn1_enc_raw (struct pbuf *p, u16_t ofs, u8_t raw_len, u8_t *raw)

Detailed Description

Abstract Syntax Notation One (ISO 8824, 8825) encoding

Todo:
not optimised (yet), favor correctness over speed, favor speed over size

Function Documentation

err_t snmp_asn1_enc_length ( struct pbuf *  p,
u16_t  ofs,
u16_t  length 
)

Encodes host order length field into a pbuf chained ASN1 msg.

Parameters:
p points to output pbuf to encode length into
ofs points to the offset within the pbuf chain
length is the host order length to be encoded
Returns:
ERR_OK if successfull, ERR_ARG if we can't (or won't) encode

void snmp_asn1_enc_length_cnt ( u16_t  length,
u8_t *  octets_needed 
)

Returns octet count for length.

Parameters:
length 
octets_needed points to the return value

err_t snmp_asn1_enc_oid ( struct pbuf *  p,
u16_t  ofs,
u8_t  ident_len,
s32_t *  ident 
)

Encodes object identifier into a pbuf chained ASN1 msg.

Parameters:
p points to output pbuf to encode oid into
ofs points to the offset within the pbuf chain
ident_len object identifier array length
ident points to object identifier array
Returns:
ERR_OK if successfull, ERR_ARG if we can't (or won't) encode

void snmp_asn1_enc_oid_cnt ( u8_t  ident_len,
s32_t *  ident,
u16_t *  octets_needed 
)

Returns octet count for an object identifier.

Parameters:
ident_len object identifier array length
ident points to object identifier array
octets_needed points to the return value

err_t snmp_asn1_enc_raw ( struct pbuf *  p,
u16_t  ofs,
u8_t  raw_len,
u8_t *  raw 
)

Encodes raw data (octet string, opaque) into a pbuf chained ASN1 msg.

Parameters:
p points to output pbuf to encode raw data into
ofs points to the offset within the pbuf chain
raw_len raw data length
raw points raw data
Returns:
ERR_OK if successfull, ERR_ARG if we can't (or won't) encode

err_t snmp_asn1_enc_s32t ( struct pbuf *  p,
u16_t  ofs,
u8_t  octets_needed,
s32_t  value 
)

Encodes s32_t integer into a pbuf chained ASN1 msg.

Parameters:
p points to output pbuf to encode value into
ofs points to the offset within the pbuf chain
octets_needed encoding length (from snmp_asn1_enc_s32t_cnt())
value is the host order s32_t value to be encoded
Returns:
ERR_OK if successfull, ERR_ARG if we can't (or won't) encode
See also:
snmp_asn1_enc_s32t_cnt()

void snmp_asn1_enc_s32t_cnt ( s32_t  value,
u16_t *  octets_needed 
)

Returns octet count for an s32_t.

Parameters:
value 
octets_needed points to the return value
Note:
ASN coded integers are _always_ signed.

err_t snmp_asn1_enc_type ( struct pbuf *  p,
u16_t  ofs,
u8_t  type 
)

Encodes ASN type field into a pbuf chained ASN1 msg.

Parameters:
p points to output pbuf to encode value into
ofs points to the offset within the pbuf chain
type input ASN1 type
Returns:
ERR_OK if successfull, ERR_ARG if we can't (or won't) encode

err_t snmp_asn1_enc_u32t ( struct pbuf *  p,
u16_t  ofs,
u8_t  octets_needed,
u32_t  value 
)

Encodes u32_t (counter, gauge, timeticks) into a pbuf chained ASN1 msg.

Parameters:
p points to output pbuf to encode value into
ofs points to the offset within the pbuf chain
octets_needed encoding length (from snmp_asn1_enc_u32t_cnt())
value is the host order u32_t value to be encoded
Returns:
ERR_OK if successfull, ERR_ARG if we can't (or won't) encode
See also:
snmp_asn1_enc_u32t_cnt()

void snmp_asn1_enc_u32t_cnt ( u32_t  value,
u16_t *  octets_needed 
)

Returns octet count for an u32_t.

Parameters:
value 
octets_needed points to the return value
Note:
ASN coded integers are _always_ signed. E.g. +0xFFFF is coded as 0x00,0xFF,0xFF. Note the leading sign octet. A positive value of 0xFFFFFFFF is preceded with 0x00 and the length is 5 octets!!


Generated on Sun Mar 23 19:22:46 2008 for lwIP 1.3.0 by  doxygen 1.5.4