コード例 #1
0
ファイル: reader.c プロジェクト: redcapnetworks/RIOT
void aodv_packet_reader_init(void)
{
    VDEBUG("%s()\n", __func__);

    /* initialize reader */
    rfc5444_reader_init(&reader);

    /* register message consumers. We have no message TLVs, so we can leave the
     * rfc5444_reader_tlvblock_consumer_entry empty */
    rfc5444_reader_add_message_consumer(&reader, &_rreq_consumer,
                                        NULL, 0);
    rfc5444_reader_add_message_consumer(&reader, &_rrep_consumer,
                                        NULL, 0);
    rfc5444_reader_add_message_consumer(&reader, &_rerr_consumer,
                                        NULL, 0);

    /* register address consumer */
    rfc5444_reader_add_message_consumer(&reader, &_rreq_address_consumer,
                                        _rreq_rrep_address_consumer_entries,
                                        ARRAYSIZE(_rreq_rrep_address_consumer_entries));
    rfc5444_reader_add_message_consumer(&reader, &_rrep_address_consumer,
                                        _rreq_rrep_address_consumer_entries,
                                        ARRAYSIZE(_rreq_rrep_address_consumer_entries));
    rfc5444_reader_add_message_consumer(&reader, &_rerr_address_consumer,
                                        _rerr_address_consumer_entries,
                                        ARRAYSIZE(_rerr_address_consumer_entries));
}
コード例 #2
0
ファイル: nhdp_reader.c プロジェクト: 4dahalibut/RIOT
void nhdp_reader_init(void)
{
    /* Initialize reader */
    rfc5444_reader_init(&reader);

    /* Register packet consumer for sequence number processing */
    rfc5444_reader_add_packet_consumer(&reader, &_nhdp_packet_consumer, NULL, 0);

    /* Register HELLO message consumer */
    rfc5444_reader_add_message_consumer(&reader, &_nhdp_msg_consumer,
                                        _nhdp_msg_tlvs, ARRAYSIZE(_nhdp_msg_tlvs));
    rfc5444_reader_add_message_consumer(&reader, &_nhdp_address_consumer,
                                        _nhdp_addr_tlvs, ARRAYSIZE(_nhdp_addr_tlvs));
}
コード例 #3
0
ファイル: rfc5444_print.c プロジェクト: OLSR/OONF
/**
 * This function converts a rfc5444 buffer into a human readable
 * form and print it into an buffer. To do this it allocates its own
 * rfc5444 reader, hooks in the printer macros, parse the packet and
 * cleans up the reader again.
 *
 * @param out pointer to output buffer
 * @param buffer pointer to packet to be printed
 * @param length length of packet in bytes
 * @return return code of reader, see rfc5444_result enum
 */
enum rfc5444_result
rfc5444_print_direct(struct autobuf *out, void *buffer, size_t length)
{
  struct rfc5444_reader reader;
  struct rfc5444_print_session session;
  enum rfc5444_result result;

  memset(&reader, 0, sizeof(reader));
  memset(&session, 0, sizeof(session));

  session.output = out;

  rfc5444_reader_init(&reader);
  rfc5444_print_add(&session, &reader);

  result = rfc5444_reader_handle_packet(&reader, buffer, length);
  if (result) {
    abuf_appendf(out, "Error while parsing rfc5444: %s\n", rfc5444_strerror(result));
  }
  rfc5444_print_remove(&session);
  rfc5444_reader_cleanup(&reader);

  return result;
}