Fixed compile errors and warnings for IPv6 on Win32 port.
This commit is contained in:
@@ -204,18 +204,18 @@ extern "C" {
|
||||
BACNET_ADDRESS * addr,
|
||||
uint32_t *device_id);
|
||||
|
||||
int bvlc6_encode_header(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint8_t message_type,
|
||||
uint16_t length);
|
||||
int bvlc6_decode_header(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t * message_type,
|
||||
uint16_t * length);
|
||||
int bvlc6_encode_header(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint8_t message_type,
|
||||
uint16_t length);
|
||||
int bvlc6_decode_header(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t * message_type,
|
||||
uint16_t * length);
|
||||
|
||||
int bvlc6_encode_result(
|
||||
int bvlc6_encode_result(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac,
|
||||
@@ -226,13 +226,13 @@ extern "C" {
|
||||
uint32_t * vmac,
|
||||
uint16_t * result_code);
|
||||
|
||||
int bvlc6_encode_original_unicast(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
uint32_t vmac_dst,
|
||||
uint8_t * npdu,
|
||||
uint16_t npdu_len);
|
||||
int bvlc6_encode_original_unicast(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_size,
|
||||
uint32_t vmac_src,
|
||||
uint32_t vmac_dst,
|
||||
uint8_t * npdu,
|
||||
uint16_t npdu_len);
|
||||
int bvlc6_decode_original_unicast(
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_len,
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <stdbool.h> /* for the standard bool type. */
|
||||
#include "bacdcode.h"
|
||||
#include "config.h"
|
||||
#include "device.h"
|
||||
#include "bip6.h"
|
||||
#include "net.h"
|
||||
|
||||
@@ -54,6 +55,29 @@ void bip6_set_interface(
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the BACnet IPv6 UDP port number
|
||||
*
|
||||
* @param port - IPv6 UDP port number
|
||||
*/
|
||||
void bip6_set_port(
|
||||
uint16_t port)
|
||||
{
|
||||
BIP6_Addr.port = port;
|
||||
BIP6_Broadcast_Addr.port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BACnet IPv6 UDP port number
|
||||
*
|
||||
* @return IPv6 UDP port number
|
||||
*/
|
||||
uint16_t bip6_get_port(
|
||||
void)
|
||||
{
|
||||
return BIP6_Addr.port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BACnet broadcast address for my interface.
|
||||
* Used as dest address in messages sent as BROADCAST
|
||||
@@ -298,11 +322,11 @@ bool bip6_init(
|
||||
char *ifname)
|
||||
{
|
||||
WSADATA wd;
|
||||
int i, NumSocks, RetVal, FromLen, AmountRead;
|
||||
SOCKADDR_STORAGE From;
|
||||
ADDRINFO Hints, *AddrInfo, *AI;
|
||||
int i, RetVal;
|
||||
struct addrinfo Hints, *AddrInfo, *AI;
|
||||
SOCKET ServSock[FD_SETSIZE];
|
||||
fd_set SockSet;
|
||||
char port[6] = "";
|
||||
int sockopt = 0;
|
||||
|
||||
// Ask for Winsock version 2.2.
|
||||
if ((RetVal = WSAStartup(MAKEWORD(2, 2), &wd)) != 0) {
|
||||
@@ -322,7 +346,8 @@ bool bip6_init(
|
||||
Hints.ai_family = PF_INET6;
|
||||
Hints.ai_socktype = SOCK_DGRAM;
|
||||
Hints.ai_flags = AI_NUMERICHOST | AI_PASSIVE;
|
||||
RetVal = getaddrinfo(ifname, BIP6_Addr.port, &Hints, &AddrInfo);
|
||||
snprintf(port, sizeof(port), "%u", BIP6_Addr.port);
|
||||
RetVal = getaddrinfo(ifname, &port[0], &Hints, &AddrInfo);
|
||||
if (RetVal != 0) {
|
||||
fprintf(stderr, "getaddrinfo failed with error %d: %s\n",
|
||||
RetVal, gai_strerror(RetVal));
|
||||
@@ -359,9 +384,8 @@ bool bip6_init(
|
||||
continue;
|
||||
}
|
||||
if ((AI->ai_family == PF_INET6) &&
|
||||
IN6_IS_ADDR_LINKLOCAL((IN6_ADDR *) INETADDR_ADDRESS(AI->ai_addr)) &&
|
||||
(((SOCKADDR_IN6 *) (AI->ai_addr))->sin6_scope_id == 0)
|
||||
) {
|
||||
IN6_IS_ADDR_LINKLOCAL(AI->ai_addr) &&
|
||||
(((SOCKADDR_IN6 *) (AI->ai_addr))->sin6_scope_id == 0)) {
|
||||
fprintf(stderr,
|
||||
"IPv6 link local addresses should specify a scope ID!\n");
|
||||
}
|
||||
@@ -369,7 +393,7 @@ bool bip6_init(
|
||||
/* This makes sure that the src port is correct when sending */
|
||||
sockopt = 1;
|
||||
RetVal =
|
||||
setsockopt(BIP6_Socket, SOL_SOCKET, SO_REUSEADDR, &sockopt,
|
||||
setsockopt(BIP6_Socket, SOL_SOCKET, SO_REUSEADDR, (char *)&sockopt,
|
||||
sizeof(sockopt));
|
||||
if (RetVal < 0) {
|
||||
closesocket(BIP6_Socket);
|
||||
|
||||
@@ -28,16 +28,8 @@
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define STRICT 1
|
||||
/* WindowsXP - minimum */
|
||||
#define _NTDDI_VERSION_FROM_WIN32_WINNT2(ver) ver##0000
|
||||
#define _NTDDI_VERSION_FROM_WIN32_WINNT(ver) _NTDDI_VERSION_FROM_WIN32_WINNT2(ver)
|
||||
|
||||
#ifndef _WIN32_WINNT
|
||||
# define _WIN32_WINNT 0x501
|
||||
#endif
|
||||
#ifndef NTDDI_VERSION
|
||||
# define NTDDI_VERSION _NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT)
|
||||
#endif
|
||||
/* Windows XP minimum */
|
||||
#define _WIN32_WINNT 0x501
|
||||
|
||||
#include <windows.h>
|
||||
#if (!defined(USE_INADDR) || (USE_INADDR == 0)) && \
|
||||
@@ -47,6 +39,11 @@
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#ifndef IPPROTO_IPV6
|
||||
// If the version of winsock does not by default include IPV6 then
|
||||
// use the tech preview if it is avaliable.
|
||||
#include <tpipv6.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#ifdef __MINGW32__
|
||||
|
||||
Reference in New Issue
Block a user