C AMQP Protocol Engine API  0.6
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
engine.h
Go to the documentation of this file.
1 #ifndef PROTON_ENGINE_H
2 #define PROTON_ENGINE_H 1
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include <proton/import_export.h>
26 #ifndef __cplusplus
27 #include <stdbool.h>
28 #endif
29 #include <stddef.h>
30 #include <sys/types.h>
31 #include <proton/codec.h>
32 #include <proton/error.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
46 typedef struct pn_session_t pn_session_t;
47 typedef struct pn_link_t pn_link_t;
50 
51 typedef enum {
53  PN_SOURCE = 1,
54  PN_TARGET = 2,
57 typedef enum {
62 typedef enum {
68 typedef enum {
73 typedef enum {
78 typedef enum {
82 
85 
86 typedef struct pn_delivery_tag_t {
87  size_t size;
88  const char *bytes;
90 
91 #ifndef SWIG // older versions of SWIG choke on this:
92 static inline pn_delivery_tag_t pn_dtag(const char *bytes, size_t size) {
93  pn_delivery_tag_t dtag = {size, bytes};
94  return dtag;
95 }
96 #endif
97 
98 typedef int pn_state_t;
100 #define PN_LOCAL_UNINIT (1)
101 #define PN_LOCAL_ACTIVE (2)
102 #define PN_LOCAL_CLOSED (4)
103 #define PN_REMOTE_UNINIT (8)
104 #define PN_REMOTE_ACTIVE (16)
105 #define PN_REMOTE_CLOSED (32)
107 #define PN_LOCAL_MASK (PN_LOCAL_UNINIT | PN_LOCAL_ACTIVE | PN_LOCAL_CLOSED)
108 #define PN_REMOTE_MASK (PN_REMOTE_UNINIT | PN_REMOTE_ACTIVE | PN_REMOTE_CLOSED)
109 
116 #define PN_RECEIVED (0x0000000000000023)
117 #define PN_ACCEPTED (0x0000000000000024)
118 #define PN_REJECTED (0x0000000000000025)
119 #define PN_RELEASED (0x0000000000000026)
120 #define PN_MODIFIED (0x0000000000000027)
121 
122 typedef int pn_trace_t;
123 typedef void (pn_tracer_t)(pn_transport_t *transport, const char *message);
124 
125 #define PN_TRACE_OFF (0)
126 #define PN_TRACE_RAW (1)
127 #define PN_TRACE_FRM (2)
128 #define PN_TRACE_DRV (4)
129 
130 // connection
131 
137 
143 PN_EXTERN pn_state_t pn_connection_state(pn_connection_t *connection);
147 PN_EXTERN const char *pn_connection_get_container(pn_connection_t *connection);
149 PN_EXTERN void pn_connection_set_container(pn_connection_t *connection, const char *container);
151 PN_EXTERN const char *pn_connection_get_hostname(pn_connection_t *connection);
153 PN_EXTERN void pn_connection_set_hostname(pn_connection_t *connection, const char *hostname);
162 
163 
180 
190 
200 
202 PN_EXTERN void pn_session_set_incoming_capacity(pn_session_t *ssn, size_t capacity);
203 
206 
216 
222 PN_EXTERN int pn_transport_bind(pn_transport_t *transport, pn_connection_t *connection);
223 
225 
240 PN_EXTERN pn_session_t *pn_session_head(pn_connection_t *connection, pn_state_t state);
241 
254 PN_EXTERN pn_session_t *pn_session_next(pn_session_t *session, pn_state_t state);
255 
270 PN_EXTERN pn_link_t *pn_link_head(pn_connection_t *connection, pn_state_t state);
271 
284 PN_EXTERN pn_link_t *pn_link_next(pn_link_t *link, pn_state_t state);
285 
290 
299 
306 PN_EXTERN void pn_connection_set_context(pn_connection_t *connection, void *context);
307 
308 
309 // transport
311 /* deprecated */
312 PN_EXTERN ssize_t pn_transport_input(pn_transport_t *transport, const char *bytes, size_t available);
313 /* deprecated */
314 PN_EXTERN ssize_t pn_transport_output(pn_transport_t *transport, char *bytes, size_t size);
315 
329 
338 PN_EXTERN char *pn_transport_tail(pn_transport_t *transport);
339 
349 PN_EXTERN int pn_transport_push(pn_transport_t *transport, const char *src, size_t size);
350 
361 PN_EXTERN int pn_transport_process(pn_transport_t *transport, size_t size);
362 
370 
383 PN_EXTERN ssize_t pn_transport_pending(pn_transport_t *transport);
384 
394 PN_EXTERN const char *pn_transport_head(pn_transport_t *transport);
395 
403 PN_EXTERN int pn_transport_peek(pn_transport_t *transport, char *dst, size_t size);
404 
413 PN_EXTERN void pn_transport_pop(pn_transport_t *transport, size_t size);
414 
422 
423 
438 PN_EXTERN void pn_transport_trace(pn_transport_t *transport, pn_trace_t trace);
441 PN_EXTERN void pn_transport_set_context(pn_transport_t *transport, void *context);
443 PN_EXTERN void pn_transport_log(pn_transport_t *transport, const char *message);
444 PN_EXTERN void pn_transport_logf(pn_transport_t *transport, const char *fmt, ...);
445 // max frame of zero means "unlimited"
447 PN_EXTERN void pn_transport_set_max_frame(pn_transport_t *transport, uint32_t size);
449 /* timeout of zero means "no timeout" */
453 PN_EXTERN uint64_t pn_transport_get_frames_output(const pn_transport_t *transport);
454 PN_EXTERN uint64_t pn_transport_get_frames_input(const pn_transport_t *transport);
457 
458 // session
459 PN_EXTERN pn_state_t pn_session_state(pn_session_t *session);
462 PN_EXTERN void pn_session_open(pn_session_t *session);
464 PN_EXTERN void pn_session_free(pn_session_t *session);
466 PN_EXTERN void pn_session_set_context(pn_session_t *session, void *context);
467 
468 // link
469 PN_EXTERN pn_link_t *pn_sender(pn_session_t *session, const char *name);
470 PN_EXTERN pn_link_t *pn_receiver(pn_session_t *session, const char *name);
471 PN_EXTERN const char *pn_link_name(pn_link_t *link);
474 PN_EXTERN pn_state_t pn_link_state(pn_link_t *link);
493 
497 
498 PN_EXTERN void pn_link_open(pn_link_t *sender);
499 PN_EXTERN void pn_link_close(pn_link_t *sender);
500 PN_EXTERN void pn_link_free(pn_link_t *sender);
502 PN_EXTERN void pn_link_set_context(pn_link_t *link, void *context);
504 
505 // sender
506 PN_EXTERN void pn_link_offered(pn_link_t *sender, int credit);
507 PN_EXTERN ssize_t pn_link_send(pn_link_t *sender, const char *bytes, size_t n);
508 PN_EXTERN int pn_link_drained(pn_link_t *sender);
509 //void pn_link_abort(pn_sender_t *sender);
510 
511 // receiver
512 PN_EXTERN void pn_link_flow(pn_link_t *receiver, int credit);
513 PN_EXTERN void pn_link_drain(pn_link_t *receiver, int credit);
514 PN_EXTERN void pn_link_set_drain(pn_link_t *receiver, bool drain);
515 PN_EXTERN ssize_t pn_link_recv(pn_link_t *receiver, char *bytes, size_t n);
516 PN_EXTERN bool pn_link_draining(pn_link_t *receiver);
517 
518 // terminus
521 
522 PN_EXTERN const char *pn_terminus_get_address(pn_terminus_t *terminus);
523 PN_EXTERN int pn_terminus_set_address(pn_terminus_t *terminus, const char *address);
526  pn_durability_t durability);
532 PN_EXTERN int pn_terminus_set_dynamic(pn_terminus_t *terminus, bool dynamic);
540 
541 // delivery
545 // how do we do delivery state?
556 PN_EXTERN void pn_delivery_update(pn_delivery_t *delivery, uint64_t state);
558 //int pn_delivery_format(pn_delivery_t *delivery);
562 PN_EXTERN void pn_delivery_set_context(pn_delivery_t *delivery, void *context);
564 
565 // disposition
566 PN_EXTERN uint64_t pn_disposition_type(pn_disposition_t *disposition);
569 PN_EXTERN void pn_disposition_set_section_number(pn_disposition_t *disposition, uint32_t section_number);
571 PN_EXTERN void pn_disposition_set_section_offset(pn_disposition_t *disposition, uint64_t section_offset);
573 PN_EXTERN void pn_disposition_set_failed(pn_disposition_t *disposition, bool failed);
575 PN_EXTERN void pn_disposition_set_undeliverable(pn_disposition_t *disposition, bool undeliverable);
577 
578 // conditions
581 
584 
587 
589 
592 
593 PN_EXTERN const char *pn_condition_get_name(pn_condition_t *condition);
594 PN_EXTERN int pn_condition_set_name(pn_condition_t *condition, const char *name);
595 
597 PN_EXTERN int pn_condition_set_description(pn_condition_t *condition, const char *description);
598 
600 
602 PN_EXTERN const char *pn_condition_redirect_host(pn_condition_t *condition);
604 
605 #ifdef __cplusplus
606 }
607 #endif
608 
609 #endif /* engine.h */