| 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 |
*/ |
| 20 |
|
| 21 |
#include "pncompat/misc_defs.h" |
| 22 |
|
| 23 |
#include <inttypes.h> |
| 24 |
|
| 25 |
#include "proton/types.h" |
| 26 |
#include "proton/message.h" |
| 27 |
|
| 28 |
void msgr_die(const char *file, int line, const char *message); |
| 29 |
char *msgr_strdup( const char *src ); |
| 30 |
pn_timestamp_t msgr_now(void); |
| 31 |
void parse_password( const char *, char ** ); |
| 32 |
|
| 33 |
#define check_messenger(m) \ |
| 34 |
{ check(pn_messenger_errno(m) == 0, pn_error_text(pn_messenger_error(m))) } |
| 35 |
|
| 36 |
#define check( expression, message ) \ |
| 37 |
{ if (!(expression)) msgr_die(__FILE__,__LINE__, message); } |
| 38 |
|
| 39 |
|
| 40 |
// manage an ordered list of addresses |
| 41 |
|
| 42 |
typedef struct { |
| 43 |
const char **addresses; |
| 44 |
int size; // room in 'addresses' |
| 45 |
int count; // # entries |
| 46 |
} Addresses_t; |
| 47 |
|
| 48 |
#define NEXT_ADDRESS(a, i) (((i) + 1) % (a).count) |
| 49 |
void addresses_init( Addresses_t *a ); |
| 50 |
void addresses_free( Addresses_t *a ); |
| 51 |
void addresses_add( Addresses_t *a, const char *addr ); |
| 52 |
void addresses_merge( Addresses_t *a, const char *list ); |
| 53 |
|
| 54 |
// Statistics handling |
| 55 |
|
| 56 |
typedef struct { |
| 57 |
pn_timestamp_t start; |
| 58 |
uint64_t latency_samples; |
| 59 |
double latency_total; |
| 60 |
double latency_min; |
| 61 |
double latency_max; |
| 62 |
} Statistics_t; |
| 63 |
|
| 64 |
void statistics_start( Statistics_t *s ); |
| 65 |
void statistics_msg_received( Statistics_t *s, pn_message_t *message ); |
| 66 |
void statistics_report( Statistics_t *s, uint64_t sent, uint64_t received ); |
| 67 |
|
| 68 |
void enable_logging(void); |
| 69 |
void LOG( const char *fmt, ... ); |
| 70 |
|