Some quick code to use UDP-only (no TCP) with mBed. Echos received packets and sends packets when a button is pressed

Dependencies:   mbed

Committer:
pehrhovey
Date:
Sun Mar 14 00:54:12 2010 +0000
Revision:
0:a548a085de55

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pehrhovey 0:a548a085de55 1 /**
pehrhovey 0:a548a085de55 2 * @file
pehrhovey 0:a548a085de55 3 * Abstract Syntax Notation One (ISO 8824, 8825) codec.
pehrhovey 0:a548a085de55 4 */
pehrhovey 0:a548a085de55 5
pehrhovey 0:a548a085de55 6 /*
pehrhovey 0:a548a085de55 7 * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
pehrhovey 0:a548a085de55 8 * All rights reserved.
pehrhovey 0:a548a085de55 9 *
pehrhovey 0:a548a085de55 10 * Redistribution and use in source and binary forms, with or without modification,
pehrhovey 0:a548a085de55 11 * are permitted provided that the following conditions are met:
pehrhovey 0:a548a085de55 12 *
pehrhovey 0:a548a085de55 13 * 1. Redistributions of source code must retain the above copyright notice,
pehrhovey 0:a548a085de55 14 * this list of conditions and the following disclaimer.
pehrhovey 0:a548a085de55 15 * 2. Redistributions in binary form must reproduce the above copyright notice,
pehrhovey 0:a548a085de55 16 * this list of conditions and the following disclaimer in the documentation
pehrhovey 0:a548a085de55 17 * and/or other materials provided with the distribution.
pehrhovey 0:a548a085de55 18 * 3. The name of the author may not be used to endorse or promote products
pehrhovey 0:a548a085de55 19 * derived from this software without specific prior written permission.
pehrhovey 0:a548a085de55 20 *
pehrhovey 0:a548a085de55 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
pehrhovey 0:a548a085de55 22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
pehrhovey 0:a548a085de55 23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
pehrhovey 0:a548a085de55 24 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
pehrhovey 0:a548a085de55 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
pehrhovey 0:a548a085de55 26 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
pehrhovey 0:a548a085de55 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
pehrhovey 0:a548a085de55 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
pehrhovey 0:a548a085de55 29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
pehrhovey 0:a548a085de55 30 * OF SUCH DAMAGE.
pehrhovey 0:a548a085de55 31 *
pehrhovey 0:a548a085de55 32 * Author: Christiaan Simons <christiaan.simons@axon.tv>
pehrhovey 0:a548a085de55 33 */
pehrhovey 0:a548a085de55 34
pehrhovey 0:a548a085de55 35 #ifndef __LWIP_SNMP_ASN1_H__
pehrhovey 0:a548a085de55 36 #define __LWIP_SNMP_ASN1_H__
pehrhovey 0:a548a085de55 37
pehrhovey 0:a548a085de55 38 #include "lwip/opt.h"
pehrhovey 0:a548a085de55 39 #include "lwip/err.h"
pehrhovey 0:a548a085de55 40 #include "lwip/pbuf.h"
pehrhovey 0:a548a085de55 41 #include "lwip/snmp.h"
pehrhovey 0:a548a085de55 42
pehrhovey 0:a548a085de55 43 #if LWIP_SNMP
pehrhovey 0:a548a085de55 44
pehrhovey 0:a548a085de55 45 #ifdef __cplusplus
pehrhovey 0:a548a085de55 46 extern "C" {
pehrhovey 0:a548a085de55 47 #endif
pehrhovey 0:a548a085de55 48
pehrhovey 0:a548a085de55 49 #define SNMP_ASN1_UNIV (!0x80 | !0x40)
pehrhovey 0:a548a085de55 50 #define SNMP_ASN1_APPLIC (!0x80 | 0x40)
pehrhovey 0:a548a085de55 51 #define SNMP_ASN1_CONTXT ( 0x80 | !0x40)
pehrhovey 0:a548a085de55 52
pehrhovey 0:a548a085de55 53 #define SNMP_ASN1_CONSTR (0x20)
pehrhovey 0:a548a085de55 54 #define SNMP_ASN1_PRIMIT (!0x20)
pehrhovey 0:a548a085de55 55
pehrhovey 0:a548a085de55 56 /* universal tags */
pehrhovey 0:a548a085de55 57 #define SNMP_ASN1_INTEG 2
pehrhovey 0:a548a085de55 58 #define SNMP_ASN1_OC_STR 4
pehrhovey 0:a548a085de55 59 #define SNMP_ASN1_NUL 5
pehrhovey 0:a548a085de55 60 #define SNMP_ASN1_OBJ_ID 6
pehrhovey 0:a548a085de55 61 #define SNMP_ASN1_SEQ 16
pehrhovey 0:a548a085de55 62
pehrhovey 0:a548a085de55 63 /* application specific (SNMP) tags */
pehrhovey 0:a548a085de55 64 #define SNMP_ASN1_IPADDR 0 /* octet string size(4) */
pehrhovey 0:a548a085de55 65 #define SNMP_ASN1_COUNTER 1 /* u32_t */
pehrhovey 0:a548a085de55 66 #define SNMP_ASN1_GAUGE 2 /* u32_t */
pehrhovey 0:a548a085de55 67 #define SNMP_ASN1_TIMETICKS 3 /* u32_t */
pehrhovey 0:a548a085de55 68 #define SNMP_ASN1_OPAQUE 4 /* octet string */
pehrhovey 0:a548a085de55 69
pehrhovey 0:a548a085de55 70 /* context specific (SNMP) tags */
pehrhovey 0:a548a085de55 71 #define SNMP_ASN1_PDU_GET_REQ 0
pehrhovey 0:a548a085de55 72 #define SNMP_ASN1_PDU_GET_NEXT_REQ 1
pehrhovey 0:a548a085de55 73 #define SNMP_ASN1_PDU_GET_RESP 2
pehrhovey 0:a548a085de55 74 #define SNMP_ASN1_PDU_SET_REQ 3
pehrhovey 0:a548a085de55 75 #define SNMP_ASN1_PDU_TRAP 4
pehrhovey 0:a548a085de55 76
pehrhovey 0:a548a085de55 77 err_t snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type);
pehrhovey 0:a548a085de55 78 err_t snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length);
pehrhovey 0:a548a085de55 79 err_t snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value);
pehrhovey 0:a548a085de55 80 err_t snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value);
pehrhovey 0:a548a085de55 81 err_t snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid);
pehrhovey 0:a548a085de55 82 err_t snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw);
pehrhovey 0:a548a085de55 83
pehrhovey 0:a548a085de55 84 void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed);
pehrhovey 0:a548a085de55 85 void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed);
pehrhovey 0:a548a085de55 86 void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed);
pehrhovey 0:a548a085de55 87 void snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed);
pehrhovey 0:a548a085de55 88 err_t snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type);
pehrhovey 0:a548a085de55 89 err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length);
pehrhovey 0:a548a085de55 90 err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u8_t octets_needed, u32_t value);
pehrhovey 0:a548a085de55 91 err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u8_t octets_needed, s32_t value);
pehrhovey 0:a548a085de55 92 err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident);
pehrhovey 0:a548a085de55 93 err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u8_t raw_len, u8_t *raw);
pehrhovey 0:a548a085de55 94
pehrhovey 0:a548a085de55 95 #ifdef __cplusplus
pehrhovey 0:a548a085de55 96 }
pehrhovey 0:a548a085de55 97 #endif
pehrhovey 0:a548a085de55 98
pehrhovey 0:a548a085de55 99 #endif /* LWIP_SNMP */
pehrhovey 0:a548a085de55 100
pehrhovey 0:a548a085de55 101 #endif /* __LWIP_SNMP_ASN1_H__ */