OpenSDN source code
thrift_transport.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  * Copyright 2006-2017 The Apache Software Foundation.
20  * https://github.com/apache/thrift
21  *
22  * Modifications Copyright (c) Juniper Networks, Inc.
23  * Copyright Contributors to the OpenSDN project
24  */
25 
26 #ifndef _THRIFT_TRANSPORT_H
27 #define _THRIFT_TRANSPORT_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
36 typedef enum {
41 
46 {
48  /* vtable */
49  int32_t (*read) (struct _ThriftTransport *transport, void *buf,
50  u_int32_t len, int *error);
51  u_int8_t (*write) (struct _ThriftTransport *transport, const void *buf,
52  const u_int32_t len, int *error);
53 };
54 typedef struct _ThriftTransport ThriftTransport;
55 
56 /* used by THRIFT_TYPE_TRANSPORT */
58 
59 /* virtual public methods */
60 
65 static inline int32_t
66 thrift_transport_read (ThriftTransport *transport, void *buf,
67  u_int32_t len, int *error)
68 {
69  return transport->read (transport, buf, len, error);
70 }
71 
76 static inline u_int8_t
77 thrift_transport_write (ThriftTransport *transport, const void *buf,
78  const u_int32_t len, int *error)
79 {
80  return transport->write (transport, buf, len, error);
81 }
82 
83 /* define error/exception types */
84 typedef enum
85 {
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif /* _THRIFT_TRANSPORT_H */
int32_t(* read)(struct _ThriftTransport *transport, void *buf, u_int32_t len, int *error)
ThriftTransportType ttype
u_int8_t(* write)(struct _ThriftTransport *transport, const void *buf, const u_int32_t len, int *error)
ThriftTransportType
@ T_TRANSPORT_FAKE
@ T_TRANSPORT_MEMORY_BUFFER
@ T_TRANSPORT_FILE
ThriftTransportError
@ THRIFT_TRANSPORT_ERROR_CLOSE
@ THRIFT_TRANSPORT_ERROR_UNKNOWN
@ THRIFT_TRANSPORT_ERROR_CONNECT
@ THRIFT_TRANSPORT_ERROR_SEND
@ THRIFT_TRANSPORT_ERROR_RECEIVE
@ THRIFT_TRANSPORT_ERROR_HOST
@ THRIFT_TRANSPORT_ERROR_SOCKET
ThriftTransportType thrift_transport_get_type(void)