1 /* 2 * include/types/protocol_buffers.h 3 * This file contains structure declarations for protocol buffers. 4 * 5 * Copyright 2012 Willy Tarreau <w@1wt.eu> 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation, version 2.1 10 * exclusively. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #ifndef _TYPES_PROTOCOL_BUFFERS_H 23 #define _TYPES_PROTOCOL_BUFFERS_H 24 25 enum protobuf_wire_type { 26 PBUF_TYPE_VARINT, 27 PBUF_TYPE_64BIT, 28 PBUF_TYPE_LENGTH_DELIMITED, 29 PBUF_TYPE_START_GROUP, /* Deprecated */ 30 PBUF_TYPE_STOP_GROUP, /* Deprecated */ 31 PBUF_TYPE_32BIT, 32 }; 33 34 enum protobuf_type { 35 /* These enums are used to initialize calloc()'ed struct fields. 36 * Start them from 1 to avoid collisions with the default 0 value 37 * of such struct fields. 38 */ 39 PBUF_T_BINARY = 1, 40 41 /* Do not reorder the following ones: 42 * PBUF_T_VARINT_*, PBUF_T_32BIT_* and PBUF_T_64BIT_* 43 */ 44 PBUF_T_VARINT_INT32, 45 PBUF_T_VARINT_UINT32, 46 PBUF_T_VARINT_INT64, 47 PBUF_T_VARINT_UINT64, 48 PBUF_T_VARINT_BOOL, 49 PBUF_T_VARINT_ENUM, 50 51 /* These two following varints are first encoded with zigzag. */ 52 PBUF_T_VARINT_SINT32, 53 PBUF_T_VARINT_SINT64, 54 55 /* Fixed size types from here. */ 56 PBUF_T_32BIT_FIXED32, 57 PBUF_T_32BIT_SFIXED32, 58 PBUF_T_32BIT_FLOAT, 59 60 PBUF_T_64BIT_FIXED64, 61 PBUF_T_64BIT_SFIXED64, 62 PBUF_T_64BIT_DOUBLE, 63 }; 64 65 66 struct pbuf_fid { 67 unsigned int *ids; 68 size_t sz; 69 }; 70 71 struct protobuf_parser_def { 72 int (*skip)(unsigned char **pos, size_t *left, size_t vlen); 73 int (*smp_store)(struct sample *, int type, 74 unsigned char *pos, size_t left, size_t vlen); 75 }; 76 77 #endif /* _TYPES_PROTOCOL_BUFFERS_H */ 78 79 /* 80 * Local variables: 81 * c-indent-level: 8 82 * c-basic-offset: 8 83 * End: 84 */ 85