Add config option to select packet radio type.

This commit is contained in:
gardners 2014-10-01 09:29:16 +09:30 committed by Jeremy Lakeman
parent db5daa20ee
commit 2296196f7b
4 changed files with 38 additions and 1 deletions

View File

@ -708,6 +708,39 @@ int cf_fmt_interface_type(const char **textp, const short *typep)
return CFOK;
}
int cf_opt_radio_type(short *typep, const char *text)
{
if (strcasecmp(text, "rfd900") == 0) {
*typep = RADIO_TYPE_RFD900;
return CFOK;
}
if (strcasecmp(text, "rfm69") == 0) {
*typep = RADIO_TYPE_RFM69;
return CFOK;
}
return CFINVALID;
}
int cf_fmt_radio_type(const char **textp, const short *typep)
{
const char *t = NULL;
switch (*typep) {
case RADIO_TYPE_RFD900: t = "rfd900"; break;
case RADIO_TYPE_RFM69: t = "rfm69"; break;
}
if (!t)
return CFINVALID;
*textp = str_edup(t);
return CFOK;
}
int cf_cmp_radio_type(const short *a, const short *b)
{
return *a < *b ? -1 : *a > *b ? 1 : 0;
}
int cf_cmp_interface_type(const short *a, const short *b)
{
return *a < *b ? -1 : *a > *b ? 1 : 0;

View File

@ -458,6 +458,7 @@ ATOM(bool_t, drop_broadcasts, 0, boolean,, "If true, drop all inc
ATOM(bool_t, drop_unicasts, 0, boolean,, "If true, drop all incoming unicast packets")
ATOM(uint16_t, drop_packets, 0, uint16_nonzero,, "Percentage of incoming packets that should be dropped for testing purposes")
ATOM(short, type, OVERLAY_INTERFACE_WIFI, interface_type,, "Type of network interface")
ATOM(short, radiotype, RADIO_TYPE_RFD900, radio_type,, "Type of packet radio interface")
SUB_STRUCT(mdp_iftype, mdp,)
ATOM(bool_t, send_broadcasts, 1, boolean,, "If false, don't send any broadcast packets")
ATOM(bool_t, default_route, 0, boolean,, "If true, use this interface as a default route")

View File

@ -49,6 +49,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define OVERLAY_INTERFACE_WIFI 2
#define OVERLAY_INTERFACE_PACKETRADIO 3
#define RADIO_TYPE_RFD900 0
#define RADIO_TYPE_RFM69 1
#define OQ_ISOCHRONOUS_VOICE 0
#define OQ_MESH_MANAGEMENT 1
#define OQ_ISOCHRONOUS_VIDEO 2

View File

@ -154,7 +154,7 @@ int radio_link_free(struct overlay_interface *interface)
{
if (interface->radio_link_state){
free(interface->radio_link_state);
interface->radio_link_state=NULL;
interface->radio_link_state=NULL;
}
return 0;
}