Files
bacnet_stack/src/bacnet/hostnport.h
T
Kari Argillander 369da70f2a Strip tabs and trailing white spaces, and fix end of files (#748)
* format: Strip trailing whitespaces

We want to get rid of trailing whitespaces completly as they make just git
noice. Much better to start using automated tools to get rid of them once and
not getting them back again. This way git history will be cleaner and review
easier.

Commit was generated with:

    pre-commit run --all-files trailing-whitespace

* format: Files should have exactly one new line end of them

It is good practice that every file has one new line. It is not now days so
mandatory but it also is not nice if file has lot of newlines end of it. We will
use pre-commit which takes automatically care about this so let's fix all.

Commit was generated with:

    pre-commit run --all-files end-of-file-fixer

* format: Convert tabs to spaces

Project mostly use spaces over tabs. When mixing tabs and spaces this usually
makes formatting issues and also when changing those in commits it will make lot
of git noise. We will force spaces most of the time and use pre-commit to fix.

Commit was generated with:

    pre-commit run --all-files remove-tabs

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-25 14:13:57 -05:00

193 lines
5.5 KiB
C

/**
* @file
* @brief API for BACnetHostNPort complex data type encode and decode
* @author Steve Karg <skarg@users.sourceforge.net>
* @date May 2022
* @copyright SPDX-License-Identifier: MIT
*/
#ifndef BACNET_HOST_N_PORT_H
#define BACNET_HOST_N_PORT_H
#include <stdint.h>
#include <stdbool.h>
/* BACnet Stack defines - first */
#include "bacnet/bacdef.h"
/* BACnet Stack API */
#include "bacnet/bacstr.h"
#include "bacnet/datalink/bvlc.h"
/**
* BACnetHostNPort ::= SEQUENCE {
* host [0] BACnetHostAddress,
* BACnetHostAddress ::= CHOICE {
* none [0] NULL,
* ip-address [1] OCTET STRING,
* name [2] CharacterString
* }
* port [1] Unsigned16
* }
*/
typedef struct BACnetHostNPort {
bool host_ip_address:1;
bool host_name:1;
union BACnetHostAddress {
/* none = host_ip_address AND host_name are FALSE */
BACNET_OCTET_STRING ip_address;
BACNET_CHARACTER_STRING name;
} host;
uint16_t port;
} BACNET_HOST_N_PORT;
/**
* BACnetBDTEntry ::= SEQUENCE {
* bbmd-address [0] BACnetHostNPort,
* broadcast-mask [1] OCTET STRING OPTIONAL
* -- shall be present if BACnet/IP, and absent for BACnet/IPv6
* }
*/
typedef struct BACnetBDTEntry {
BACNET_HOST_N_PORT bbmd_address;
BACNET_OCTET_STRING broadcast_mask;
} BACNET_BDT_ENTRY;
/**
* BACnetFDTEntry ::= SEQUENCE {
* bacnetip-address [0] OCTET STRING,
* -- the 6-octet B/IP or 18-octet B/IPv6 address of the registrant
* time-to-live [1] Unsigned16,
* -- time to live in seconds at the time of registration
* remaining-time-to-live [2] Unsigned16
* -- remaining time to live in seconds, incl. grace period
* }
*/
typedef struct BACnetFDTEntry {
BACNET_OCTET_STRING bacnetip_address;
uint16_t time_to_live;
uint16_t remaining_time_to_live;
} BACNET_FDT_ENTRY;
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
BACNET_STACK_EXPORT
int host_n_port_address_encode(
uint8_t *apdu,
BACNET_HOST_N_PORT *address);
BACNET_STACK_EXPORT
int host_n_port_encode(
uint8_t * apdu,
BACNET_HOST_N_PORT *address);
BACNET_STACK_EXPORT
int host_n_port_context_encode(
uint8_t * apdu,
uint8_t tag_number,
BACNET_HOST_N_PORT *address);
BACNET_STACK_EXPORT
int host_n_port_address_decode(uint8_t *apdu,
uint32_t apdu_size,
BACNET_ERROR_CODE *error_code,
BACNET_HOST_N_PORT *address);
BACNET_STACK_EXPORT
int host_n_port_decode(uint8_t *apdu,
uint32_t apdu_len,
BACNET_ERROR_CODE *error_code,
BACNET_HOST_N_PORT *address);
BACNET_STACK_EXPORT
int host_n_port_context_decode(uint8_t *apdu,
uint32_t apdu_size,
uint8_t tag_number,
BACNET_ERROR_CODE *error_code,
BACNET_HOST_N_PORT *address);
BACNET_STACK_EXPORT
bool host_n_port_copy(
BACNET_HOST_N_PORT * dst,
BACNET_HOST_N_PORT * src);
BACNET_STACK_EXPORT
bool host_n_port_same(
BACNET_HOST_N_PORT * dst,
BACNET_HOST_N_PORT * src);
BACNET_STACK_EXPORT
bool host_n_port_from_ascii(
BACNET_HOST_N_PORT *value,
const char *argv);
BACNET_STACK_EXPORT
int bacnet_bdt_entry_encode(
uint8_t * apdu,
BACNET_BDT_ENTRY *entry);
BACNET_STACK_EXPORT
int bacnet_bdt_entry_context_encode(
uint8_t * apdu,
uint8_t tag_number,
BACNET_BDT_ENTRY *entry);
BACNET_STACK_EXPORT
int bacnet_bdt_entry_decode(uint8_t *apdu,
uint32_t apdu_len,
BACNET_ERROR_CODE *error_code,
BACNET_BDT_ENTRY *address);
BACNET_STACK_EXPORT
int bacnet_bdt_entry_context_decode(uint8_t *apdu,
uint32_t apdu_size,
uint8_t tag_number,
BACNET_ERROR_CODE *error_code,
BACNET_BDT_ENTRY *address);
BACNET_STACK_EXPORT
bool bacnet_bdt_entry_copy(
BACNET_BDT_ENTRY * dst,
BACNET_BDT_ENTRY * src);
BACNET_STACK_EXPORT
bool bacnet_bdt_entry_same(
BACNET_BDT_ENTRY * dst,
BACNET_BDT_ENTRY * src);
BACNET_STACK_EXPORT
bool bacnet_bdt_entry_from_ascii(
BACNET_BDT_ENTRY *value,
const char *argv);
BACNET_STACK_EXPORT
int bacnet_bdt_entry_to_ascii(
char *str, size_t str_size,
BACNET_BDT_ENTRY *value);
BACNET_STACK_EXPORT
int bacnet_fdt_entry_encode(
uint8_t * apdu,
BACNET_FDT_ENTRY *entry);
BACNET_STACK_EXPORT
int bacnet_fdt_entry_context_encode(
uint8_t * apdu,
uint8_t tag_number,
BACNET_FDT_ENTRY *entry);
BACNET_STACK_EXPORT
int bacnet_fdt_entry_decode(uint8_t *apdu,
uint32_t apdu_len,
BACNET_ERROR_CODE *error_code,
BACNET_FDT_ENTRY *address);
BACNET_STACK_EXPORT
int bacnet_fdt_entry_context_decode(uint8_t *apdu,
uint32_t apdu_size,
uint8_t tag_number,
BACNET_ERROR_CODE *error_code,
BACNET_FDT_ENTRY *address);
BACNET_STACK_EXPORT
bool bacnet_fdt_entry_copy(
BACNET_FDT_ENTRY * dst,
BACNET_FDT_ENTRY * src);
BACNET_STACK_EXPORT
bool bacnet_fdt_entry_same(
BACNET_FDT_ENTRY * dst,
BACNET_FDT_ENTRY * src);
BACNET_STACK_EXPORT
bool bacnet_fdt_entry_from_ascii(
BACNET_FDT_ENTRY *value,
const char *argv);
BACNET_STACK_EXPORT
int bacnet_fdt_entry_to_ascii(
char *str, size_t str_size,
BACNET_FDT_ENTRY *value);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif