6 #include "meshlink++.h"
11 // Open a new meshlink instance.
14 mesh.open("basicpp_conf", "foo", "basicpp", DEV_CLASS_BACKBONE);
16 // Check that our own node exists.
18 meshlink::node *self = mesh.get_self();
20 cerr << "Foo does not know about itself\n";
23 if(strcmp(self->name, "foo")) {
24 cerr << "Foo thinks its name is " << self->name << "\n";
28 // Disable local discovery.
30 mesh.enable_discovery(false);
32 // Start and stop the mesh.
35 cerr << "Foo could not start\n";
40 // Make sure we can start and stop the mesh again.
43 cerr << "Foo could not start twice\n";
48 // Close the mesh and open it again, now with a different name parameter.
52 // Check that the name is ignored now, and that we still are "foo".
54 mesh.open("basicpp_conf", "bar", "basicpp", DEV_CLASS_BACKBONE);
56 if(mesh.get_node("bar")) {
57 cerr << "Foo knows about bar, it shouldn't\n";
61 self = mesh.get_self();
63 cerr << "Foo doesn't know about itself the second time\n";
66 if(strcmp(self->name, "foo")) {
67 cerr << "Foo thinks its name is " << self->name << " the second time\n";
71 // Start and stop the mesh.
73 mesh.enable_discovery(false);
76 cerr << "Foo could not start a third time\n";
82 if(!meshlink::destroy("basicpp_conf")) {
83 cerr << "Could not destroy configuration\n";
87 if(!access("basic.conf", F_OK) || errno != ENOENT) {
88 cerr << "Configuration not fully destroyed\n";