Reply by "mir...@neacsu.net [rabbit-semi]" November 6, 20182018-11-06
Hi again Steve,

I remembered the old advice "Use the force: read the source" and looked into NET.LIB. It seems there is an option IFG_DHCP_FELLBACK:
#define IFG_DHCP_FELLBACK 395 // Get DHCP fallback status [int *]

That being said, I still believe the best option is to implement your own fallback mechanism.

Mircea
Reply by "mir...@neacsu.net [rabbit-semi]" November 6, 20182018-11-06
Hi Steve,

There is no way to find if DHCP has failed.

I don't see any merit in using the fallback mechanism implemented in BOOTP library instead of implementing your own. If DHCP fails just reconfigure the interface with a static IP and be done with it.

Cheers,

Mircea
Reply by "Ste...@yahoo.com [rabbit-semi]" November 5, 20182018-11-05
I want to use the DHCP Fallback feature in case there is no DHCP server is available. I'm workingwith an RCM6750, but I will also implement this in the RCM3900.
The only example I can find is in sample program dhcp.c, function print_results.
The function has this statement:
   if (ifconfig(iface,
         IFG_DHCP_INFO, &di,
         IFG_DHCP_OK, &dhcp_ok,
         IFG_DHCP_FELLBACK, &dhcp_fb,
         IFG_IPADDR, &myip,
         IFG_NETMASK, &mynetmask,
         IFS_END)
      || !di) {
      printf("No DHCP info obtained!\n");
      goto _exit;
   }
According to the TCP/IP User's Manual, 019-0100-E, there are no IFG_DHCP_INFO or IFG_DHCP_FELLBACK parameters.Do I have an outdated manual? How many of those DHCP parameters do I need to determine if DHCP failed? And do I need todo anything if DHCP failed? In other words, is the fallback automatic and Ethernet up and ready to go?

#yiv3149453054 #yiv3149453054 -- #yiv3149453054ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv3149453054 #yiv3149453054ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv3149453054 #yiv3149453054ygrp-mkp #yiv3149453054hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv3149453054 #yiv3149453054ygrp-mkp #yiv3149453054ads {margin-bottom:10px;}#yiv3149453054 #yiv3149453054ygrp-mkp .yiv3149453054ad {padding:0 0;}#yiv3149453054 #yiv3149453054ygrp-mkp .yiv3149453054ad p {margin:0;}#yiv3149453054 #yiv3149453054ygrp-mkp .yiv3149453054ad a {color:#0000ff;text-decoration:none;}#yiv3149453054 #yiv3149453054ygrp-sponsor #yiv3149453054ygrp-lc {font-family:Arial;}#yiv3149453054 #yiv3149453054ygrp-sponsor #yiv3149453054ygrp-lc #yiv3149453054hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv3149453054 #yiv3149453054ygrp-sponsor #yiv3149453054ygrp-lc .yiv3149453054ad {margin-bottom:10px;padding:0 0;}#yiv3149453054 #yiv3149453054actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv3149453054 #yiv3149453054activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv3149453054 #yiv3149453054activity span {font-weight:700;}#yiv3149453054 #yiv3149453054activity span:first-child {text-transform:uppercase;}#yiv3149453054 #yiv3149453054activity span a {color:#5085b6;text-decoration:none;}#yiv3149453054 #yiv3149453054activity span span {color:#ff7900;}#yiv3149453054 #yiv3149453054activity span .yiv3149453054underline {text-decoration:underline;}#yiv3149453054 .yiv3149453054attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv3149453054 .yiv3149453054attach div a {text-decoration:none;}#yiv3149453054 .yiv3149453054attach img {border:none;padding-right:5px;}#yiv3149453054 .yiv3149453054attach label {display:block;margin-bottom:5px;}#yiv3149453054 .yiv3149453054attach label a {text-decoration:none;}#yiv3149453054 blockquote {margin:0 0 0 4px;}#yiv3149453054 .yiv3149453054bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv3149453054 .yiv3149453054bold a {text-decoration:none;}#yiv3149453054 dd.yiv3149453054last p a {font-family:Verdana;font-weight:700;}#yiv3149453054 dd.yiv3149453054last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv3149453054 dd.yiv3149453054last p span.yiv3149453054yshortcuts {margin-right:0;}#yiv3149453054 div.yiv3149453054attach-table div div a {text-decoration:none;}#yiv3149453054 div.yiv3149453054attach-table {width:400px;}#yiv3149453054 div.yiv3149453054file-title a, #yiv3149453054 div.yiv3149453054file-title a:active, #yiv3149453054 div.yiv3149453054file-title a:hover, #yiv3149453054 div.yiv3149453054file-title a:visited {text-decoration:none;}#yiv3149453054 div.yiv3149453054photo-title a, #yiv3149453054 div.yiv3149453054photo-title a:active, #yiv3149453054 div.yiv3149453054photo-title a:hover, #yiv3149453054 div.yiv3149453054photo-title a:visited {text-decoration:none;}#yiv3149453054 div#yiv3149453054ygrp-mlmsg #yiv3149453054ygrp-msg p a span.yiv3149453054yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv3149453054 .yiv3149453054green {color:#628c2a;}#yiv3149453054 .yiv3149453054MsoNormal {margin:0 0 0 0;}#yiv3149453054 o {font-size:0;}#yiv3149453054 #yiv3149453054photos div {float:left;width:72px;}#yiv3149453054 #yiv3149453054photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv3149453054 #yiv3149453054photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv3149453054 #yiv3149453054reco-category {font-size:77%;}#yiv3149453054 #yiv3149453054reco-desc {font-size:77%;}#yiv3149453054 .yiv3149453054replbq {margin:4px;}#yiv3149453054 #yiv3149453054ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv3149453054 #yiv3149453054ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv3149453054 #yiv3149453054ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv3149453054 #yiv3149453054ygrp-mlmsg select, #yiv3149453054 input, #yiv3149453054 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv3149453054 #yiv3149453054ygrp-mlmsg pre, #yiv3149453054 code {font:115% monospace;}#yiv3149453054 #yiv3149453054ygrp-mlmsg * {line-height:1.22em;}#yiv3149453054 #yiv3149453054ygrp-mlmsg #yiv3149453054logo {padding-bottom:10px;}#yiv3149453054 #yiv3149453054ygrp-msg p a {font-family:Verdana;}#yiv3149453054 #yiv3149453054ygrp-msg p#yiv3149453054attach-count span {color:#1E66AE;font-weight:700;}#yiv3149453054 #yiv3149453054ygrp-reco #yiv3149453054reco-head {color:#ff7900;font-weight:700;}#yiv3149453054 #yiv3149453054ygrp-reco {margin-bottom:20px;padding:0px;}#yiv3149453054 #yiv3149453054ygrp-sponsor #yiv3149453054ov li a {font-size:130%;text-decoration:none;}#yiv3149453054 #yiv3149453054ygrp-sponsor #yiv3149453054ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv3149453054 #yiv3149453054ygrp-sponsor #yiv3149453054ov ul {margin:0;padding:0 0 0 8px;}#yiv3149453054 #yiv3149453054ygrp-text {font-family:Georgia;}#yiv3149453054 #yiv3149453054ygrp-text p {margin:0 0 1em 0;}#yiv3149453054 #yiv3149453054ygrp-text tt {font-size:120%;}#yiv3149453054 #yiv3149453054ygrp-vital ul li:last-child {border-right:none !important;}#yiv3149453054
Reply by "mir...@neacsu.net [rabbit-semi]" November 5, 20182018-11-05
Thanks for the compliment Tom but I'm just good at searching :)

Cheers,

Mircea
Reply by "Ste...@yahoo.com [rabbit-semi]" November 5, 20182018-11-05
Thanks. It was right in front of me the whole time.
Steve

From: "Tom Collins t...@tomlogic.com [rabbit-semi]"
To: r...
Sent: Monday, November 5, 2018 1:36 PM
Subject: Re: [rabbit-semi] UDP Broadcast

  Thanks Mircea for knowing the stack better than I!
So you can call udp_peek() to get a copy of the _udp_datagram_info before calling udp_recv().  You don’t need to use udp_recvfrom(), because you’ll already have the remote IP and port from that structure.
-Tom
On Nov 5, 2018, at 9:05 AM, m...@neacsu.net [rabbit-semi] wrote:
Have looked into udp_peek function:
SYNTAX:      int udp_peek(udp_Socket* s, _udp_datagram_info far * udi)

KEYWORDS:    tcpip, socket
DESCRIPTION: Look into the UDP socket receive buffer to see if there is             a datagram ready to be read using udp_recvfrom().  This             function does not remove the datagram from the buffer,             but it allows the application to determine the full             details about the next datagram, including whether the             datagram was broadcast..
             The returned data is put in *udi.  udi must point to a             valid data structure, or be NULL.  The data structure is                 typedef struct {            longword remip;    // Remote host IP address            word     remport;  // Remote host port number            int      len;      // Length of datagram            word     flags;    // Flags as follows:                 // This is an ICMP error entry                 #define UDI_ICMP_ERROR 0x0001                 // Type-of-service bit mask                 #define UDI_TOS_MASK       0x001E                 // Hardware address field is valid                 #define UDI_HWA_VALID 0x0020                 // Received on broadcast link-layer address.                        #define UDI_BROADCAST_LL 0x0040                        // Received on broadcast network (IP) address.                        #define UDI_BROADCAST_IP 0x0080                 // Received on broadcast link-layer address.                        #define UDI_MULTICAST_LL 0x0100                        // Received on broadcast network (IP) address.                        #define UDI_MULTICAST_IP 0x0200                   byte     iface;    // Interface number                   byte     hwa[6];   // Peer's hardware (Ethernet) MAC                 } _udp_datagram_info;
PARAMETER1:  UDP socket to checkPARAMETER2:  Where to store the returned information.
RETURN VALUE: 1    a normal datagram is in the receive buffer              0    no datagram waiting              -3   an ICMP error message is in the receive buffer - this                   will only be returned if udi parameter is not NULL.
Cheers,Mircea

#yiv3149453054 #yiv3149453054 -- #yiv3149453054ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv3149453054 #yiv3149453054ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv3149453054 #yiv3149453054ygrp-mkp #yiv3149453054hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv3149453054 #yiv3149453054ygrp-mkp #yiv3149453054ads {margin-bottom:10px;}#yiv3149453054 #yiv3149453054ygrp-mkp .yiv3149453054ad {padding:0 0;}#yiv3149453054 #yiv3149453054ygrp-mkp .yiv3149453054ad p {margin:0;}#yiv3149453054 #yiv3149453054ygrp-mkp .yiv3149453054ad a {color:#0000ff;text-decoration:none;}#yiv3149453054 #yiv3149453054ygrp-sponsor #yiv3149453054ygrp-lc {font-family:Arial;}#yiv3149453054 #yiv3149453054ygrp-sponsor #yiv3149453054ygrp-lc #yiv3149453054hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv3149453054 #yiv3149453054ygrp-sponsor #yiv3149453054ygrp-lc .yiv3149453054ad {margin-bottom:10px;padding:0 0;}#yiv3149453054 #yiv3149453054actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv3149453054 #yiv3149453054activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv3149453054 #yiv3149453054activity span {font-weight:700;}#yiv3149453054 #yiv3149453054activity span:first-child {text-transform:uppercase;}#yiv3149453054 #yiv3149453054activity span a {color:#5085b6;text-decoration:none;}#yiv3149453054 #yiv3149453054activity span span {color:#ff7900;}#yiv3149453054 #yiv3149453054activity span .yiv3149453054underline {text-decoration:underline;}#yiv3149453054 .yiv3149453054attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv3149453054 .yiv3149453054attach div a {text-decoration:none;}#yiv3149453054 .yiv3149453054attach img {border:none;padding-right:5px;}#yiv3149453054 .yiv3149453054attach label {display:block;margin-bottom:5px;}#yiv3149453054 .yiv3149453054attach label a {text-decoration:none;}#yiv3149453054 blockquote {margin:0 0 0 4px;}#yiv3149453054 .yiv3149453054bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv3149453054 .yiv3149453054bold a {text-decoration:none;}#yiv3149453054 dd.yiv3149453054last p a {font-family:Verdana;font-weight:700;}#yiv3149453054 dd.yiv3149453054last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv3149453054 dd.yiv3149453054last p span.yiv3149453054yshortcuts {margin-right:0;}#yiv3149453054 div.yiv3149453054attach-table div div a {text-decoration:none;}#yiv3149453054 div.yiv3149453054attach-table {width:400px;}#yiv3149453054 div.yiv3149453054file-title a, #yiv3149453054 div.yiv3149453054file-title a:active, #yiv3149453054 div.yiv3149453054file-title a:hover, #yiv3149453054 div.yiv3149453054file-title a:visited {text-decoration:none;}#yiv3149453054 div.yiv3149453054photo-title a, #yiv3149453054 div.yiv3149453054photo-title a:active, #yiv3149453054 div.yiv3149453054photo-title a:hover, #yiv3149453054 div.yiv3149453054photo-title a:visited {text-decoration:none;}#yiv3149453054 div#yiv3149453054ygrp-mlmsg #yiv3149453054ygrp-msg p a span.yiv3149453054yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv3149453054 .yiv3149453054green {color:#628c2a;}#yiv3149453054 .yiv3149453054MsoNormal {margin:0 0 0 0;}#yiv3149453054 o {font-size:0;}#yiv3149453054 #yiv3149453054photos div {float:left;width:72px;}#yiv3149453054 #yiv3149453054photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv3149453054 #yiv3149453054photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv3149453054 #yiv3149453054reco-category {font-size:77%;}#yiv3149453054 #yiv3149453054reco-desc {font-size:77%;}#yiv3149453054 .yiv3149453054replbq {margin:4px;}#yiv3149453054 #yiv3149453054ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv3149453054 #yiv3149453054ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv3149453054 #yiv3149453054ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv3149453054 #yiv3149453054ygrp-mlmsg select, #yiv3149453054 input, #yiv3149453054 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv3149453054 #yiv3149453054ygrp-mlmsg pre, #yiv3149453054 code {font:115% monospace;}#yiv3149453054 #yiv3149453054ygrp-mlmsg * {line-height:1.22em;}#yiv3149453054 #yiv3149453054ygrp-mlmsg #yiv3149453054logo {padding-bottom:10px;}#yiv3149453054 #yiv3149453054ygrp-msg p a {font-family:Verdana;}#yiv3149453054 #yiv3149453054ygrp-msg p#yiv3149453054attach-count span {color:#1E66AE;font-weight:700;}#yiv3149453054 #yiv3149453054ygrp-reco #yiv3149453054reco-head {color:#ff7900;font-weight:700;}#yiv3149453054 #yiv3149453054ygrp-reco {margin-bottom:20px;padding:0px;}#yiv3149453054 #yiv3149453054ygrp-sponsor #yiv3149453054ov li a {font-size:130%;text-decoration:none;}#yiv3149453054 #yiv3149453054ygrp-sponsor #yiv3149453054ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv3149453054 #yiv3149453054ygrp-sponsor #yiv3149453054ov ul {margin:0;padding:0 0 0 8px;}#yiv3149453054 #yiv3149453054ygrp-text {font-family:Georgia;}#yiv3149453054 #yiv3149453054ygrp-text p {margin:0 0 1em 0;}#yiv3149453054 #yiv3149453054ygrp-text tt {font-size:120%;}#yiv3149453054 #yiv3149453054ygrp-vital ul li:last-child {border-right:none !important;}#yiv3149453054
Reply by "Tom...@tomlogic.com [rabbit-semi]" November 5, 20182018-11-05
Thanks Mircea for knowing the stack better than I!

So you can call udp_peek() to get a copy of the _udp_datagram_info before calling udp_recv(). You don’t need to use udp_recvfrom(), because you’ll already have the remote IP and port from that structure.

-Tom
> On Nov 5, 2018, at 9:05 AM, m...@neacsu.net [rabbit-semi] wrote:
>
> Have looked into udp_peek function:
> SYNTAX: int udp_peek(udp_Socket* s, _udp_datagram_info far * udi)
>
> KEYWORDS: tcpip, socket
>
> DESCRIPTION: Look into the UDP socket receive buffer to see if there is
> a datagram ready to be read using udp_recvfrom(). This
> function does not remove the datagram from the buffer,
> but it allows the application to determine the full
> details about the next datagram, including whether the
> datagram was broadcast.
>
> The returned data is put in *udi. udi must point to a
> valid data structure, or be NULL. The data structure is
> typedef struct {
> longword remip; // Remote host IP address
> word remport; // Remote host port number
> int len; // Length of datagram
> word flags; // Flags as follows:
> // This is an ICMP error entry
> #define UDI_ICMP_ERROR 0x0001
> // Type-of-service bit mask
> #define UDI_TOS_MASK 0x001E
> // Hardware address field is valid
> #define UDI_HWA_VALID 0x0020
> // Received on broadcast link-layer address.
> #define UDI_BROADCAST_LL 0x0040
> // Received on broadcast network (IP) address.
> #define UDI_BROADCAST_IP 0x0080
> // Received on broadcast link-layer address.
> #define UDI_MULTICAST_LL 0x0100
> // Received on broadcast network (IP) address.
> #define UDI_MULTICAST_IP 0x0200
> byte iface; // Interface number
> byte hwa[6]; // Peer's hardware (Ethernet) MAC
> } _udp_datagram_info;
>
> PARAMETER1: UDP socket to check
> PARAMETER2: Where to store the returned information.
>
> RETURN VALUE: 1 a normal datagram is in the receive buffer
> 0 no datagram waiting
> -3 an ICMP error message is in the receive buffer - this
> will only be returned if udi parameter is not NULL.
>
> Cheers,
> Mircea
>
Reply by "Ste...@yahoo.com [rabbit-semi]" November 5, 20182018-11-05
The UDP packet returned by the UDP library provided for Netburner modules contains the source and destination IP addresses. And if the datagram was a broadcast, the destination IP address is 255.255.255.255. I don't do anything special with the packet when I send it to indicated it's a broadcast. I just set the destination IP as the broadcast IP.

From: "'Bill Auerbach' b...@softools.com [rabbit-semi]"
To: r...
Sent: Saturday, November 3, 2018 7:58 AM
Subject: Re: [rabbit-semi] UDP Broadcast

  You would have to include that as part of the UDP payload (or know from other data contained in the datagram).  The broadcast address is lost when it's mapped to every IP address that gets targeted.  Unless there's a way I've not seen but I've done a lot of broadcast and subnet-broadcast to devices and I needed to embed in the payload how it was sent.  I'd like to know this as well if it exists. :-)
------ Original Message ------From: "Steve Trigero s...@yahoo.com [rabbit-semi]" To: "r..." Sent: 11/2/2018 5:21:12 PMSubject: [rabbit-semi] UDP Broadcast

  In my R6k application I use UDP protocol. I open several socket to received datagrams from any IP.Is there a way to determine if a datagram was received as a Broadcast datagram?  Neither udp_recvfromnor udp_recv seem to provide that information. 
#yiv1532437163 #yiv1532437163 -- #yiv1532437163ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv1532437163 #yiv1532437163ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv1532437163 #yiv1532437163ygrp-mkp #yiv1532437163hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv1532437163 #yiv1532437163ygrp-mkp #yiv1532437163ads {margin-bottom:10px;}#yiv1532437163 #yiv1532437163ygrp-mkp .yiv1532437163ad {padding:0 0;}#yiv1532437163 #yiv1532437163ygrp-mkp .yiv1532437163ad p {margin:0;}#yiv1532437163 #yiv1532437163ygrp-mkp .yiv1532437163ad a {color:#0000ff;text-decoration:none;}#yiv1532437163 #yiv1532437163ygrp-sponsor #yiv1532437163ygrp-lc {font-family:Arial;}#yiv1532437163 #yiv1532437163ygrp-sponsor #yiv1532437163ygrp-lc #yiv1532437163hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv1532437163 #yiv1532437163ygrp-sponsor #yiv1532437163ygrp-lc .yiv1532437163ad {margin-bottom:10px;padding:0 0;}#yiv1532437163 #yiv1532437163actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv1532437163 #yiv1532437163activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv1532437163 #yiv1532437163activity span {font-weight:700;}#yiv1532437163 #yiv1532437163activity span:first-child {text-transform:uppercase;}#yiv1532437163 #yiv1532437163activity span a {color:#5085b6;text-decoration:none;}#yiv1532437163 #yiv1532437163activity span span {color:#ff7900;}#yiv1532437163 #yiv1532437163activity span .yiv1532437163underline {text-decoration:underline;}#yiv1532437163 .yiv1532437163attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv1532437163 .yiv1532437163attach div a {text-decoration:none;}#yiv1532437163 .yiv1532437163attach img {border:none;padding-right:5px;}#yiv1532437163 .yiv1532437163attach label {display:block;margin-bottom:5px;}#yiv1532437163 .yiv1532437163attach label a {text-decoration:none;}#yiv1532437163 blockquote {margin:0 0 0 4px;}#yiv1532437163 .yiv1532437163bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv1532437163 .yiv1532437163bold a {text-decoration:none;}#yiv1532437163 dd.yiv1532437163last p a {font-family:Verdana;font-weight:700;}#yiv1532437163 dd.yiv1532437163last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv1532437163 dd.yiv1532437163last p span.yiv1532437163yshortcuts {margin-right:0;}#yiv1532437163 div.yiv1532437163attach-table div div a {text-decoration:none;}#yiv1532437163 div.yiv1532437163attach-table {width:400px;}#yiv1532437163 div.yiv1532437163file-title a, #yiv1532437163 div.yiv1532437163file-title a:active, #yiv1532437163 div.yiv1532437163file-title a:hover, #yiv1532437163 div.yiv1532437163file-title a:visited {text-decoration:none;}#yiv1532437163 div.yiv1532437163photo-title a, #yiv1532437163 div.yiv1532437163photo-title a:active, #yiv1532437163 div.yiv1532437163photo-title a:hover, #yiv1532437163 div.yiv1532437163photo-title a:visited {text-decoration:none;}#yiv1532437163 div#yiv1532437163ygrp-mlmsg #yiv1532437163ygrp-msg p a span.yiv1532437163yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv1532437163 .yiv1532437163green {color:#628c2a;}#yiv1532437163 .yiv1532437163MsoNormal {margin:0 0 0 0;}#yiv1532437163 o {font-size:0;}#yiv1532437163 #yiv1532437163photos div {float:left;width:72px;}#yiv1532437163 #yiv1532437163photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv1532437163 #yiv1532437163photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv1532437163 #yiv1532437163reco-category {font-size:77%;}#yiv1532437163 #yiv1532437163reco-desc {font-size:77%;}#yiv1532437163 .yiv1532437163replbq {margin:4px;}#yiv1532437163 #yiv1532437163ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv1532437163 #yiv1532437163ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv1532437163 #yiv1532437163ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv1532437163 #yiv1532437163ygrp-mlmsg select, #yiv1532437163 input, #yiv1532437163 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv1532437163 #yiv1532437163ygrp-mlmsg pre, #yiv1532437163 code {font:115% monospace;}#yiv1532437163 #yiv1532437163ygrp-mlmsg * {line-height:1.22em;}#yiv1532437163 #yiv1532437163ygrp-mlmsg #yiv1532437163logo {padding-bottom:10px;}#yiv1532437163 #yiv1532437163ygrp-msg p a {font-family:Verdana;}#yiv1532437163 #yiv1532437163ygrp-msg p#yiv1532437163attach-count span {color:#1E66AE;font-weight:700;}#yiv1532437163 #yiv1532437163ygrp-reco #yiv1532437163reco-head {color:#ff7900;font-weight:700;}#yiv1532437163 #yiv1532437163ygrp-reco {margin-bottom:20px;padding:0px;}#yiv1532437163 #yiv1532437163ygrp-sponsor #yiv1532437163ov li a {font-size:130%;text-decoration:none;}#yiv1532437163 #yiv1532437163ygrp-sponsor #yiv1532437163ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv1532437163 #yiv1532437163ygrp-sponsor #yiv1532437163ov ul {margin:0;padding:0 0 0 8px;}#yiv1532437163 #yiv1532437163ygrp-text {font-family:Georgia;}#yiv1532437163 #yiv1532437163ygrp-text p {margin:0 0 1em 0;}#yiv1532437163 #yiv1532437163ygrp-text tt {font-size:120%;}#yiv1532437163 #yiv1532437163ygrp-vital ul li:last-child {border-right:none !important;}#yiv1532437163
Reply by "mir...@neacsu.net [rabbit-semi]" November 5, 20182018-11-05
Have looked into udp_peek function:
SYNTAX: int udp_peek(udp_Socket* s, _udp_datagram_info far * udi)

KEYWORDS: tcpip, socket

DESCRIPTION: Look into the UDP socket receive buffer to see if there is
a datagram ready to be read using udp_recvfrom(). This
function does not remove the datagram from the buffer,
but it allows the application to determine the full
details about the next datagram, including whether the
datagram was broadcast.

The returned data is put in *udi. udi must point to a
valid data structure, or be NULL. The data structure is
typedef struct {
longword remip; // Remote host IP address
word remport; // Remote host port number
int len; // Length of datagram
word flags; // Flags as follows:
// This is an ICMP error entry
#define UDI_ICMP_ERROR 0x0001
// Type-of-service bit mask
#define UDI_TOS_MASK 0x001E
// Hardware address field is valid
#define UDI_HWA_VALID 0x0020
// Received on broadcast link-layer address.
#define UDI_BROADCAST_LL 0x0040
// Received on broadcast network (IP) address.
#define UDI_BROADCAST_IP 0x0080
// Received on broadcast link-layer address.
#define UDI_MULTICAST_LL 0x0100
// Received on broadcast network (IP) address.
#define UDI_MULTICAST_IP 0x0200
byte iface; // Interface number
byte hwa[6]; // Peer's hardware (Ethernet) MAC
} _udp_datagram_info;

PARAMETER1: UDP socket to check
PARAMETER2: Where to store the returned information.

RETURN VALUE: 1 a normal datagram is in the receive buffer
0 no datagram waiting
-3 an ICMP error message is in the receive buffer - this
will only be returned if udi parameter is not NULL.

Cheers,
Mircea
Reply by "Tom...@tomlogic.com [rabbit-semi]" November 5, 20182018-11-05
Steve,

Sorry for not chiming in earlier.

I can confirm that udp_recvfrom() doesn’t return that information, and udp_recv() is just a macro wrapper for udp_recvfrom().

It should not be difficult to add this capability, though:

* Refactor the core of udp_recvfrom() to take a pointer to a _udp_datagram_info structure instead of remote IP and port.
* udp_recvfrom() is now a wrapper that calls the new function, and copies remote IP and port out of that structure.
* Expose the new API for use in your program, where you reference the “flags” entry of the structure to identify whether it’s unicast, broadcast or multicast.
* Open a pull request on Github with your awesome work and have me merge it for others to use. ;-)

Contact me directly if you have questions on how to do that.

-Tom
> On Nov 5, 2018, at 8:23 AM, Steve Trigero s...@yahoo.com [rabbit-semi] wrote:
> The UDP packet returned by the UDP library provided for Netburner modules contains the
> source and destination IP addresses. And if the datagram was a broadcast, the destination IP
> address is 255.255.255.255. I don't do anything special with the packet when I send it to
> indicated it's a broadcast. I just set the destination IP as the broadcast IP.
> From: "'Bill Auerbach' b...@softools.com [rabbit-semi]" >
> To: r...
> Sent: Saturday, November 3, 2018 7:58 AM
> Subject: Re: [rabbit-semi] UDP Broadcast
>
>
> You would have to include that as part of the UDP payload (or know from other data contained in the datagram). The broadcast address is lost when it's mapped to every IP address that gets targeted. Unless there's a way I've not seen but I've done a lot of broadcast and subnet-broadcast to devices and I needed to embed in the payload how it was sent. I'd like to know this as well if it exists. :-)
>
> ------ Original Message ------
> From: "Steve Trigero s...@yahoo.com [rabbit-semi]" >
> To: "r... " >
> Sent: 11/2/2018 5:21:12 PM
> Subject: [rabbit-semi] UDP Broadcast
>
>>
>> In my R6k application I use UDP protocol. I open several socket to received datagrams from any IP.
>> Is there a way to determine if a datagram was received as a Broadcast datagram? Neither udp_recvfrom
>> nor udp_recv seem to provide that information.
>
Reply by "'Bi...@softools.com [rabbit-semi]" November 3, 20182018-11-03
You would have to include that as part of the UDP payload (or know from
other data contained in the datagram). The broadcast address is lost
when it's mapped to every IP address that gets targeted. Unless there's
a way I've not seen but I've done a lot of broadcast and
subnet-broadcast to devices and I needed to embed in the payload how it
was sent. I'd like to know this as well if it exists. :-)

------ Original Message ------
From: "Steve Trigero s...@yahoo.com [rabbit-semi]"

To: "r..."
Sent: 11/2/2018 5:21:12 PM
Subject: [rabbit-semi] UDP Broadcast

>In my R6k application I use UDP protocol. I open several socket to
>received datagrams from any IP.
>Is there a way to determine if a datagram was received as a Broadcast
>datagram? Neither udp_recvfrom
>nor udp_recv seem to provide that information.
>