compiles!

This commit is contained in:
skarg
2005-03-16 19:47:16 +00:00
parent b4878c303a
commit c62d283ec4
2 changed files with 31 additions and 30 deletions
+8 -17
View File
@@ -37,22 +37,16 @@
#include <errno.h> /* Error number and related */ #include <errno.h> /* Error number and related */
#include <stdint.h> // for standard integer types uint8_t etc. #include <stdint.h> // for standard integer types uint8_t etc.
#include <stdbool.h> // for the standard bool type. #include <stdbool.h> // for the standard bool type.
//#include <sys/time.h> /* System time values */ #include <sys/types.h> /* System data types */
//#include <sys/types.h> /* System data types */ #include <unistd.h> /* Command-line options */
//#include <sys/stat.h> /* File statistics */ #include <string.h> /* string hanfling functions */
//#include <unistd.h> /* Command-line options */
//#include <fcntl.h> /* FD-based file-control */
//#include <string.h> /* string hanfling functions */
//#include <signal.h> /* signal handling functions */
//#include <time.h> /* time functions */
//#include <stdarg.h>
#define ENUMS #define ENUMS
#include <sys/socket.h> #include <sys/socket.h>
//#include <net/route.h> #include <net/route.h>
//#include <net/if.h> #include <net/if.h>
//#include <features.h> /* for the glibc version number */
#include <features.h> /* for the glibc version number */
#if __GLIBC__ >= 2 && __GLIBC_MINOR >= 1 #if __GLIBC__ >= 2 && __GLIBC_MINOR >= 1
#include <netpacket/packet.h> #include <netpacket/packet.h>
#include <net/ethernet.h> /* the L2 protocols */ #include <net/ethernet.h> /* the L2 protocols */
@@ -61,11 +55,8 @@
#include <linux/if_packet.h> #include <linux/if_packet.h>
#include <linux/if_ether.h> /* The L2 protocols */ #include <linux/if_ether.h> /* The L2 protocols */
#endif #endif
//#include <netinet/in.h> #include <netinet/in.h>
//#include <arpa/inet.h> #include <sys/ioctl.h>
//#include <sys/un.h>
//#include <sys/ioctl.h>
//#include <netdb.h>
#include "bacdef.h" #include "bacdef.h"
#include "ethernet.h" #include "ethernet.h"
+23 -13
View File
@@ -35,6 +35,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h>
#include "bacdef.h" #include "bacdef.h"
#include "npdu.h" #include "npdu.h"
#include "iam.h" #include "iam.h"
@@ -55,10 +56,11 @@ bool I_Am_Request = true;
// services are supported and what services are rejected // services are supported and what services are rejected
void Process_APDU( void Process_APDU(
BACNET_ADDRESS *src, // source address BACNET_ADDRESS *src, // source address
bool data_expecting_reply,
uint8_t *apdu, // APDU data uint8_t *apdu, // APDU data
uint16_t pdu_len, // length of the PDU uint16_t pdu_len) // for confirmed messages
uint8_t invoke_id) // for confirmed messages
{ {
uint8_t invoke_id = 0;
} }
@@ -67,19 +69,27 @@ void Process_PDU(
uint8_t *pdu, // PDU data uint8_t *pdu, // PDU data
uint16_t pdu_len) // length PDU uint16_t pdu_len) // length PDU
{ {
uint8_t invoke_id = 0;
int apdu_offset = 0; int apdu_offset = 0;
BACNET_ADDRESS dest = {0};
BACNET_NPDU_DATA npdu_data = {0};
apdu_offset = npdu_decode( apdu_offset = npdu_decode(
&src, // source address - get the SADR/SNET if in there &pdu[0], // data to decode
&pdu[0], &dest, // destination address - get the DNET/DLEN/DADR if in there
pdu_len src, // source address - get the SNET/SLEN/SADR if in there
&invoke_id); &npdu_data); // amount of data to decode
Process_APDU( if (npdu_data.network_layer_message)
&src, {
&pdu[apdu_offset], fprintf(stderr,"main: network layer message received!");
pdu_len - apdu_offset, }
invoke_id); else
{
Process_APDU(
src,
npdu_data.data_expecting_reply,
&pdu[apdu_offset],
pdu_len - apdu_offset);
}
return; return;
} }
@@ -117,7 +127,7 @@ void Send_IAm(void)
pdu_len); // number of bytes of data pdu_len); // number of bytes of data
} }
int main(void) int main(int argc, char *argv[])
{ {
BACNET_ADDRESS src = {0}; // address where message came from BACNET_ADDRESS src = {0}; // address where message came from
uint16_t pdu_len = 0; uint16_t pdu_len = 0;