Annotation of embedaddon/libpdel/ppp/ppp_l2tp_server.h, revision 1.1.1.1

1.1       misho       1: 
                      2: /*
                      3:  * Copyright (c) 2001-2002 Packet Design, LLC.
                      4:  * All rights reserved.
                      5:  * 
                      6:  * Subject to the following obligations and disclaimer of warranty,
                      7:  * use and redistribution of this software, in source or object code
                      8:  * forms, with or without modifications are expressly permitted by
                      9:  * Packet Design; provided, however, that:
                     10:  * 
                     11:  *    (i)  Any and all reproductions of the source or object code
                     12:  *         must include the copyright notice above and the following
                     13:  *         disclaimer of warranties; and
                     14:  *    (ii) No rights are granted, in any manner or form, to use
                     15:  *         Packet Design trademarks, including the mark "PACKET DESIGN"
                     16:  *         on advertising, endorsements, or otherwise except as such
                     17:  *         appears in the above copyright notice or in the software.
                     18:  * 
                     19:  * THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
                     20:  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO
                     21:  * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING
                     22:  * THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED
                     23:  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
                     24:  * OR NON-INFRINGEMENT.  PACKET DESIGN DOES NOT WARRANT, GUARANTEE,
                     25:  * OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS
                     26:  * OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY,
                     27:  * RELIABILITY OR OTHERWISE.  IN NO EVENT SHALL PACKET DESIGN BE
                     28:  * LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE
                     29:  * OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT,
                     30:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL
                     31:  * DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF
                     32:  * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF
                     33:  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     34:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
                     35:  * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
                     36:  * THE POSSIBILITY OF SUCH DAMAGE.
                     37:  *
                     38:  * Author: Archie Cobbs <archie@freebsd.org>
                     39:  */
                     40: 
                     41: #ifndef _PPP_L2TP_PDEL_PPP_PPP_L2TP_SERVER_H_
                     42: #define _PPP_L2TP_PDEL_PPP_PPP_L2TP_SERVER_H_
                     43: 
                     44: struct ppp_engine;
                     45: struct ppp_l2tp_peer;
                     46: struct ppp_channel;
                     47: 
                     48: #define L2TP_PORT              1701
                     49: 
                     50: /*
                     51:  * Callback for client to decide whether establishing a new L2TP
                     52:  * connection from ip:port is ok or not.
                     53:  *
                     54:  * Should return a non-NULL cookie to let the channel be established.
                     55:  * This argument becomes the 'carg' parameter to the 'plumb' and
                     56:  * 'destroy' methods below; the destroy method below is guaranteed
                     57:  * to be called exactly once if 'admit' returns a non-NULL cookie
                     58:  * (unless ppp_l2tp_server_close() is called first).
                     59:  *
                     60:  * The 'peer' may be used in a call to ppp_l2tp_server_close() to
                     61:  * close the associated L2TP connection before 'destroy' is called.
                     62:  * If so, 'destroy' will not be called. Calling ppp_l2tp_server_close()
                     63:  * after 'destroy' has been called will cause a crash.
                     64:  *
                     65:  * If desired, a name for this link (for logging purposes) may be
                     66:  * printed into the 'name' buffer, which has size 'nsize'.
                     67:  *
                     68:  * Note: we only allow one L2TP session to be established within
                     69:  * each control connection. So this will not be called if there is
                     70:  * already a connection with ip:port.
                     71:  */
                     72: typedef void   *ppp_l2tp_server_admit_t(void *arg, struct ppp_l2tp_peer *peer,
                     73:                        struct in_addr ip, u_int16_t port,
                     74:                        struct ppp_auth_config *auth, char *name, size_t nsize);
                     75: 
                     76: /*
                     77:  * Do any NAT mapping required to set up a reverse mapping from
                     78:  * our address at self_ip:self_port back to peer_ip:peer_port.
                     79:  * The original port we received the initial packet on is orig_port.
                     80:  *
                     81:  * This method is optional.
                     82:  */
                     83: typedef int    ppp_l2tp_server_natmap_t(void *arg,
                     84:                        struct in_addr self_ip, u_int16_t self_port,
                     85:                        u_int16_t orig_port, struct in_addr peer_ip,
                     86:                        u_int16_t peer_port);
                     87: 
                     88: /*
                     89:  * Callback to tear down client state associated with a L2TP connection.
                     90:  *
                     91:  * After this function is called, "carg" will not be used again.
                     92:  */
                     93: typedef void   ppp_l2tp_server_destroy_t(void *arg, void *carg);
                     94: 
                     95: /*
                     96:  * Info supplied by client library to L2TP server.
                     97:  */
                     98: struct ppp_l2tp_server_info {
                     99:        void                            *arg;
                    100:        const char                      *vendor;
                    101:        ppp_l2tp_server_admit_t         *admit;
                    102:        ppp_l2tp_server_natmap_t        *natmap;
                    103:        ppp_l2tp_server_destroy_t       *destroy;
                    104: };
                    105: 
                    106: __BEGIN_DECLS
                    107: 
                    108: /* Functions */
                    109: extern int     ppp_l2tp_server_start(struct ppp_engine *engine,
                    110:                        const struct ppp_l2tp_server_info *info,
                    111:                        struct in_addr ip, u_int16_t port, u_int max_conn);
                    112: extern void    *ppp_l2tp_server_get_client_info(struct ppp_channel *chan);
                    113: extern void    ppp_l2tp_server_close(struct ppp_engine *engine,
                    114:                        struct ppp_l2tp_peer **peerp);
                    115: extern void    ppp_l2tp_server_stop(struct ppp_engine *engine);
                    116: 
                    117: __END_DECLS
                    118: 
                    119: #endif /* _PPP_L2TP_PDEL_PPP_PPP_L2TP_SERVER_H_ */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>