Support packets in flight
[samplevnf.git] / VNFs / DPPD-PROX / quit.h
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #ifndef _QUIT_H_
18 #define _QUIT_H_
19
20 #include <signal.h>
21 #include <sys/types.h>
22 #include <unistd.h>
23
24 #include <rte_debug.h>
25
26 #include "display.h"
27 #include "prox_cfg.h"
28 #include "log.h"
29
30 /* PROX_PANIC for checks that are possibly hit due to configuration or
31    when feature is not implemented. */
32 /* Restore tty and abort if there is a problem */
33 #define PROX_PANIC(cond, ...) do {                                      \
34                 if (cond) {                                             \
35                         plog_info(__VA_ARGS__);                         \
36                         display_end();                                  \
37                         plog_end();                                     \
38                         plog_info(__VA_ARGS__);                         \
39                         if (prox_cfg.flags & DSF_DAEMON) {              \
40                                 pid_t ppid = getppid();                 \
41                                 plog_info("sending SIGUSR2 to %d\n", ppid);\
42                                 kill(ppid, SIGUSR2);                    \
43                         }                                               \
44                         rte_panic("PANIC at %s:%u, callstack:\n",       \
45                                   __FILE__, __LINE__);                  \
46                 }                                                       \
47         } while (0)
48
49 #endif /* _QUIT_H_ */