Skip to content
Snippets Groups Projects
Commit 65086f12 authored by clohr's avatar clohr
Browse files

Préparation de la v0.5r2

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/C/trunk@1584 b32b6428-25c9-4566-ad07-03861ab6144f
parent 063f2c92
Branches
No related tags found
No related merge requests found
......@@ -89,6 +89,7 @@ const char *add_device(devices_t *devices, char button, const char *addr,
device->devinfo.vendorId = "IHSEV";
device->devinfo.version = "0.4";
device->devinfo.url = "http://recherche.telecom-bretagne.eu/xaal/documentation/";
device->devinfo.info = NULL;
device->devinfo.unsupportedAttributes = NULL;
device->devinfo.unsupportedMethods = NULL;
device->devinfo.unsupportedNotifications = NULL;
......
......
/*
* Modified version of the xAAL library
* xAAL_read_bus() is modified to return actual message size and sender's IP
*/
/* libxaal
* A minimal xAAL library, with security
*
......@@ -172,7 +167,7 @@ bool xAAL_add_wanted_target(const char *addr, xAAL_businfo_t *bus) {
if ( uuid_parse(addr, uuid) == -1 )
return false;
if ( retrieve_uuid(bus->wanted_targets_nb, bus->wanted_targets, uuid) == -1 )
if ( retrieve_uuid(bus->wanted_targets_nb, bus->wanted_targets, uuid) != -1 )
return true;
bus->wanted_targets = realloc(bus->wanted_targets,
......@@ -205,10 +200,14 @@ bool xAAL_del_wanted_target(const char *addr, xAAL_businfo_t *bus) {
static bool wanted_match(struct json_object *jtargets,
unsigned sz, uuid_t *list) {
int i, len = json_object_array_length(jtargets);
int i, len;
struct json_object *jtarget;
uuid_t uu;
if ( !json_object_is_type(jtargets, json_type_array) )
return true;
len = json_object_array_length(jtargets);
if (len == 0 || sz == 0)
return true;
......@@ -386,6 +385,13 @@ bool xAAL_read_bus(const xAAL_businfo_t *bus,
json_object_put(jmsg);
return false;
}
if ( !json_object_is_type(*jtargets, json_type_array) ) {
if (xAAL_error_log) fprintf(xAAL_error_log, "Invalid 'targets' in xAAL message\n");
json_object_put(*jtargets);
json_object_put(jmsg);
return false;
}
} else
*jtargets = json_object_new_array();
......
......
......@@ -1074,6 +1074,7 @@ int main(int argc, char **argv) {
me.version = "0.5";
me.groupId = NULL;
me.url = "http://recherche.telecom-bretagne.eu/xaal/documentation/";
me.info = NULL;
me.unsupportedAttributes = NULL;
me.unsupportedMethods = NULL;
me.unsupportedNotifications = NULL;
......
......
......@@ -645,6 +645,7 @@ void init_xaagent(options_t *options, xAAL_businfo_t *bus, xAAL_devinfo_t *me, i
me->version = "0.1";
me->groupId = NULL;
me->url = "http://recherche.telecom-bretagne.eu/xaal/documentation/";
me->info = NULL;
me->unsupportedAttributes = NULL;
me->unsupportedMethods = NULL;
me->unsupportedNotifications = NULL;
......
......
......@@ -13,6 +13,7 @@
#include <syslog.h>
#include <sys/time.h>
#include <unistd.h>
#include <netdb.h>
#include <libwebsockets.h>
......@@ -59,6 +60,15 @@ void emit_log(int level, const char *line) {
}
int service_port(const char *name) {
struct servent *serv = getservbyname(name, NULL);
if (serv)
return serv->s_port;
else
return atoi(name);
}
int main(int argc, char **argv) {
struct lws_context_creation_info info;
options_t options = { .addr=NULL, .port=NULL, .hops=-1, .passphrase=NULL,
......@@ -118,7 +128,7 @@ int main(int argc, char **argv) {
count_pollfds = 3;
memset(&info, 0, sizeof info);
info.port = atoi(options.http_port);//why not a service name?
info.port = service_port(options.http_port);
info.iface = options.http_iface;
info.protocols = protocols;
info.gid = options.gid;
......@@ -141,11 +151,6 @@ int main(int argc, char **argv) {
int n = 0;
while (n >= 0 && !force_exit) {
/*
* this represents an existing server's single poll action
* which also includes libwebsocket sockets
*/
n = poll(pollfds, count_pollfds, 50);
if (n < 0)
continue;
......@@ -159,13 +164,13 @@ int main(int argc, char **argv) {
} else if ( (pollfds[n].fd == alive_fd) && (pollfds[n].revents & POLLIN) ) {
if ( read(alive_fd, &exp, sizeof(uint64_t)) == -1 )
lwsl_err("Alive timer\n");
lwsl_err("Error on Alive timer\n");
if ( !xAAL_notify_alive(&bus, &me) )
lwsl_err("Could not send alive notification.\n");
} else if ( (pollfds[n].fd == checking_fd) && (pollfds[n].revents & POLLIN) ) {
if ( read(checking_fd, &exp, sizeof(uint64_t)) == -1 )
lwsl_err("Checking timer\n");
lwsl_err("Error on Checking timer\n");
callback_checking(&bus, &me, &db);
} else {
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment