3 * \author written by Emmanuel Roullit emmanuel.roullit@gmail.com (c) 2012
7 /* __LICENSE_HEADER_BEGIN__ */
10 * Copyright (C) 2012 Emmanuel Roullit <emmanuel.roullit@gmail.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
28 /* __LICENSE_HEADER_END__ */
34 dabbad - Multithreaded packet mmap daemon
38 dabbad [--daemonize][--help]
42 dabbad (dabba daemon) is here to manage multithreaded network captures.
43 It listens an IPC interface and waits for commands to execute.
51 Start dabbad in a classic process mode. It allows the user to
54 =item dabbad --daemonize
56 Start dabbad as a daemon.
66 Written by Emmanuel Roullit <emmanuel.roullit@gmail.com>
72 =item Please report bugs to <https://github.com/eroullit/dabba/issues>
74 =item dabba project project page: <https://github.com/eroullit/dabba>
82 =item Copyright © 2012 Emmanuel Roullit.
84 =item License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
86 =item This is free software: you are free to change and redistribute it.
88 =item There is NO WARRANTY, to the extent permitted by law.
102 #include <sys/types.h>
103 #include <sys/stat.h>
106 #include <dabbad/ipc.h>
107 #include <dabbad/help.h>
115 * \brief Dabbad options getter
116 * \return Dabbad option data structure
119 const struct option
*dabbad_options_get(void)
121 static const struct option dabbad_long_options
[] = {
122 {"daemonize", no_argument
, NULL
, OPT_DAEMONIZE
},
123 {"help", no_argument
, NULL
, OPT_HELP
},
127 return (dabbad_long_options
);
132 * \brief Create dabbad pidfile
133 * \return 0 on success, else on failure.
135 * This function creates start time a file containing dabbad process id.
138 static inline int dabbad_pidfile_create(void)
142 char pidstr
[8] = { 0 };
143 ssize_t pidstrlen
= 0;
145 pidfd
= creat(DABBAD_PID_FILE
, 0600);
150 pidstrlen
= snprintf(pidstr
, sizeof(pidstr
), "%i\n", getpid());
152 if (write(pidfd
, pidstr
, pidstrlen
) != pidstrlen
) {
161 * \brief Dabbad entry point
162 * \param[in] argc Argument counter
163 * \param[in] argv Argument vector
164 * \return 0 on success, else on failure
166 * This function is dabbad entry point.
167 * It parses given arguments, configure the daemon accordingly and start
168 * IPC message polling.
171 int main(int argc
, char **argv
)
180 getopt_long_only(argc
, argv
, "", dabbad_options_get(),
188 show_usage(dabbad_options_get());
197 perror("Could not daemonize process");
202 assert(dabbad_pidfile_create());
203 dabbad_ipc_msg_init();
205 return dabbad_ipc_msg_poll();