olsrd.h File Reference

OLSRd configuration and process management. More...

#include <stdlib.h>
#include "process.h"
#include "util.h"
#include "obj.h"

Go to the source code of this file.

Classes

struct  co_olsrd_process_t
 contains the OLSRd process protocol More...
 
struct  co_olsrd_conf_item_t
 contains the key and value for configuring OLSRd for Commotion More...
 
struct  co_olsrd_conf_plugin_t
 contains the number of configuration items for OLSRd More...
 
struct  co_olsrd_conf_iface_t
 contains interace configuration settings for OLSR, including interface name, mode and IPv4 broadcast message More...
 
struct  co_olsrd_conf_hna_t
 contains host network address settings, including family, address and netmask More...
 

Macros

#define OLSR_HNA4   (1 << 0)
 
#define OLSR_HNA6   (1 << 1)
 
#define OLSR_IFACE_MESH   (1 << 0)
 
#define OLSR_IFACE_ETHER   (1 << 1)
 

Functions

int co_olsrd_add_iface (const char *name, int mode, const char *Ipv4Broadcast)
 adds an interface to OLSRd More...
 
int co_olsrd_remove_iface (char *name, int mode, char *Ipv4Broadcast)
 removes an interface from OLSRd More...
 
int co_olsrd_add_hna (const int family, const char *address, const char *netmask)
 adds a host network address to OLSRd More...
 
int co_olsrd_remove_hna (int family, char *address, char *netmask)
 remves a host network address from OLSRd More...
 
int co_olsrd_print_conf (const char *filename)
 prints OLSR configuration info from file (currently unimplemented) More...
 
int co_olsrd_init (co_obj_t *self)
 initiates the OLSR daemon when a new process gets created (currently unimplemented) More...
 

Detailed Description

OLSRd configuration and process management.

Author
Josh King (jheretic), jking.nosp@m.@cha.nosp@m.mbana.nosp@m..net

Function Documentation

int co_olsrd_add_hna ( const int  family,
const char *  address,
const char *  netmask 
)

adds a host network address to OLSRd

Parameters
familythe address family
addressthe network address for the interface
netmaskthe netmask for the interface
198  {
199  co_olsrd_conf_hna_t *new_hna = NULL;
200  new_hna = (co_olsrd_conf_hna_t*)calloc(1, sizeof(co_olsrd_conf_hna_t));
201 
202  new_hna->family = family;
203 
204  new_hna->address = (char*)calloc(strlen(address)+1, sizeof(char));
205  strcpy(new_hna->address, address);
206 
207  new_hna->netmask = (char*)calloc(strlen(netmask)+1, sizeof(char));
208  strcpy(new_hna->netmask, netmask);
209 
210  list_append(hna, lnode_create(new_hna));
211  return 1;
212 }
contains host network address settings, including family, address and netmask
Definition: olsrd.h:84
int co_olsrd_add_iface ( const char *  name,
int  mode,
const char *  Ipv4Broadcast 
)

adds an interface to OLSRd

Parameters
namename of the interface to be added
modenetwork mode for interface
Ipv4BroadcastIPv4 broadcast address (node address, using netmask as last octet)
149  {
150  co_olsrd_conf_iface_t *new_iface = NULL;
151  new_iface = (co_olsrd_conf_iface_t*)calloc(1, sizeof(co_olsrd_conf_iface_t));
152 
153  new_iface->mode = mode;
154 
155  new_iface->ifname = (char*)calloc(strlen(name)+1, sizeof(char));
156  strcpy(new_iface->ifname, name);
157 
158  new_iface->Ipv4Broadcast=(char*)calloc(strlen(Ipv4Broadcast)+1,sizeof(char));
159  strcpy(new_iface->Ipv4Broadcast, Ipv4Broadcast);
160 
161  list_append(ifaces, lnode_create(new_iface));
162  return 1;
163 }
contains interace configuration settings for OLSR, including interface name, mode and IPv4 broadcast ...
Definition: olsrd.h:74
co_obj_t * name
Definition: cmd.h:60
int co_olsrd_init ( co_obj_t self)

initiates the OLSR daemon when a new process gets created (currently unimplemented)

Parameters
selfprocess to be called
248  {
249  //co_olsrd_process_t *this = self;
250  //This function gets called when the process object is created, and should call any initialization stuff that happens before it starts
251  return 1;
252 }
int co_olsrd_print_conf ( const char *  filename)

prints OLSR configuration info from file (currently unimplemented)

Parameters
filenamethe configuration file

References name.

93  {
94  int i = 0;
95  FILE *conf_file;
96 
97  if (!(conf_file = fopen(filename, "w+"))) {
98  /* file could not be opened!
99  */
100  return 0;
101  }
102 
103  for (i = 0; i<global_items_count; i++) {
104  fprintf(conf_file, "%s\t%s\n", global_items[i].key,
105  global_items[i].value);
106  }
107 
108  for (i = 0; i<plugins_count; i++) {
109  int j = 0;
110  fprintf(conf_file, "LoadPlugin\t\"%s\"\n", plugins[i].name);
111  fprintf(conf_file, "{\n");
112  for (j = 0; j<plugins[i].num_attr; j++) {
113  fprintf(conf_file, "\t%s\t%s\n",plugins[i].attr[i]->key,
114  plugins[i].attr[i]->value);
115  }
116  fprintf(conf_file, "}\n");
117  }
118 
119  list_process(ifaces, (void*)conf_file, _co_olsrd_print_iface_i);
120  list_process(hna, (void*)conf_file, _co_olsrd_print_hna_i);
121 
122  fclose(conf_file);
123 
124  return 1;
125 }
co_obj_t * name
Definition: cmd.h:60
int co_olsrd_remove_hna ( int  family,
char *  address,
char *  netmask 
)

remves a host network address from OLSRd

Parameters
familythe address family
addressthe network address for the interface
netmaskthe netmask for the interface
214  {
215  co_olsrd_conf_hna_t *hna_to_remove;
216  co_olsrd_conf_hna_t hna_to_find;
217  lnode_t *hna_node_to_remove;
218 
219  /*
220  * FYI: This causes a compiler warning for
221  * discarding the constant. Using a strcpy()
222  * would fix this, but that wastes time.
223  */
224  hna_to_find.family = family;
225  hna_to_find.address = address;
226  hna_to_find.netmask = netmask;
227 
228  if ((hna_node_to_remove = list_find(hna,
229  &hna_to_find,
230  _co_olsrd_compare_hna_i))) {
231  /*
232  * delete from the list.
233  */
234  list_delete(hna, hna_node_to_remove);
235 
236  /*
237  * free the object's memory.
238  */
239  hna_to_remove = lnode_get(hna_node_to_remove);
240  free(hna_to_remove->address);
241  free(hna_to_remove->netmask);
242  free(hna_to_remove);
243  }
244  return 1;
245 }
contains host network address settings, including family, address and netmask
Definition: olsrd.h:84
int co_olsrd_remove_iface ( char *  name,
int  mode,
char *  Ipv4Broadcast 
)

removes an interface from OLSRd

Parameters
namename of the interface to be removed
modenetwork mode for interface
Ipv4BroadcastIPv4 broadcast address (node address, using netmask as last octet)

References name.

165  {
166  co_olsrd_conf_iface_t *iface_to_remove;
167  co_olsrd_conf_iface_t iface_to_find;
168  lnode_t *iface_node_to_remove;
169 
170  /*
171  * FYI: This causes a compiler warning for
172  * discarding the constant. Using a strcpy()
173  * would fix this, but that wastes time.
174  */
175  iface_to_find.mode = mode;
176  iface_to_find.ifname = name;
177  iface_to_find.Ipv4Broadcast = Ipv4Broadcast;
178 
179  if ((iface_node_to_remove = list_find(ifaces,
180  &iface_to_find,
181  _co_olsrd_compare_iface_i))) {
182  /*
183  * delete from the list.
184  */
185  list_delete(ifaces, iface_node_to_remove);
186 
187  /*
188  * free the object's memory.
189  */
190  iface_to_remove = lnode_get(iface_node_to_remove);
191  free(iface_to_remove->ifname);
192  free(iface_to_remove->Ipv4Broadcast);
193  free(iface_to_remove);
194  }
195  return 1;
196 }
contains interace configuration settings for OLSR, including interface name, mode and IPv4 broadcast ...
Definition: olsrd.h:74
co_obj_t * name
Definition: cmd.h:60