X-Git-Url: http://git.sameswireless.fr/l2tpns.git/blobdiff_plain/ec1507a6c2f477e81050e5540fceed50c7bf7432..b5273cc1c65f9496c1a7c2135b61979dd98fcf08:/l2tpns.h diff --git a/l2tpns.h b/l2tpns.h index 56f8fa1..989ddd9 100644 --- a/l2tpns.h +++ b/l2tpns.h @@ -24,6 +24,10 @@ #define MAXADDRESS 20 // Maximum length for the Endpoint Discrminiator address #define MAXSESSION 60000 // could be up to 65535 #define MAXTBFS 6000 // Maximum token bucket filters. Might need up to 2 * session. +#define MAXSESSINGRP 12 // Maximum number of member links in grouped session +#define MAXGRPINSESS 12 // Maximum number of member links in session group +#define MAXGROUPE 300 // could be up to 65535, Maximum number of grouped session +#define MAXROUTEINGRP 15 // max static routes per group // Tunnel Id reserved for pppoe #define TUNNEL_ID_PPPOE 1 @@ -207,6 +211,7 @@ enum { typedef uint16_t sessionidt; typedef uint16_t bundleidt; typedef uint16_t tunnelidt; +typedef uint16_t groupidt; typedef uint32_t clockt; typedef uint8_t hasht[16]; @@ -328,14 +333,37 @@ typedef struct #ifdef LAC sessionidt forwardtosession; // LNS id_session to forward uint8_t src_hwaddr[ETH_ALEN]; // MAC addr source (for pppoe sessions 6 bytes) - char reserved[4]; // Space to expand structure without changing HB_VERSION + uint32_t coutgrp_delta; #else uint8_t src_hwaddr[ETH_ALEN]; // MAC addr source (for pppoe sessions 6 bytes) - char reserved[6]; // Space to expand structure without changing HB_VERSION + uint32_t coutgrp_delta; + char reserved[2]; // Space to expand structure without changing HB_VERSION #endif } sessiont; +typedef struct +{ + uint32_t tx_rate; + time_t mark_time; + sessionidt sid; + uint8_t weight; +} +groupsessionidt; + +typedef struct +{ + //uint16_t indexprevsessid; + uint32_t time_changed; + //time_t mark_time; + groupidt prev; + groupsessionidt sesslist[MAXSESSINGRP]; + routet route[MAXROUTEINGRP]; // static routes + uint8_t nbroutesgrp; + uint8_t nbsession; +} +groupsesst; + typedef struct { int state; // current state (bundlestate enum) @@ -781,6 +809,7 @@ typedef struct uint8_t pppoe_hwaddr[ETH_ALEN]; // MAC addr of interface pppoe to bind int disable_sending_hello; // Disable l2tp sending HELLO message for Apple compatibility. int disable_no_spoof; // Disable no spoof (permit load balancing client --> internet) + int grp_txrate_average_time; // caculation txrate average time (default 10s) } configt; enum config_typet { INT, STRING, UNSIGNED_LONG, SHORT, BOOL, IPv4, IPv6 }; @@ -946,6 +975,10 @@ int ip_filter(uint8_t *buf, int len, uint8_t filter); int cmd_show_ipcache(struct cli_def *cli, char *command, char **argv, int argc); int cmd_show_hist_idle(struct cli_def *cli, char *command, char **argv, int argc); int cmd_show_hist_open(struct cli_def *cli, char *command, char **argv, int argc); +void netlink_addattr(struct nlmsghdr *nh, int type, const void *data, int alen); +ssize_t netlink_send(struct nlmsghdr *nh); +void cache_ipmap(in_addr_t ip, sessionidt s); + #ifdef LAC tunnelidt lac_new_tunnel(); void lac_tunnelclear(tunnelidt t); @@ -954,6 +987,16 @@ void lac_send_ICRQ(tunnelidt t, sessionidt s); void lac_tunnelshutdown(tunnelidt t, char *reason, int result, int error, char *msg); #endif +// grpsess.c +sessionidt grp_getnextsession(groupidt g, in_addr_t ip); +void grp_initdata(void); +void grp_processvendorspecific(sessionidt s, uint8_t *pvs); +groupidt grp_groupbysession(sessionidt s); +groupidt grp_groupbyip(in_addr_t ip); +void grp_setgrouproute(groupidt g, int add); +void grp_time_changed(void); +void grp_removesession(groupidt g, sessionidt s); + #undef LOG #undef LOG_HEX #define LOG(D, s, t, f, ...) ({ if (D <= config->debug) _log(D, s, t, f, ## __VA_ARGS__); }) @@ -988,6 +1031,7 @@ extern bundlet *bundle; extern sessiont *session; extern sessionlocalt *sess_local; extern ippoolt *ip_address_pool; +extern groupsesst *grpsession; #define sessionfree (session[0].next) @@ -1000,6 +1044,7 @@ extern struct Tstats *_statistics; extern in_addr_t my_address; extern int clifd; extern int epollfd; +extern int tunidx; // ifr_ifindex of tun device struct event_data { enum {