Commotion Wireless
About
Blog
Documentation
Download
For Organizers
For Developers
- API Reference - commotiond
Main Page
Related Pages
Classes
Files
File List
File Members
plugins
serval-dna
serval-dna.h
Go to the documentation of this file.
1
/**
2
* @file serval-dna.h
3
* @brief re-implementation of the serval-dna daemon as a
4
* commotiond plugin
5
*
6
* @author Dan Staples (dismantl), danstaples@opentechinstitute.org
7
*
8
* @internal
9
* Created 12/18/2013
10
* Compiler gcc/g++
11
* Company The Open Technology Institute
12
* Copyright Copyright (c) 2013, Dan Staples
13
*
14
* This file is part of Commotion, Copyright (c) 2013, Josh King
15
*
16
* Commotion is free software: you can redistribute it and/or modify
17
* it under the terms of the GNU General Public License as published
18
* by the Free Software Foundation, either version 3 of the License,
19
* or (at your option) any later version.
20
*
21
* Commotion is distributed in the hope that it will be useful,
22
* but WITHOUT ANY WARRANTY; without even the implied warranty of
23
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
* GNU General Public License for more details.
25
*
26
* You should have received a copy of the GNU General Public License
27
* along with Commotion. If not, see <http://www.gnu.org/licenses/>.
28
*
29
* =====================================================================================
30
*/
31
32
#ifndef __CO_SERVAL_DNA_H
33
#define __CO_SERVAL_DNA_H
34
35
#define DEFAULT_SID "0000000000000000000000000000000000000000000000000000000000000000"
36
#define DEFAULT_MDP_PATH "/etc/commotion/keys.d/mdp.keyring/serval.keyring"
37
#define DEFAULT_SERVAL_PATH "/var/serval-node"
38
39
#define PATH_MAX 4096
40
41
#define CHECK_ERR(A, M, ...) if(!(A)) { \
42
ERROR(M, ##__VA_ARGS__); \
43
if (err_msg == NULL) \
44
err_msg = co_list16_create(); \
45
char *msg = NULL; \
46
int len = snprintf(NULL, 0, M, ##__VA_ARGS__); \
47
msg = calloc(len + 1,sizeof(char)); \
48
sprintf(msg, M, ##__VA_ARGS__); \
49
if (len < UINT8_MAX) { \
50
co_list_append(err_msg, co_str8_create(msg,len+1,0)); \
51
} else if (len < UINT16_MAX) { \
52
co_list_append(err_msg, co_str16_create(msg,len+1,0)); \
53
} else if (len < UINT32_MAX) { \
54
co_list_append(err_msg, co_str32_create(msg,len+1,0)); \
55
} \
56
free(msg); \
57
goto error; \
58
}
59
60
/** until we have nested tree support */
61
#undef CHECK_ERR
62
#define CHECK_ERR(A, M, ...) if(!(A)) { \
63
ERROR(M, ##__VA_ARGS__); \
64
if (err_msg) \
65
co_obj_free(err_msg); \
66
char *msg = NULL; \
67
int len = snprintf(NULL, 0, M, ##__VA_ARGS__); \
68
msg = calloc(len + 1,sizeof(char)); \
69
sprintf(msg, M, ##__VA_ARGS__); \
70
if (len < UINT8_MAX) { \
71
err_msg = co_str8_create(msg,len+1,0); \
72
} else if (len < UINT16_MAX) { \
73
err_msg = co_str16_create(msg,len+1,0); \
74
} else if (len < UINT32_MAX) { \
75
err_msg = co_str32_create(msg,len+1,0); \
76
} \
77
free(msg); \
78
goto error; \
79
}
80
81
#define CLEAR_ERR() err_msg = NULL;
82
83
#define INS_ERROR() if (err_msg) { CMD_OUTPUT("errors",err_msg); }
84
85
int
co_plugin_register(
co_obj_t
*
self
,
co_obj_t
**output,
co_obj_t
*params);
86
int
co_plugin_init(
co_obj_t
*
self
,
co_obj_t
**output,
co_obj_t
*params);
87
int
co_plugin_name(
co_obj_t
*
self
,
co_obj_t
**output,
co_obj_t
*params);
88
int
co_plugin_shutdown(
co_obj_t
*
self
,
co_obj_t
**output,
co_obj_t
*params);
89
int
serval_socket_cb
(
co_obj_t
*
self
,
co_obj_t
*context);
90
int
serval_timer_cb(
co_obj_t
*
self
,
co_obj_t
**output,
co_obj_t
*context);
91
int
serval_schema(
co_obj_t
*
self
,
co_obj_t
**output,
co_obj_t
*params);
92
int
serval_daemon_handler(
co_obj_t
*
self
,
co_obj_t
**output,
co_obj_t
*params);
93
94
#endif
serval_socket_cb
int serval_socket_cb(co_obj_t *self, co_obj_t *context)
Definition:
serval-dna.c:117
co_obj_t
Definition:
obj.h:131
Generated on Fri Jun 6 2014 13:22:05 for commotiond by
1.8.7