Move main() out of clatd.c.
This allows us to unit test methods that are in clatd.c.
Also simplify the build file, adding a defaults stanza and
grouping files in a filegroup so that both the code and the unit
test have the same source files.
Test: atest clatd_test
Test: builds, boots, 464xlat works
Change-Id: I544c3ee846abd3e38b80a2d9a4db5497fd9beb0c
diff --git a/clatd.h b/clatd.h
index 327a948..32f8cd5 100644
--- a/clatd.h
+++ b/clatd.h
@@ -13,13 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * clatd.h - main system definitions
+ * clatd.h - main routines used by clatd
*/
#ifndef __CLATD_H__
#define __CLATD_H__
#include <sys/uio.h>
+struct tun_data;
+
#define MAXMTU 1500
#define PACKETLEN (MAXMTU + sizeof(struct tun_pi))
#define CLATD_VERSION "1.4"
@@ -32,21 +34,15 @@
// how frequently (in seconds) to poll for an address change while there is no traffic
#define NO_TRAFFIC_INTERFACE_POLL_FREQUENCY 90
-// A clat_packet is an array of iovec structures representing a packet that we are translating.
-// The CLAT_POS_XXX constants represent the array indices within the clat_packet that contain
-// specific parts of the packet. The packet_* functions operate on all the packet segments past a
-// given position.
-typedef enum {
- CLAT_POS_TUNHDR,
- CLAT_POS_IPHDR,
- CLAT_POS_FRAGHDR,
- CLAT_POS_TRANSPORTHDR,
- CLAT_POS_ICMPERR_IPHDR,
- CLAT_POS_ICMPERR_FRAGHDR,
- CLAT_POS_ICMPERR_TRANSPORTHDR,
- CLAT_POS_PAYLOAD,
- CLAT_POS_MAX
-} clat_packet_index;
-typedef struct iovec clat_packet[CLAT_POS_MAX];
+void stop_loop();
+void set_capability(uint64_t target_cap);
+void drop_root_but_keep_caps();
+void open_sockets(struct tun_data *tunnel, uint32_t mark);
+int ipv6_address_changed(const char *interface);
+int update_clat_ipv6_address(const struct tun_data *tunnel, const char *interface);
+void configure_interface(const char *uplink_interface, const char *plat_prefix,
+ struct tun_data *tunnel, unsigned net_id);
+void event_loop(struct tun_data *tunnel);
+int parse_unsigned(const char *str, unsigned *out);
#endif /* __CLATD_H__ */