#ifndef L2TPD_H #define L2TPD_H #include "babd.h" #include "config.h" #include "selectops.h" #include "ctrlfd.h" #include extern unsigned num_est_sessions; extern unsigned num_sessions; extern unsigned num_est_tunnels; extern unsigned num_tunnels; class PacketHandler_t : public SelectEventHandler { public: int udp_fd, l2tp_fd; void SelectEvent(int fd, SelectEventType event); virtual void handle_packet(char *buf, unsigned len, union sockaddr_union *sin) { } }; #include "l2tp_peer.h" struct replication_packet { u16 len; u16 port; u32 addr; u32 addr4[4]; char buf[0]; }; class l2tp_tunnel_t; class l2tp_session_t; class l2tp_replication_t : public SelectEventHandler { public: u32 replicate_peer; int replication_error; void SelectEvent(int fd, SelectEventType event); l2tp_replication_t(void); int repl_listen_fd, repl_fd; void replicate_packet(char *buf, int len, union sockaddr_union *sin, int sin_len); }; class l2tpd_t : public PacketHandler_t, public l2tp_replication_t { union sockaddr_union our_sau; l2tp_peer_t *first_peer; public: bvirt_ns_t *m_netns; const char *host_name; int host_name_len; int peer_must_auth; l2tpd_t *next, **prevp; l2tp_tunnel_t *l2tp_tunnels[65536]; int init_failed; int setup_replication(ctrlfd_t *cfd, u32 replicate); l2tpd_t(ctrlfd_t *cfd, bvirt_ns_t *netns, union sockaddr_union, u32 replicate_peer); ~l2tpd_t(void); l2tp_tunnel_t *make_tunnel(union sockaddr_union *, u16 tunnel, bvirt_ns_t *netns); void dump_sessions(ctrlfd_t *cfd, int verbose=0); void dump_num_sessions(ctrlfd_t *cfd); void set_host_name(ctrlfd_t *cfd, const char *str); void start_tunnel(ctrlfd_t *cfd, char *ip); void stop_tunnel(ctrlfd_t *cfd, char *ip); void start_session(ctrlfd_t *cfd, char *args); virtual void handle_packet(char *buf, unsigned len, union sockaddr_union *sin); l2tp_peer_t *find_peer(union sockaddr_union *, bvirt_ns_t *netns); l2tp_peer_t *find_make_peer(union sockaddr_union *, const char *secret, bvirt_ns_t *netns); void dump_multihop(ctrlfd_t *cfd); void add_del_multihop(ctrlfd_t *cfd, char *ip, int add); void cmd_radius_local_ip(ctrlfd_t *cfd, const char *ip); void cmd_peer_must_auth(ctrlfd_t *cfd, const char *str); void fixed_local_ip(ctrlfd_t *cfd, const char *ip); l2tp_peer_t *lookup_multihop_peer(const char *full_id, const char *domain, int insert); l2tp_tunnel_t *try_multihop(OptionSet_t *options); l2tp_tunnel_t *try_multihop(const char *user); void dump_full_state(ctrlfd_t *cfd, int do_config); l2tp_session_t *find_l2tp_session(const char *dfs_str); friend l2tpd_t *find_local_l2tpd(union sockaddr_union *local_ip, bvirt_ns_t *netns, int family); int show_running_config(ctrlfd_t *cfd, int verbose); int show_running_multihop_config(ctrlfd_t *cfd, int verbose); int is_local_ip(union sockaddr_union *sau) { return sau_match_ip(&our_sau, sau); } friend l2tpd_t *find_l2tpd(bvirt_ns_t *netns, union sockaddr_union *sin); void show_hw_peer(ctrlfd_t *cfd); }; l2tpd_t *find_local_l2tpd(union sockaddr_union *local_ip, bvirt_ns_t *netns, int family); void all_dump_full_state(ctrlfd_t *cfd, const char *args); extern l2tpd_t *the_l2tpd; #endif