Updated output of whois demo. Began implementing the datalink-all concept.
This commit is contained in:
@@ -110,6 +110,13 @@ int main(
|
||||
/* allow the device ID to be set */
|
||||
if (argc > 1)
|
||||
Device_Set_Object_Instance_Number(strtol(argv[1], NULL, 0));
|
||||
#if defined(BACDL_ALL)
|
||||
pEnv = getenv("BACNET_DATALINK");
|
||||
if (pEnv) {
|
||||
datalink_set(pEnv));
|
||||
} else {
|
||||
datalink_set("bip");
|
||||
#endif
|
||||
#if defined(BACDL_BIP)
|
||||
pEnv = getenv("BACNET_IP_PORT");
|
||||
if (pEnv) {
|
||||
|
||||
@@ -109,16 +109,32 @@ static void print_address_cache(
|
||||
uint32_t device_id = 0;
|
||||
unsigned max_apdu = 0;
|
||||
|
||||
fprintf(stderr, "Device\tMAC\tMaxAPDU\tNet\n");
|
||||
printf("%-7s %-14s %-4s %-5s %-14s\n",
|
||||
"Device","MAC","APDU","SNET","SADR");
|
||||
printf("------- -------------- ---- ----- --------------\n");
|
||||
for (i = 0; i < MAX_ADDRESS_CACHE; i++) {
|
||||
if (address_get_by_index(i, &device_id, &max_apdu, &address)) {
|
||||
fprintf(stderr, "%u\t", device_id);
|
||||
for (j = 0; j < address.mac_len; j++) {
|
||||
fprintf(stderr, "%02X", address.mac[j]);
|
||||
printf("%7u ", device_id);
|
||||
for (j = 0; j < 7; j++) {
|
||||
if (j < address.mac_len) {
|
||||
printf("%02X", address.mac[j]);
|
||||
} else {
|
||||
printf(" ");
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\t");
|
||||
fprintf(stderr, "%hu\t", max_apdu);
|
||||
fprintf(stderr, "%hu\n", address.net);
|
||||
printf(" %4hu ", max_apdu);
|
||||
printf("%5hu ", address.net);
|
||||
if (address.net) {
|
||||
for (j = 0; j < 7; j++) {
|
||||
if (j < address.len) {
|
||||
printf("%02X", address.adr[j]);
|
||||
} else {
|
||||
printf(" ");
|
||||
}
|
||||
printf(" ");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
/* declare a single physical layer using your compiler define.
|
||||
see datalink.h for possible defines. */
|
||||
#if !(defined(BACDL_ETHERNET) || defined(BACDL_ARCNET) || defined(BACDL_MSTP) || defined(BACDL_BIP) || defined(BACDL_TEST))
|
||||
#if !(defined(BACDL_ETHERNET) || defined(BACDL_ARCNET) || defined(BACDL_MSTP) || defined(BACDL_BIP) || defined(BACDL_TEST) || defined(BACDL_ALL))
|
||||
#define BACDL_BIP
|
||||
#endif
|
||||
|
||||
/* optional debug info for BACnet/IP datalink layers */
|
||||
#if defined(BACDL_BIP)
|
||||
#if (defined(BACDL_BIP) || defined(BACDL_ALL))
|
||||
#if !defined(USE_INADDR)
|
||||
#define USE_INADDR 1
|
||||
#endif
|
||||
|
||||
@@ -87,7 +87,10 @@
|
||||
#else
|
||||
#include "npdu.h"
|
||||
|
||||
extern int datalink_send_pdu(
|
||||
#define MAX_HEADER (8)
|
||||
#define MAX_MPDU (MAX_HEADER+MAX_PDU)
|
||||
|
||||
int datalink_send_pdu(
|
||||
BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * npdu_data,
|
||||
uint8_t * pdu,
|
||||
@@ -105,7 +108,8 @@ extern void datalink_get_my_address(
|
||||
BACNET_ADDRESS * my_address);
|
||||
extern void datalink_set_interface(
|
||||
char *ifname);
|
||||
|
||||
extern void datalink_set(
|
||||
char *datalink_string);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+35
-32
@@ -32,7 +32,9 @@
|
||||
-------------------------------------------
|
||||
####COPYRIGHTEND####*/
|
||||
#include "datalink.h"
|
||||
#include <string.h>
|
||||
|
||||
#if defined(BACDL_ALL)
|
||||
/* Function pointers - point to your datalink */
|
||||
bool(*datalink_init) (char *ifname);
|
||||
|
||||
@@ -58,37 +60,38 @@ void (
|
||||
*datalink_get_my_address) (
|
||||
BACNET_ADDRESS * my_address);
|
||||
|
||||
void datalink_configure(
|
||||
void)
|
||||
void datalink_set(
|
||||
char *datalink_string)
|
||||
{
|
||||
#if defined(BACDL_ETHERNET)
|
||||
datalink_init = ethernet_init;
|
||||
datalink_send_pdu = ethernet_send_pdu;
|
||||
datalink_receive = ethernet_receive;
|
||||
datalink_cleanup = ethernet_cleanup;
|
||||
datalink_get_broadcast_address = ethernet_get_broadcast_address;
|
||||
datalink_get_my_address = ethernet_get_my_address;
|
||||
#elif defined(BACDL_ARCNET)
|
||||
datalink_init = arcnet_init;
|
||||
datalink_send_pdu = arcnet_send_pdu;
|
||||
datalink_receive = arcnet_receive;
|
||||
datalink_cleanup = arcnet_cleanup;
|
||||
datalink_get_broadcast_address = arcnet_get_broadcast_address;
|
||||
datalink_get_my_address = arcnet_get_my_address;
|
||||
#elif defined(BACDL_MSTP)
|
||||
datalink_init = dlmstp_init;
|
||||
datalink_send_pdu = dlmstp_send_pdu;
|
||||
datalink_receive = dlmstp_receive;
|
||||
datalink_cleanup = dlmstp_cleanup;
|
||||
datalink_get_broadcast_address = dlmstp_get_broadcast_address;
|
||||
datalink_get_my_address = dlmstp_get_my_address;
|
||||
#elif defined(BACDL_BIP)
|
||||
datalink_init = bip_init;
|
||||
datalink_send_pdu = bip_send_pdu;
|
||||
datalink_receive = bip_receive;
|
||||
datalink_cleanup = bip_cleanup;
|
||||
datalink_get_broadcast_address = bip_get_broadcast_address;
|
||||
datalink_get_my_address = bip_get_my_address;
|
||||
if (strcasecmp("bip",datalink_string) == 0) {
|
||||
datalink_init = bip_init;
|
||||
datalink_send_pdu = bip_send_pdu;
|
||||
datalink_receive = bip_receive;
|
||||
datalink_cleanup = bip_cleanup;
|
||||
datalink_get_broadcast_address = bip_get_broadcast_address;
|
||||
datalink_get_my_address = bip_get_my_address;
|
||||
} else if (strcasecmp("ethernet",datalink_string) == 0) {
|
||||
datalink_init = ethernet_init;
|
||||
datalink_send_pdu = ethernet_send_pdu;
|
||||
datalink_receive = ethernet_receive;
|
||||
datalink_cleanup = ethernet_cleanup;
|
||||
datalink_get_broadcast_address = ethernet_get_broadcast_address;
|
||||
datalink_get_my_address = ethernet_get_my_address;
|
||||
} else if (strcasecmp("arcnet",datalink_string) == 0) {
|
||||
datalink_init = arcnet_init;
|
||||
datalink_send_pdu = arcnet_send_pdu;
|
||||
datalink_receive = arcnet_receive;
|
||||
datalink_cleanup = arcnet_cleanup;
|
||||
datalink_get_broadcast_address = arcnet_get_broadcast_address;
|
||||
datalink_get_my_address = arcnet_get_my_address;
|
||||
} else if (strcasecmp("mstp",datalink_string) == 0) {
|
||||
datalink_init = dlmstp_init;
|
||||
datalink_send_pdu = dlmstp_send_pdu;
|
||||
datalink_receive = dlmstp_receive;
|
||||
datalink_cleanup = dlmstp_cleanup;
|
||||
datalink_get_broadcast_address = dlmstp_get_broadcast_address;
|
||||
datalink_get_my_address = dlmstp_get_my_address;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user