Added handling for ARCNET on the Linux port.

This commit is contained in:
skarg
2005-09-06 20:41:01 +00:00
parent 7368ba24f6
commit 4ba79baf1e
8 changed files with 77 additions and 13 deletions
+2 -2
View File
@@ -7,9 +7,9 @@ BASEDIR = .
# Note: you can strip out symbols using the strip command
# to get an idea of how big the compile really is.
#CFLAGS = -Wall -I. -Iports/linux -g -DBACDL_ETHERNET=1
CFLAGS = -Wall -I. -Iports/linux -g -DBACDL_ARCNET=1
#CFLAGS = -Wall -I. -Iports/linux -g -DBACDL_ARCNET=1
#CFLAGS = -Wall -I. -Iports/linux -g -DBACDL_MSTP=1
#CFLAGS = -Wall -I. -Iports/linux -g -DBACDL_BIP=1
CFLAGS = -Wall -I. -Iports/linux -g -DBACDL_BIP=1
SRCS = ports/linux/main.c \
ports/linux/ethernet.c \
+1 -1
View File
@@ -47,7 +47,7 @@ typedef struct
static BACNET_FILE_LISTING BACnet_File_Listing[] =
{
{0, "temp.txt"},
{0, "test.log"},
{1, "script.txt"},
{0, NULL} // last file indication
};
+1 -1
View File
@@ -94,7 +94,7 @@ void bip_set_broadcast_addr(uint32_t net_address);
// returns host byte order
uint32_t bip_get_broadcast_addr(void);
void bip_set_interface_name(char *ifname);
void bip_set_interface(char *ifname);
#ifdef __cplusplus
}
+2 -2
View File
@@ -11,8 +11,8 @@
// This is used in constructing messages and to tell others our limits
// 50 is the minimum; adjust to your memory and physical layer constraints
// Lon=206, MS/TP=480, ARCNET=480, Ethernet=1476
#define MAX_APDU 50
//#define MAX_APDU 480
//#define MAX_APDU 50
#define MAX_APDU 480
//#define MAX_APDU 1476
// for confirmed messages, this is the number of transactions
+16
View File
@@ -109,6 +109,22 @@ uint16_t datalink_receive(
#endif
}
void datalink_cleanup(void)
{
#ifdef BACDL_ETHERNET
ethernet_cleanup();
#endif
#ifdef BACDL_BIP
bip_cleanup();
#endif
#ifdef BACDL_ARCNET
arcnet_cleanup();
#endif
#ifdef BACDL_MSTP
dlmstp_cleanup();
#endif
}
void datalink_get_broadcast_address(
BACNET_ADDRESS *dest) // destination address
{
+2
View File
@@ -72,6 +72,8 @@ uint16_t datalink_receive(
uint16_t max_pdu, // amount of space available in the PDU
unsigned timeout); // number of milliseconds to wait for a packet
void datalink_cleanup(void);
void datalink_get_broadcast_address(
BACNET_ADDRESS *dest); // destination address
+48
View File
@@ -38,6 +38,54 @@
#include "bip.h"
#include "net.h"
static int get_local_ifr_ioctl(char *ifname, struct ifreq *ifr, int request)
{
int fd;
int rv; // return value
strncpy(ifr->ifr_name, ifname, sizeof(ifr->ifr_name));
fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
if (fd < 0)
rv = fd;
else
rv = ioctl(fd, request, ifr);
return rv;
}
static int get_local_address_ioctl(
char *ifname,
struct in_addr *addr,
int request)
{
struct ifreq ifr = { {{0}} };
struct sockaddr_in *tcpip_address;
int rv; // return value
rv = get_local_ifr_ioctl(ifname,&ifr,request);
if (rv >= 0) {
tcpip_address = (struct sockaddr_in *) &ifr.ifr_addr;
memcpy(addr, &tcpip_address->sin_addr, sizeof(struct in_addr));
}
return rv;
}
void bip_set_interface(char *ifname)
{
struct in_addr local_address;
struct in_addr broadcast_address;
/* setup local address */
get_local_address_ioctl(ifname, &local_address, SIOCGIFADDR);
bip_set_addr(local_address.s_addr);
fprintf(stderr,"IP Address: %s\n",inet_ntoa(local_address));
/* setup local broadcast address */
get_local_address_ioctl(ifname, &broadcast_address, SIOCGIFBRDADDR);
bip_set_broadcast_addr(broadcast_address.s_addr);
fprintf(stderr,"Broadcast Address: %s\n",inet_ntoa(broadcast_address));
}
bool bip_init(void)
{
int status = 0; // return from socket lib calls
+5 -7
View File
@@ -204,13 +204,7 @@ static void print_address_cache(void)
static void sig_handler(int signo)
{
#ifdef BACDL_ETHERNET
ethernet_cleanup();
#endif
#ifdef BACDL_BIP
bip_cleanup();
#endif
datalink_cleanup();
print_address_cache();
exit(0);
@@ -244,6 +238,10 @@ int main(int argc, char *argv[])
if (!bip_init())
return 1;
#endif
#ifdef BACDL_ARCNET
if (!arcnet_init("arc0"))
return 1;
#endif
// loop forever
for (;;)