| 1 |
// Copyright (c) Microsoft. All rights reserved. |
| 2 |
// Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 3 |
|
| 4 |
#ifndef SESSION_H |
| 5 |
#define SESSION_H |
| 6 |
|
| 7 |
#include <stdint.h> |
| 8 |
#include "azure_uamqp_c/amqpvalue.h" |
| 9 |
#include "azure_uamqp_c/amqp_frame_codec.h" |
| 10 |
#include "azure_uamqp_c/connection.h" |
| 11 |
|
| 12 |
#include "azure_uamqp_c/amqp_definitions_role.h" |
| 13 |
#include "azure_uamqp_c/amqp_definitions_handle.h" |
| 14 |
#include "azure_uamqp_c/amqp_definitions_fields.h" |
| 15 |
#include "azure_uamqp_c/amqp_definitions_sender_settle_mode.h" |
| 16 |
#include "azure_uamqp_c/amqp_definitions_receiver_settle_mode.h" |
| 17 |
#include "azure_uamqp_c/amqp_definitions_sequence_no.h" |
| 18 |
#include "azure_uamqp_c/amqp_definitions_delivery_number.h" |
| 19 |
#include "azure_uamqp_c/amqp_definitions_disposition.h" |
| 20 |
#include "azure_uamqp_c/amqp_definitions_transfer_number.h" |
| 21 |
#include "azure_uamqp_c/amqp_definitions_flow.h" |
| 22 |
#include "azure_uamqp_c/amqp_definitions_attach.h" |
| 23 |
#include "azure_uamqp_c/amqp_definitions_error.h" |
| 24 |
#include "azure_uamqp_c/amqp_definitions_detach.h" |
| 25 |
#include "azure_uamqp_c/amqp_definitions_delivery_tag.h" |
| 26 |
#include "azure_uamqp_c/amqp_definitions_message_format.h" |
| 27 |
#include "azure_uamqp_c/amqp_definitions_transfer.h" |
| 28 |
|
| 29 |
|
| 30 |
#include "umock_c/umock_c_prod.h" |
| 31 |
#include "azure_macro_utils/macro_utils.h" |
| 32 |
|
| 33 |
|
| 34 |
#ifdef __cplusplus |
| 35 |
extern "C" { |
| 36 |
#endif /* __cplusplus */ |
| 37 |
|
| 38 |
typedef struct SESSION_INSTANCE_TAG* SESSION_HANDLE; |
| 39 |
typedef struct LINK_ENDPOINT_INSTANCE_TAG* LINK_ENDPOINT_HANDLE; |
| 40 |
|
| 41 |
#define SESSION_STATE_VALUES \ |
| 42 |
SESSION_STATE_UNMAPPED, \ |
| 43 |
SESSION_STATE_BEGIN_SENT, \ |
| 44 |
SESSION_STATE_BEGIN_RCVD, \ |
| 45 |
SESSION_STATE_MAPPED, \ |
| 46 |
SESSION_STATE_END_SENT, \ |
| 47 |
SESSION_STATE_END_RCVD, \ |
| 48 |
SESSION_STATE_DISCARDING, \ |
| 49 |
SESSION_STATE_ERROR |
| 50 |
|
| 51 |
MU_DEFINE_ENUM(SESSION_STATE, SESSION_STATE_VALUES) |
| 52 |
|
| 53 |
#define SESSION_SEND_TRANSFER_RESULT_VALUES \ |
| 54 |
SESSION_SEND_TRANSFER_OK, \ |
| 55 |
SESSION_SEND_TRANSFER_ERROR, \ |
| 56 |
SESSION_SEND_TRANSFER_BUSY |
| 57 |
|
| 58 |
MU_DEFINE_ENUM(SESSION_SEND_TRANSFER_RESULT, SESSION_SEND_TRANSFER_RESULT_VALUES) |
| 59 |
|
| 60 |
typedef void(*LINK_ENDPOINT_FRAME_RECEIVED_CALLBACK)(void* context, AMQP_VALUE performative, uint32_t frame_payload_size, const unsigned char* payload_bytes); |
| 61 |
typedef void(*ON_LINK_ENDPOINT_DESTROYED_CALLBACK)(LINK_ENDPOINT_HANDLE handle, void* context); |
| 62 |
typedef void(*ON_SESSION_STATE_CHANGED)(void* context, SESSION_STATE new_session_state, SESSION_STATE previous_session_state); |
| 63 |
typedef void(*ON_SESSION_FLOW_ON)(void* context); |
| 64 |
typedef bool(*ON_LINK_ATTACHED)(void* context, LINK_ENDPOINT_HANDLE new_link_endpoint, const char* name, role role, AMQP_VALUE source, AMQP_VALUE target, fields properties); |
| 65 |
|
| 66 |
MOCKABLE_FUNCTION(, SESSION_HANDLE, session_create, CONNECTION_HANDLE, connection, ON_LINK_ATTACHED, on_link_attached, void*, callback_context); |
| 67 |
MOCKABLE_FUNCTION(, SESSION_HANDLE, session_create_from_endpoint, CONNECTION_HANDLE, connection, ENDPOINT_HANDLE, connection_endpoint, ON_LINK_ATTACHED, on_link_attached, void*, callback_context); |
| 68 |
MOCKABLE_FUNCTION(, int, session_set_incoming_window, SESSION_HANDLE, session, uint32_t, incoming_window); |
| 69 |
MOCKABLE_FUNCTION(, int, session_get_incoming_window, SESSION_HANDLE, session, uint32_t*, incoming_window); |
| 70 |
MOCKABLE_FUNCTION(, int, session_set_outgoing_window, SESSION_HANDLE, session, uint32_t, outgoing_window); |
| 71 |
MOCKABLE_FUNCTION(, int, session_get_outgoing_window, SESSION_HANDLE, session, uint32_t*, outgoing_window); |
| 72 |
MOCKABLE_FUNCTION(, int, session_set_handle_max, SESSION_HANDLE, session, handle, handle_max); |
| 73 |
MOCKABLE_FUNCTION(, int, session_get_handle_max, SESSION_HANDLE, session, handle*, handle_max); |
| 74 |
MOCKABLE_FUNCTION(, void, session_destroy, SESSION_HANDLE, session); |
| 75 |
MOCKABLE_FUNCTION(, int, session_begin, SESSION_HANDLE, session); |
| 76 |
MOCKABLE_FUNCTION(, int, session_end, SESSION_HANDLE, session, const char*, condition_value, const char*, description); |
| 77 |
MOCKABLE_FUNCTION(, LINK_ENDPOINT_HANDLE, session_create_link_endpoint, SESSION_HANDLE, session, const char*, name); |
| 78 |
MOCKABLE_FUNCTION(, void, session_set_link_endpoint_callback, LINK_ENDPOINT_HANDLE, link_endpoint, ON_LINK_ENDPOINT_DESTROYED_CALLBACK, on_link_endpoint_destroyed, void*, context); |
| 79 |
MOCKABLE_FUNCTION(, void, session_destroy_link_endpoint, LINK_ENDPOINT_HANDLE, link_endpoint); |
| 80 |
MOCKABLE_FUNCTION(, int, session_start_link_endpoint, LINK_ENDPOINT_HANDLE, link_endpoint, ON_ENDPOINT_FRAME_RECEIVED, frame_received_callback, ON_SESSION_STATE_CHANGED, on_session_state_changed, ON_SESSION_FLOW_ON, on_session_flow_on, void*, context); |
| 81 |
MOCKABLE_FUNCTION(, int, session_send_flow, LINK_ENDPOINT_HANDLE, link_endpoint, FLOW_HANDLE, flow); |
| 82 |
MOCKABLE_FUNCTION(, int, session_send_attach, LINK_ENDPOINT_HANDLE, link_endpoint, ATTACH_HANDLE, attach); |
| 83 |
MOCKABLE_FUNCTION(, int, session_send_disposition, LINK_ENDPOINT_HANDLE, link_endpoint, DISPOSITION_HANDLE, disposition); |
| 84 |
MOCKABLE_FUNCTION(, int, session_send_detach, LINK_ENDPOINT_HANDLE, link_endpoint, DETACH_HANDLE, detach); |
| 85 |
MOCKABLE_FUNCTION(, SESSION_SEND_TRANSFER_RESULT, session_send_transfer, LINK_ENDPOINT_HANDLE, link_endpoint, TRANSFER_HANDLE, transfer, PAYLOAD*, payloads, size_t, payload_count, delivery_number*, delivery_id, ON_SEND_COMPLETE, on_send_complete, void*, callback_context); |
| 86 |
|
| 87 |
#ifdef __cplusplus |
| 88 |
} |
| 89 |
#endif /* __cplusplus */ |
| 90 |
|
| 91 |
#endif /* SESSION_H */ |