#ifndef _PPTPD_H #define _PPTPD_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "pptp-proto.h" struct aval_ppp { struct aval_ppp *next; int index; char line[0]; }; struct ppp_struct { int fd; pid_t ppp_pid; struct ppp_struct * next; struct aval_ppp * cmdline; u_int16_t call_id; /* network order */ u_int16_t peers_call_id; /* network order */ char pptp_type; #define PPTP_PNS 0 #define PPTP_PAC 1 u_int16_t fcs16; char buf[PPPFRAME_MAX]; char buf_flags; #define PPP_BUF_ESCAPE 0x01 #define PPP_NOISE_TO_FLAG 0x02 int buf_pos; }; struct control_struct { struct control_struct ** control_chain; /* control connection */ int ctrl_fd; time_t last_pong_time; /* control connection receiver data */ char * ctrl_rcv_buf; u_int16_t ctrl_rcv_len; int ctrl_rcv_offset; #define CTRL_RCV_LEN0 -3 #define CTRL_RCV_LEN1 -2 #define CTRL_RCV_START -1 struct control_struct * next; /* data connection */ int gre_fd; u_int32_t in_seq; /* sequence number of received packet +1 */ u_int32_t in_ack; /* input accepted packet +1 */ u_int32_t in_pack; /* prev. input accepted packet +1 */ u_int32_t out_seq; /* last output packet */ u_int32_t out_ack; /* output packet accepted by peer */ u_int32_t in_window_size; u_int32_t out_window_size; struct timeval gre_tv, gre_dtv; struct pptp_gre_header *in_window[MAX_GRE_WINDOW]; struct pptp_gre_header *out_window[MAX_GRE_WINDOW]; struct sockaddr_in addr_local; struct sockaddr_in addr_remote; /* ppp interfaces */ struct ppp_struct * ppp; }; #define ALLOC_PACKET(buf,what) \ if( ((buf)=malloc(sizeof(*(buf))))!=NULL ) { \ (buf)->header.length = htons(sizeof(*(buf))); \ (buf)->header.pptp_type = htons(PPTP_CTRL_MESSAGE);\ (buf)->header.magic = htonl(PPTP_MAGIC_COOKIE); \ (buf)->header.ctrl_type = htons(what); \ (buf)->header.reserved0 = htons(RESERVED); \ } /* GCC hack, (c) 2000 Milan Pikula */ #define NOTHING #define LOG(FMT, PAR...) syslog(LOG_INFO, __FILE__ ":%d(" __FUNCTION__ "): " FMT, __LINE__ NOTHING, ## PAR) /* time(x) <= time(y) */ #define TV_IS_MIN(X,Y) ((X).tv_sec <= (Y).tv_sec || ((X).tv_sec == (Y).tv_sec && (X).tv_usec <= (Y).tv_usec)) #define TV_MIN(X,Y) (TV_IS_MIN((X),(Y)) ? (X) : (Y)) #if 0 inline void tv_sub(stuct timeval * x, struct timeval * y) { if (x.tv_usec >= y.tv_usec) x.tv_usec -= y.tv_usec; else { x.tv_usec += 1000000 - y.tv_usec; x.tv_sec --; } x.tv_sec -= y.tv_sec; return x; } #endif #define TV_SUB(X,Y) do { \ (X).tv_sec -= (((X).tv_usec < (Y).tv_usec)?1:0) + (Y).tv_sec; \ (X).tv_usec += (((X).tv_usec < (Y).tv_usec)?1000000:0) - (Y).tv_usec; \ } while (0) #define TV_ADD(X,Y) do { \ (X).tv_sec += (Y).tv_sec + ((Y).tv_usec+(X).tv_usec)/1000000; \ (X).tv_usec = ((X).tv_usec + (Y).tv_usec)%1000000; \ } while (0) #include "prototypes.h" #endif /* _PPTPD_H */