clatd: move stop_loop() into main.c

* New clang-tidy gives more warnings:
  .../external/android-clat/main.c:136:23: error: 'stop_loop' may not be asynchronous-safe; calling it from a signal handler may be dangerous [cert-sig30-c,-warnings-as-errors]
  if (signal(SIGTERM, stop_loop) == SIG_ERR) {
                      ^
  .../external/android-clat/main.c:136:7: note: signal handler registered here
  if (signal(SIGTERM, stop_loop) == SIG_ERR) {
      ^
  external/android-clat/clatd.h:38:1: note: handler function declared here
    void stop_loop();
    ^

Bug: 179304856
Test: builds, atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I06bad709df2ddded97829833f5e86d72ac282fa3
diff --git a/clatd.c b/clatd.c
index 422cded..3ffe934 100644
--- a/clatd.c
+++ b/clatd.c
@@ -58,11 +58,6 @@
 
 volatile sig_atomic_t running = 1;
 
-/* function: stop_loop
- * signal handler: stop the event loop
- */
-void stop_loop() { running = 0; }
-
 /* function: configure_packet_socket
  * Binds the packet socket and attaches the receive filter to it.
  *   sock - the socket to configure
diff --git a/clatd.h b/clatd.h
index a3f9326..899458c 100644
--- a/clatd.h
+++ b/clatd.h
@@ -18,6 +18,7 @@
 #ifndef __CLATD_H__
 #define __CLATD_H__
 
+#include <signal.h>
 #include <stdlib.h>
 #include <sys/uio.h>
 
@@ -35,7 +36,8 @@
 // how frequently (in seconds) to poll for an address change while there is no traffic
 #define NO_TRAFFIC_INTERFACE_POLL_FREQUENCY 90
 
-void stop_loop();
+extern volatile sig_atomic_t running;
+
 void configure_tun_ip(const struct tun_data *tunnel, const char *v4_addr, int mtu);
 void set_capability(uint64_t target_cap);
 void drop_root_but_keep_caps();
diff --git a/main.c b/main.c
index 683b507..bfcad48 100644
--- a/main.c
+++ b/main.c
@@ -35,6 +35,11 @@
 
 #define DEVICEPREFIX "v4-"
 
+/* function: stop_loop
+ * signal handler: stop the event loop
+ */
+static void stop_loop() { running = 0; };
+
 /* function: print_help
  * in case the user is running this on the command line
  */