From 7287a2d59983d91affec527e02aba507eccfb22e Mon Sep 17 00:00:00 2001 From: gardners Date: Tue, 5 Feb 2013 06:19:48 +1030 Subject: [PATCH] add hook for transmitting packet via packet radio interface. make serial port non-blocking (which for some reason has also killed our ability to read from it :/). --- overlay_interface.c | 4 +++- overlay_packetradio.c | 12 ++++++++++++ serval.h | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/overlay_interface.c b/overlay_interface.c index 83001591..6a144572 100644 --- a/overlay_interface.c +++ b/overlay_interface.c @@ -670,7 +670,9 @@ overlay_broadcast_ensemble(int interface_number, return WHYF("Cannot send to interface %s as it is down", interface->name); } - if (interface->fileP) + if (interface->type==OVERLAY_INTERFACE_PACKETRADIO) { + return overlay_packetradio_tx_packet(interface_number,recipientaddr,bytes,len); + } else if (interface->fileP) { struct dummy_packet packet={ diff --git a/overlay_packetradio.c b/overlay_packetradio.c index 19887683..e2b34880 100644 --- a/overlay_packetradio.c +++ b/overlay_packetradio.c @@ -16,6 +16,9 @@ int overlay_packetradio_setup_port(overlay_interface *interface) { struct termios t; + + set_nonblock(interface->alarm.poll.fd); + tcgetattr(interface->alarm.poll.fd, &t); // XXX Speed and options should be configurable cfsetispeed(&t, B57600); @@ -40,6 +43,7 @@ int overlay_packetradio_setup_port(overlay_interface *interface) t.c_oflag &= ~OPOST; tcsetattr(interface->alarm.poll.fd, TCSANOW, &t); + return 0; } @@ -166,3 +170,11 @@ void overlay_packetradio_poll(struct sched_ent *alarm) return ; } +int overlay_packetradio_tx_packet(int interface_number, + struct sockaddr_in *recipientaddr, + unsigned char *bytes,int len) +{ + if (config.debug.packetradio) DEBUGF("Sending packet of %d bytes",len); + return 0; +} + diff --git a/serval.h b/serval.h index 2eaa2fe8..22bace12 100644 --- a/serval.h +++ b/serval.h @@ -753,6 +753,9 @@ int fd_poll(); void overlay_interface_discover(struct sched_ent *alarm); void overlay_packetradio_poll(struct sched_ent *alarm); int overlay_packetradio_setup_port(overlay_interface *interface); +int overlay_packetradio_tx_packet(int interface_number, + struct sockaddr_in *recipientaddr, + unsigned char *bytes,int len); void overlay_dummy_poll(struct sched_ent *alarm); void overlay_route_tick(struct sched_ent *alarm); void server_config_reload(struct sched_ent *alarm);