Re: [Bacnet-developers] [Update] Activating BVLC code
Brought to you by:
skarg
|
From: <tom...@sw...> - 2008-01-15 18:32:48
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
this is a short refresh of the last things. Now readprop is working as
well. I had to address just two small glitches in bvlc.c.
First, on an incoming "forwarded message" (typically a forwarded I-Am),
we have to pick up the "real" IP address/port number from the BVLC header:
=========================================================================
- --- a/src/bvlc.c
+++ b/src/bvlc.c
@@ -943,9 +943,13 @@ uint16_t bvlc_receive(
bvlc_send_mpdu(&dest, &npdu[4], npdu_len);
}
bvlc_fdt_forward_npdu(&sin, &npdu[4], npdu_len);
- - /* FIXME we might want to do something with tne MAC provided
- - in the BVLC header
- - */
+ /* Extract the "real" source from the BVLC header */
+ for(i=0; i<6; i++) {
+ src->mac[i] = npdu[i+4];
+ }
+ src->mac_len = 6;
+ src->net = 0;
+ src->len = 0;
if (npdu_len < max_npdu) {
/* shift the buffer to return a valid PDU */
for (i = 0; i < npdu_len; i++) {
=========================================================================
Then, there was some endianness issue here. I dared to use
bvlc_decode_bip_address() instead of duplicating the code, hope that's
OK:
=========================================================================
@@ -1111,9 +1115,9 @@ int bvlc_send_pdu(
mtu[1] = BVLC_ORIGINAL_BROADCAST_NPDU;
} else if (dest->mac_len == 6) {
/* valid unicast */
- - (void) decode_unsigned32(&dest->mac[0], &raw_address);
- - bvlc_dest.sin_addr.s_addr = raw_address;
- - (void) decode_unsigned16(&dest->mac[4], &(bvlc_dest.sin_port));
+ bvlc_decode_bip_address(&dest->mac[0], &address, &port);
+ bvlc_dest.sin_addr.s_addr = htonl(address);
+ bvlc_dest.sin_port = htons(port);
memset(&(bvlc_dest.sin_zero), '\0', 8);
mtu[1] = BVLC_ORIGINAL_UNICAST_NPDU;
} else {
=========================================================================
I didn't test it (it's a live installation, so I'd have to get
permission first!), but I'd assume that write prop will work too.
Ill try to cook up tomorrow a series of patches along the lines sketched
in my last emails. Hopefully I get the patch format right :-)
Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFHjPrZBcgs9XrR2kYRAqtmAJwKXawKgRSNZeH0mqu45AuJ93WI9QCeLy5N
LC4Kz1pkeAPIhyu1vJuMPsQ=
=p/qn
-----END PGP SIGNATURE-----
|