lwIP 2.1.2 Lightweight IP stack

Functions
snmp_asn1.h File Reference
`#include "lwip/apps/snmp_opts.h"`
`#include "lwip/err.h"`
`#include "lwip/apps/snmp_core.h"`
`#include "snmp_pbuf_stream.h"`

## Functions
err_t | snmp_asn1_dec_tlv (struct snmp_pbuf_stream *pbuf_stream, struct snmp_asn1_tlv *tlv)
err_t | snmp_asn1_dec_u32t (struct snmp_pbuf_stream *pbuf_stream, u16_t len, u32_t *value)
err_t | snmp_asn1_dec_s32t (struct snmp_pbuf_stream *pbuf_stream, u16_t len, s32_t *value)
err_t | snmp_asn1_dec_oid (struct snmp_pbuf_stream *pbuf_stream, u16_t len, u32_t *oid, u8_t *oid_len, u8_t oid_max_len)
err_t | snmp_asn1_dec_raw (struct snmp_pbuf_stream *pbuf_stream, u16_t len, u8_t *buf, u16_t *buf_len, u16_t buf_max_len)
err_t | snmp_ans1_enc_tlv (struct snmp_pbuf_stream *pbuf_stream, struct snmp_asn1_tlv *tlv)
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 (const u32_t *oid, u16_t oid_len, u16_t *octets_needed)
err_t | snmp_asn1_enc_oid (struct snmp_pbuf_stream *pbuf_stream, const u32_t *oid, u16_t oid_len)
err_t | snmp_asn1_enc_s32t (struct snmp_pbuf_stream *pbuf_stream, u16_t octets_needed, s32_t value)
err_t | snmp_asn1_enc_u32t (struct snmp_pbuf_stream *pbuf_stream, u16_t octets_needed, u32_t value)
err_t | snmp_asn1_enc_raw (struct snmp_pbuf_stream *pbuf_stream, const u8_t *raw, u16_t raw_len)

## Detailed Description

Abstract Syntax Notation One (ISO 8824, 8825) codec.

## Function Documentation

## ◆ snmp_ans1_enc_tlv()

err_t snmp_ans1_enc_tlv | ( | struct snmp_pbuf_stream * | pbuf_stream,
|  | struct snmp_asn1_tlv * | tlv
| ) |  |

Encodes a TLV into a pbuf stream.

Parameters

  pbuf_stream | points to a pbuf stream
  tlv | TLV to encode

Returns
  ERR_OK if successful, ERR_ARG if we can't (or won't) encode

## ◆ snmp_asn1_dec_oid()

err_t snmp_asn1_dec_oid | ( | struct snmp_pbuf_stream * | pbuf_stream,
|  | u16_t | len,
|  | u32_t * | oid,
|  | u8_t * | oid_len,
|  | u8_t | oid_max_len
| ) |  |

Decodes object identifier from incoming message into array of u32_t.

Parameters

  pbuf_stream | points to a pbuf stream
  len | length of the coded object identifier
  oid | return decoded object identifier
  oid_len | return decoded object identifier length
  oid_max_len | size of oid buffer

Returns
  ERR_OK if successful, ERR_ARG if we can't (or won't) decode

## ◆ snmp_asn1_dec_raw()

err_t snmp_asn1_dec_raw | ( | struct snmp_pbuf_stream * | pbuf_stream,
|  | u16_t | len,
|  | u8_t * | buf,
|  | u16_t * | buf_len,
|  | u16_t | buf_max_len
| ) |  |

Decodes (copies) raw data (ip-addresses, octet strings, opaque encoding) from incoming message into array.

Parameters

  pbuf_stream | points to a pbuf stream
  len | length of the coded raw data (zero is valid, e.g. empty string!)
  buf | return raw bytes
  buf_len | returns length of the raw return value
  buf_max_len | buffer size

Returns
  ERR_OK if successful, ERR_ARG if we can't (or won't) decode

## ◆ snmp_asn1_dec_s32t()

err_t snmp_asn1_dec_s32t | ( | struct snmp_pbuf_stream * | pbuf_stream,
|  | u16_t | len,
|  | s32_t * | value
| ) |  |

Decodes integer into s32_t.

Parameters

  pbuf_stream | points to a pbuf stream
  len | length of the coded integer field
  value | return host order integer

Returns
  ERR_OK if successful, ERR_ARG if we can't (or won't) decode

Note
  ASN coded integers are always signed!

## ◆ snmp_asn1_dec_tlv()

err_t snmp_asn1_dec_tlv | ( | struct snmp_pbuf_stream * | pbuf_stream,
|  | struct snmp_asn1_tlv * | tlv
| ) |  |

Decodes a TLV from a pbuf stream.

Parameters

  pbuf_stream | points to a pbuf stream
  tlv | returns decoded TLV

Returns
  ERR_OK if successful, ERR_VAL if we can't decode

## ◆ snmp_asn1_dec_u32t()

err_t snmp_asn1_dec_u32t | ( | struct snmp_pbuf_stream * | pbuf_stream,
|  | u16_t | len,
|  | u32_t * | value
| ) |  |

Decodes positive integer (counter, gauge, timeticks) into u32_t.

Parameters

  pbuf_stream | points to a pbuf stream
  len | length of the coded integer field
  value | return host order integer

Returns
  ERR_OK if successful, ERR_ARG if we can't (or won't) decode

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!!

## ◆ snmp_asn1_enc_length_cnt()

void snmp_asn1_enc_length_cnt | ( | u16_t | length,
|  | u8_t * | octets_needed
| ) |  |

Returns octet count for length.

Parameters

  length | parameter length
  octets_needed | points to the return value

## ◆ snmp_asn1_enc_oid()

err_t snmp_asn1_enc_oid | ( | struct snmp_pbuf_stream * | pbuf_stream,
|  | const u32_t * | oid,
|  | u16_t | oid_len
| ) |  |

Encodes object identifier into a pbuf chained ASN1 msg.

Parameters

  pbuf_stream | points to a pbuf stream
  oid | points to object identifier array
  oid_len | object identifier array length

Returns
  ERR_OK if successful, ERR_ARG if we can't (or won't) encode

## ◆ snmp_asn1_enc_oid_cnt()

void snmp_asn1_enc_oid_cnt | ( | const u32_t * | oid,
|  | u16_t | oid_len,
|  | u16_t * | octets_needed
| ) |  |

Returns octet count for an object identifier.

Parameters

  oid | points to object identifier array
  oid_len | object identifier array length
  octets_needed | points to the return value

## ◆ snmp_asn1_enc_raw()

err_t snmp_asn1_enc_raw | ( | struct snmp_pbuf_stream * | pbuf_stream,
|  | const u8_t * | raw,
|  | u16_t | raw_len
| ) |  |

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

Parameters

  pbuf_stream | points to a pbuf stream
  raw_len | raw data length
  raw | points raw data

Returns
  ERR_OK if successful, ERR_ARG if we can't (or won't) encode

## ◆ snmp_asn1_enc_s32t()

err_t snmp_asn1_enc_s32t | ( | struct snmp_pbuf_stream * | pbuf_stream,
|  | u16_t | octets_needed,
|  | s32_t | value
| ) |  |

Encodes s32_t integer into a pbuf chained ASN1 msg.

Parameters

  pbuf_stream | points to a pbuf stream
  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 successful, ERR_ARG if we can't (or won't) encode

See also
  snmp_asn1_enc_s32t_cnt()

## ◆ 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 | value to be encoded
  octets_needed | points to the return value

Note
  ASN coded integers are always signed.

## ◆ snmp_asn1_enc_u32t()

err_t snmp_asn1_enc_u32t | ( | struct snmp_pbuf_stream * | pbuf_stream,
|  | u16_t | octets_needed,
|  | u32_t | value
| ) |  |

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

Parameters

  pbuf_stream | points to a pbuf stream
  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 successful, ERR_ARG if we can't (or won't) encode

See also
  snmp_asn1_enc_u32t_cnt()

## ◆ 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 | value to be encoded
  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!!