2000-06-20 11:41:48 +00:00
|
|
|
/*
|
|
|
|
* alias_pptp.c
|
|
|
|
*
|
|
|
|
* Copyright (c) 2000 Whistle Communications, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Subject to the following obligations and disclaimer of warranty, use and
|
|
|
|
* redistribution of this software, in source or object code forms, with or
|
|
|
|
* without modifications are expressly permitted by Whistle Communications;
|
|
|
|
* provided, however, that:
|
|
|
|
* 1. Any and all reproductions of the source or object code must include the
|
|
|
|
* copyright notice above and the following disclaimer of warranties; and
|
|
|
|
* 2. No rights are granted, in any manner or form, to use Whistle
|
|
|
|
* Communications, Inc. trademarks, including the mark "WHISTLE
|
|
|
|
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
|
|
|
* such appears in the above copyright notice or in the software.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
|
|
|
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
|
|
|
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
|
|
|
* INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
|
|
|
* WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
|
|
|
* REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
|
|
|
* SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
|
|
|
* IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
|
|
|
* RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
|
|
|
* WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
|
|
* PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
|
|
|
* OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* Author: Erik Salander <erik@whistle.com>
|
|
|
|
*/
|
|
|
|
|
2001-09-30 21:03:33 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
/* Includes */
|
|
|
|
#ifdef _KERNEL
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/limits.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#else
|
|
|
|
#include <errno.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <netinet/tcp.h>
|
|
|
|
|
|
|
|
#ifdef _KERNEL
|
|
|
|
#include <netinet/libalias/alias.h>
|
|
|
|
#include <netinet/libalias/alias_local.h>
|
|
|
|
#include <netinet/libalias/alias_mod.h>
|
|
|
|
#else
|
|
|
|
#include "alias.h"
|
|
|
|
#include "alias_local.h"
|
|
|
|
#include "alias_mod.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PPTP_CONTROL_PORT_NUMBER 1723
|
|
|
|
|
|
|
|
static void
|
|
|
|
AliasHandlePptpOut(struct libalias *, struct ip *, struct alias_link *);
|
|
|
|
|
|
|
|
static void
|
|
|
|
AliasHandlePptpIn(struct libalias *, struct ip *, struct alias_link *);
|
|
|
|
|
|
|
|
static int
|
|
|
|
AliasHandlePptpGreOut(struct libalias *, struct ip *);
|
|
|
|
|
|
|
|
static int
|
|
|
|
AliasHandlePptpGreIn(struct libalias *, struct ip *);
|
|
|
|
|
2013-12-25 02:06:57 +00:00
|
|
|
static int
|
2009-04-08 11:56:49 +00:00
|
|
|
fingerprint(struct libalias *la, struct alias_data *ah)
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
{
|
|
|
|
if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL)
|
|
|
|
return (-1);
|
|
|
|
if (ntohs(*ah->dport) == PPTP_CONTROL_PORT_NUMBER
|
|
|
|
|| ntohs(*ah->sport) == PPTP_CONTROL_PORT_NUMBER)
|
|
|
|
return (0);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
2013-12-25 02:06:57 +00:00
|
|
|
static int
|
2009-04-08 11:56:49 +00:00
|
|
|
fingerprintgre(struct libalias *la, struct alias_data *ah)
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
{
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2013-12-25 02:06:57 +00:00
|
|
|
static int
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
protohandlerin(struct libalias *la, struct ip *pip, struct alias_data *ah)
|
|
|
|
{
|
|
|
|
AliasHandlePptpIn(la, pip, ah->lnk);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2013-12-25 02:06:57 +00:00
|
|
|
static int
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
protohandlerout(struct libalias *la, struct ip *pip, struct alias_data *ah)
|
|
|
|
{
|
|
|
|
AliasHandlePptpOut(la, pip, ah->lnk);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2013-12-25 02:06:57 +00:00
|
|
|
static int
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
protohandlergrein(struct libalias *la, struct ip *pip, struct alias_data *ah)
|
|
|
|
{
|
|
|
|
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY ||
|
|
|
|
AliasHandlePptpGreIn(la, pip) == 0)
|
|
|
|
return (0);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
2013-12-25 02:06:57 +00:00
|
|
|
static int
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
protohandlergreout(struct libalias *la, struct ip *pip, struct alias_data *ah)
|
|
|
|
{
|
|
|
|
if (AliasHandlePptpGreOut(la, pip) == 0)
|
|
|
|
return (0);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Kernel module definition. */
|
|
|
|
struct proto_handler handlers[] = {
|
2013-12-25 02:06:57 +00:00
|
|
|
{
|
|
|
|
.pri = 200,
|
|
|
|
.dir = IN,
|
|
|
|
.proto = TCP,
|
|
|
|
.fingerprint = &fingerprint,
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
.protohandler = &protohandlerin
|
|
|
|
},
|
2013-12-25 02:06:57 +00:00
|
|
|
{
|
|
|
|
.pri = 210,
|
|
|
|
.dir = OUT,
|
|
|
|
.proto = TCP,
|
|
|
|
.fingerprint = &fingerprint,
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
.protohandler = &protohandlerout
|
|
|
|
},
|
2013-12-25 02:06:57 +00:00
|
|
|
/*
|
|
|
|
* WATCH OUT!!! these 2 handlers NEED a priority of INT_MAX (highest possible)
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
* cause they will ALWAYS process packets, so they must be the last one
|
|
|
|
* in chain: look fingerprintgre() above.
|
|
|
|
*/
|
2013-12-25 02:06:57 +00:00
|
|
|
{
|
|
|
|
.pri = INT_MAX,
|
|
|
|
.dir = IN,
|
|
|
|
.proto = IP,
|
|
|
|
.fingerprint = &fingerprintgre,
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
.protohandler = &protohandlergrein
|
|
|
|
},
|
2013-12-25 02:06:57 +00:00
|
|
|
{
|
|
|
|
.pri = INT_MAX,
|
|
|
|
.dir = OUT,
|
|
|
|
.proto = IP,
|
|
|
|
.fingerprint = &fingerprintgre,
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
.protohandler = &protohandlergreout
|
2013-12-25 02:06:57 +00:00
|
|
|
},
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
{ EOH }
|
|
|
|
};
|
|
|
|
static int
|
|
|
|
mod_handler(module_t mod, int type, void *data)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case MOD_LOAD:
|
|
|
|
error = 0;
|
|
|
|
LibAliasAttachHandlers(handlers);
|
|
|
|
break;
|
|
|
|
case MOD_UNLOAD:
|
|
|
|
error = 0;
|
|
|
|
LibAliasDetachHandlers(handlers);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _KERNEL
|
2013-12-25 02:06:57 +00:00
|
|
|
static
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
#endif
|
|
|
|
moduledata_t alias_mod = {
|
|
|
|
"alias_pptp", mod_handler, NULL
|
|
|
|
};
|
|
|
|
|
2021-05-14 13:08:08 +00:00
|
|
|
#ifdef _KERNEL
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
DECLARE_MODULE(alias_pptp, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND);
|
|
|
|
MODULE_VERSION(alias_pptp, 1);
|
|
|
|
MODULE_DEPEND(alias_pptp, libalias, 1, 1, 1);
|
|
|
|
#endif
|
|
|
|
|
2000-06-20 11:41:48 +00:00
|
|
|
/*
|
|
|
|
Alias_pptp.c performs special processing for PPTP sessions under TCP.
|
|
|
|
Specifically, watch PPTP control messages and alias the Call ID or the
|
|
|
|
Peer's Call ID in the appropriate messages. Note, PPTP requires
|
|
|
|
"de-aliasing" of incoming packets, this is different than any other
|
|
|
|
TCP applications that are currently (ie. FTP, IRC and RTSP) aliased.
|
|
|
|
|
2000-08-09 11:25:44 +00:00
|
|
|
For Call IDs encountered for the first time, a PPTP alias link is created.
|
|
|
|
The PPTP alias link uses the Call ID in place of the original port number.
|
2000-06-20 11:41:48 +00:00
|
|
|
An alias Call ID is created.
|
|
|
|
|
|
|
|
For this routine to work, the PPTP control messages must fit entirely
|
|
|
|
into a single TCP packet. This is typically the case, but is not
|
|
|
|
required by the spec.
|
|
|
|
|
|
|
|
Unlike some of the other TCP applications that are aliased (ie. FTP,
|
|
|
|
IRC and RTSP), the PPTP control messages that need to be aliased are
|
|
|
|
guaranteed to remain the same length. The aliased Call ID is a fixed
|
|
|
|
length field.
|
|
|
|
|
|
|
|
Reference: RFC 2637
|
|
|
|
|
|
|
|
Initial version: May, 2000 (eds)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PPTP definitions
|
|
|
|
*/
|
|
|
|
|
2021-05-14 13:08:08 +00:00
|
|
|
struct grehdr { /* Enhanced GRE header. */
|
2004-03-16 21:30:41 +00:00
|
|
|
u_int16_t gh_flags; /* Flags. */
|
|
|
|
u_int16_t gh_protocol; /* Protocol type. */
|
|
|
|
u_int16_t gh_length; /* Payload length. */
|
|
|
|
u_int16_t gh_call_id; /* Call ID. */
|
|
|
|
u_int32_t gh_seq_no; /* Sequence number (optional). */
|
|
|
|
u_int32_t gh_ack_no; /* Acknowledgment number
|
|
|
|
* (optional). */
|
2000-06-20 11:41:48 +00:00
|
|
|
};
|
2004-03-16 21:30:41 +00:00
|
|
|
typedef struct grehdr GreHdr;
|
2000-06-20 11:41:48 +00:00
|
|
|
|
|
|
|
/* The PPTP protocol ID used in the GRE 'proto' field. */
|
|
|
|
#define PPTP_GRE_PROTO 0x880b
|
|
|
|
|
|
|
|
/* Bits that must be set a certain way in all PPTP/GRE packets. */
|
|
|
|
#define PPTP_INIT_VALUE ((0x2001 << 16) | PPTP_GRE_PROTO)
|
|
|
|
#define PPTP_INIT_MASK 0xef7fffff
|
|
|
|
|
|
|
|
#define PPTP_MAGIC 0x1a2b3c4d
|
|
|
|
#define PPTP_CTRL_MSG_TYPE 1
|
|
|
|
|
|
|
|
enum {
|
2004-03-16 21:30:41 +00:00
|
|
|
PPTP_StartCtrlConnRequest = 1,
|
|
|
|
PPTP_StartCtrlConnReply = 2,
|
|
|
|
PPTP_StopCtrlConnRequest = 3,
|
|
|
|
PPTP_StopCtrlConnReply = 4,
|
|
|
|
PPTP_EchoRequest = 5,
|
|
|
|
PPTP_EchoReply = 6,
|
|
|
|
PPTP_OutCallRequest = 7,
|
|
|
|
PPTP_OutCallReply = 8,
|
|
|
|
PPTP_InCallRequest = 9,
|
|
|
|
PPTP_InCallReply = 10,
|
|
|
|
PPTP_InCallConn = 11,
|
|
|
|
PPTP_CallClearRequest = 12,
|
|
|
|
PPTP_CallDiscNotify = 13,
|
|
|
|
PPTP_WanErrorNotify = 14,
|
|
|
|
PPTP_SetLinkInfo = 15
|
|
|
|
};
|
|
|
|
|
2021-05-14 13:08:08 +00:00
|
|
|
/* Message structures */
|
2004-03-16 21:30:41 +00:00
|
|
|
struct pptpMsgHead {
|
|
|
|
u_int16_t length; /* total length */
|
|
|
|
u_int16_t msgType;/* PPTP message type */
|
|
|
|
u_int32_t magic; /* magic cookie */
|
|
|
|
u_int16_t type; /* control message type */
|
|
|
|
u_int16_t resv0; /* reserved */
|
2000-06-20 11:41:48 +00:00
|
|
|
};
|
2004-03-16 21:30:41 +00:00
|
|
|
typedef struct pptpMsgHead *PptpMsgHead;
|
2000-06-20 11:41:48 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
struct pptpCodes {
|
|
|
|
u_int8_t resCode;/* Result Code */
|
|
|
|
u_int8_t errCode;/* Error Code */
|
|
|
|
};
|
|
|
|
typedef struct pptpCodes *PptpCode;
|
|
|
|
|
|
|
|
struct pptpCallIds {
|
|
|
|
u_int16_t cid1; /* Call ID field #1 */
|
|
|
|
u_int16_t cid2; /* Call ID field #2 */
|
|
|
|
};
|
|
|
|
typedef struct pptpCallIds *PptpCallId;
|
2000-06-20 11:41:48 +00:00
|
|
|
|
|
|
|
static PptpCallId AliasVerifyPptp(struct ip *, u_int16_t *);
|
|
|
|
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
static void
|
2004-01-17 10:52:21 +00:00
|
|
|
AliasHandlePptpOut(struct libalias *la,
|
2004-03-16 21:30:41 +00:00
|
|
|
struct ip *pip, /* IP packet to examine/patch */
|
2021-05-14 13:08:08 +00:00
|
|
|
struct alias_link *lnk) /* The PPTP control link */
|
|
|
|
{
|
2004-07-05 11:10:57 +00:00
|
|
|
struct alias_link *pptp_lnk;
|
2004-03-16 21:30:41 +00:00
|
|
|
PptpCallId cptr;
|
|
|
|
PptpCode codes;
|
|
|
|
u_int16_t ctl_type; /* control message type */
|
|
|
|
struct tcphdr *tc;
|
|
|
|
|
|
|
|
/* Verify valid PPTP control message */
|
|
|
|
if ((cptr = AliasVerifyPptp(pip, &ctl_type)) == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Modify certain PPTP messages */
|
2000-10-30 12:39:41 +00:00
|
|
|
switch (ctl_type) {
|
2004-03-16 21:30:41 +00:00
|
|
|
case PPTP_OutCallRequest:
|
2000-10-30 12:39:41 +00:00
|
|
|
case PPTP_OutCallReply:
|
2004-03-16 21:30:41 +00:00
|
|
|
case PPTP_InCallRequest:
|
2000-10-30 12:39:41 +00:00
|
|
|
case PPTP_InCallReply:
|
2004-03-16 21:30:41 +00:00
|
|
|
/*
|
|
|
|
* Establish PPTP link for address and Call ID found in
|
|
|
|
* control message.
|
|
|
|
*/
|
2004-07-05 11:10:57 +00:00
|
|
|
pptp_lnk = AddPptp(la, GetOriginalAddress(lnk), GetDestAddress(lnk),
|
|
|
|
GetAliasAddress(lnk), cptr->cid1);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
case PPTP_CallClearRequest:
|
|
|
|
case PPTP_CallDiscNotify:
|
|
|
|
/*
|
|
|
|
* Find PPTP link for address and Call ID found in control
|
|
|
|
* message.
|
|
|
|
*/
|
2004-07-05 11:10:57 +00:00
|
|
|
pptp_lnk = FindPptpOutByCallId(la, GetOriginalAddress(lnk),
|
2021-05-14 13:08:08 +00:00
|
|
|
GetDestAddress(lnk), cptr->cid1);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-07-05 11:10:57 +00:00
|
|
|
if (pptp_lnk != NULL) {
|
2004-03-16 21:30:41 +00:00
|
|
|
int accumulate = cptr->cid1;
|
|
|
|
|
|
|
|
/* alias the Call Id */
|
2004-07-05 11:10:57 +00:00
|
|
|
cptr->cid1 = GetAliasPort(pptp_lnk);
|
2004-03-16 21:30:41 +00:00
|
|
|
|
|
|
|
/* Compute TCP checksum for revised packet */
|
2004-07-06 12:13:28 +00:00
|
|
|
tc = (struct tcphdr *)ip_next(pip);
|
2004-03-16 21:30:41 +00:00
|
|
|
accumulate -= cptr->cid1;
|
|
|
|
ADJUST_CHECKSUM(accumulate, tc->th_sum);
|
|
|
|
|
|
|
|
switch (ctl_type) {
|
|
|
|
case PPTP_OutCallReply:
|
|
|
|
case PPTP_InCallReply:
|
2021-05-14 13:08:08 +00:00
|
|
|
codes = (PptpCode)(cptr + 1);
|
|
|
|
if (codes->resCode == 1)
|
|
|
|
/* Connection established,
|
|
|
|
* note the Peer's Call ID. */
|
|
|
|
SetDestCallId(pptp_lnk, cptr->cid2);
|
2004-03-16 21:30:41 +00:00
|
|
|
else
|
2021-05-14 13:08:08 +00:00
|
|
|
/* Connection refused. */
|
|
|
|
SetExpire(pptp_lnk, 0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
2021-05-14 13:08:08 +00:00
|
|
|
case PPTP_CallDiscNotify:
|
|
|
|
/* Connection closed. */
|
2004-07-05 11:10:57 +00:00
|
|
|
SetExpire(pptp_lnk, 0);
|
2004-03-16 21:30:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-10-30 12:39:41 +00:00
|
|
|
}
|
2000-06-20 11:41:48 +00:00
|
|
|
}
|
|
|
|
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
static void
|
2004-03-16 21:30:41 +00:00
|
|
|
AliasHandlePptpIn(struct libalias *la,
|
|
|
|
struct ip *pip, /* IP packet to examine/patch */
|
2021-05-14 13:08:08 +00:00
|
|
|
struct alias_link *lnk) /* The PPTP control link */
|
|
|
|
{
|
2004-07-05 11:10:57 +00:00
|
|
|
struct alias_link *pptp_lnk;
|
2004-03-16 21:30:41 +00:00
|
|
|
PptpCallId cptr;
|
|
|
|
u_int16_t *pcall_id;
|
|
|
|
u_int16_t ctl_type; /* control message type */
|
|
|
|
struct tcphdr *tc;
|
|
|
|
|
|
|
|
/* Verify valid PPTP control message */
|
|
|
|
if ((cptr = AliasVerifyPptp(pip, &ctl_type)) == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Modify certain PPTP messages */
|
|
|
|
switch (ctl_type) {
|
|
|
|
case PPTP_InCallConn:
|
|
|
|
case PPTP_WanErrorNotify:
|
|
|
|
case PPTP_SetLinkInfo:
|
|
|
|
pcall_id = &cptr->cid1;
|
|
|
|
break;
|
|
|
|
case PPTP_OutCallReply:
|
|
|
|
case PPTP_InCallReply:
|
|
|
|
pcall_id = &cptr->cid2;
|
|
|
|
break;
|
2021-05-14 13:08:08 +00:00
|
|
|
case PPTP_CallDiscNotify:
|
|
|
|
/* Connection closed. */
|
2004-07-05 11:10:57 +00:00
|
|
|
pptp_lnk = FindPptpInByCallId(la, GetDestAddress(lnk),
|
2021-05-14 13:08:08 +00:00
|
|
|
GetAliasAddress(lnk), cptr->cid1);
|
2004-07-05 11:10:57 +00:00
|
|
|
if (pptp_lnk != NULL)
|
|
|
|
SetExpire(pptp_lnk, 0);
|
2004-03-16 21:30:41 +00:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find PPTP link for address and Call ID found in PPTP Control Msg */
|
2004-07-05 11:10:57 +00:00
|
|
|
pptp_lnk = FindPptpInByPeerCallId(la, GetDestAddress(lnk),
|
2021-05-14 13:08:08 +00:00
|
|
|
GetAliasAddress(lnk), *pcall_id);
|
2004-03-16 21:30:41 +00:00
|
|
|
|
2004-07-05 11:10:57 +00:00
|
|
|
if (pptp_lnk != NULL) {
|
2004-03-16 21:30:41 +00:00
|
|
|
int accumulate = *pcall_id;
|
|
|
|
|
|
|
|
/* De-alias the Peer's Call Id. */
|
2004-07-05 11:10:57 +00:00
|
|
|
*pcall_id = GetOriginalPort(pptp_lnk);
|
2004-03-16 21:30:41 +00:00
|
|
|
|
|
|
|
/* Compute TCP checksum for modified packet */
|
2004-07-06 12:13:28 +00:00
|
|
|
tc = (struct tcphdr *)ip_next(pip);
|
2004-03-16 21:30:41 +00:00
|
|
|
accumulate -= *pcall_id;
|
|
|
|
ADJUST_CHECKSUM(accumulate, tc->th_sum);
|
|
|
|
|
2021-05-14 13:08:08 +00:00
|
|
|
if (ctl_type == PPTP_OutCallReply ||
|
|
|
|
ctl_type == PPTP_InCallReply) {
|
|
|
|
PptpCode codes = (PptpCode)(cptr + 1);
|
2004-03-16 21:30:41 +00:00
|
|
|
|
2021-05-14 13:08:08 +00:00
|
|
|
if (codes->resCode == 1)
|
|
|
|
/* Connection established,
|
|
|
|
* note the Call ID. */
|
|
|
|
SetDestCallId(pptp_lnk, cptr->cid1);
|
2004-03-16 21:30:41 +00:00
|
|
|
else
|
2021-05-14 13:08:08 +00:00
|
|
|
/* Connection refused. */
|
|
|
|
SetExpire(pptp_lnk, 0);
|
2004-03-16 21:30:41 +00:00
|
|
|
}
|
|
|
|
}
|
2000-06-20 11:41:48 +00:00
|
|
|
}
|
|
|
|
|
2021-05-14 13:08:08 +00:00
|
|
|
static PptpCallId
|
|
|
|
AliasVerifyPptp(struct ip *pip, u_int16_t * ptype) /* IP packet to examine/patch */
|
|
|
|
{
|
2004-03-16 21:30:41 +00:00
|
|
|
int hlen, tlen, dlen;
|
|
|
|
PptpMsgHead hptr;
|
|
|
|
struct tcphdr *tc;
|
|
|
|
|
|
|
|
/* Calculate some lengths */
|
2004-07-06 12:13:28 +00:00
|
|
|
tc = (struct tcphdr *)ip_next(pip);
|
2004-03-16 21:30:41 +00:00
|
|
|
hlen = (pip->ip_hl + tc->th_off) << 2;
|
|
|
|
tlen = ntohs(pip->ip_len);
|
|
|
|
dlen = tlen - hlen;
|
|
|
|
|
|
|
|
/* Verify data length */
|
2004-07-05 11:10:57 +00:00
|
|
|
if (dlen < (int)(sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds)))
|
2004-03-16 21:30:41 +00:00
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
/* Move up to PPTP message header */
|
2021-05-14 13:08:08 +00:00
|
|
|
hptr = (PptpMsgHead)tcp_next(tc);
|
2004-03-16 21:30:41 +00:00
|
|
|
|
|
|
|
/* Return the control message type */
|
|
|
|
*ptype = ntohs(hptr->type);
|
|
|
|
|
|
|
|
/* Verify PPTP Control Message */
|
|
|
|
if ((ntohs(hptr->msgType) != PPTP_CTRL_MSG_TYPE) ||
|
|
|
|
(ntohl(hptr->magic) != PPTP_MAGIC))
|
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
/* Verify data length. */
|
|
|
|
if ((*ptype == PPTP_OutCallReply || *ptype == PPTP_InCallReply) &&
|
2004-07-05 11:10:57 +00:00
|
|
|
(dlen < (int)(sizeof(struct pptpMsgHead) + sizeof(struct pptpCallIds) +
|
|
|
|
sizeof(struct pptpCodes))))
|
2004-03-16 21:30:41 +00:00
|
|
|
return (NULL);
|
|
|
|
else
|
2021-05-14 13:08:08 +00:00
|
|
|
return ((PptpCallId)(hptr + 1));
|
2000-10-30 12:39:41 +00:00
|
|
|
}
|
|
|
|
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
static int
|
2004-01-17 10:52:21 +00:00
|
|
|
AliasHandlePptpGreOut(struct libalias *la, struct ip *pip)
|
2000-10-30 12:39:41 +00:00
|
|
|
{
|
2004-03-16 21:30:41 +00:00
|
|
|
GreHdr *gr;
|
2004-07-05 11:10:57 +00:00
|
|
|
struct alias_link *lnk;
|
2000-10-30 12:39:41 +00:00
|
|
|
|
2021-05-14 13:08:08 +00:00
|
|
|
gr = (GreHdr *)ip_next(pip);
|
2000-10-30 12:39:41 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
/* Check GRE header bits. */
|
2021-05-14 13:08:08 +00:00
|
|
|
if ((ntohl(*((u_int32_t *)gr)) & PPTP_INIT_MASK) != PPTP_INIT_VALUE)
|
2004-03-16 21:30:41 +00:00
|
|
|
return (-1);
|
2000-10-30 12:39:41 +00:00
|
|
|
|
2004-07-05 11:10:57 +00:00
|
|
|
lnk = FindPptpOutByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
|
|
|
|
if (lnk != NULL) {
|
|
|
|
struct in_addr alias_addr = GetAliasAddress(lnk);
|
2000-10-30 12:39:41 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
/* Change source IP address. */
|
|
|
|
DifferentialChecksum(&pip->ip_sum,
|
2004-03-31 21:32:58 +00:00
|
|
|
&alias_addr, &pip->ip_src, 2);
|
2004-03-16 21:30:41 +00:00
|
|
|
pip->ip_src = alias_addr;
|
|
|
|
}
|
|
|
|
return (0);
|
2000-10-30 12:39:41 +00:00
|
|
|
}
|
|
|
|
|
Summer of Code 2005: improve libalias - part 1 of 2
With the first part of my previous Summer of Code work, we get:
-made libalias modular:
-support for 'particular' protocols (like ftp/irc/etcetc) is no more
hardcoded inside libalias, but it's available through external
modules loadable at runtime
-modules are available both in kernel (/boot/kernel/alias_*.ko) and
user land (/lib/libalias_*)
-protocols/applications modularized are: cuseeme, ftp, irc, nbt, pptp,
skinny and smedia
-added logging support for kernel side
-cleanup
After a buildworld, do a 'mergemaster -i' to install the file libalias.conf
in /etc or manually copy it.
During startup (and after every HUP signal) user land applications running
the new libalias will try to read a file in /etc called libalias.conf:
that file contains the list of modules to load.
User land applications affected by this commit are ppp and natd:
if libalias.conf is present in /etc you won't notice any difference.
The only kernel land bit affected by this commit is ng_nat:
if you are using ng_nat, and it doesn't correctly handle
ftp/irc/etcetc sessions anymore, remember to kldload
the correspondent module (i.e. kldload alias_ftp).
General information and details about the inner working are available
in the libalias man page under the section 'MODULAR ARCHITECTURE
(AND ipfw(4) SUPPORT)'.
NOTA BENE: this commit affects _ONLY_ libalias, ipfw in-kernel nat
support will be part of the next libalias-related commit.
Approved by: glebius
Reviewed by: glebius, ru
2006-09-26 23:26:53 +00:00
|
|
|
static int
|
2004-01-17 10:52:21 +00:00
|
|
|
AliasHandlePptpGreIn(struct libalias *la, struct ip *pip)
|
2000-10-30 12:39:41 +00:00
|
|
|
{
|
2004-03-16 21:30:41 +00:00
|
|
|
GreHdr *gr;
|
2004-07-05 11:10:57 +00:00
|
|
|
struct alias_link *lnk;
|
2000-10-30 12:39:41 +00:00
|
|
|
|
2021-05-14 13:08:08 +00:00
|
|
|
gr = (GreHdr *)ip_next(pip);
|
2000-10-30 12:39:41 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
/* Check GRE header bits. */
|
2021-05-14 13:08:08 +00:00
|
|
|
if ((ntohl(*((u_int32_t *)gr)) & PPTP_INIT_MASK) != PPTP_INIT_VALUE)
|
2004-03-16 21:30:41 +00:00
|
|
|
return (-1);
|
2000-10-30 12:39:41 +00:00
|
|
|
|
2004-07-05 11:10:57 +00:00
|
|
|
lnk = FindPptpInByPeerCallId(la, pip->ip_src, pip->ip_dst, gr->gh_call_id);
|
|
|
|
if (lnk != NULL) {
|
|
|
|
struct in_addr src_addr = GetOriginalAddress(lnk);
|
2000-10-30 12:39:41 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
/* De-alias the Peer's Call Id. */
|
2004-07-05 11:10:57 +00:00
|
|
|
gr->gh_call_id = GetOriginalPort(lnk);
|
2000-10-30 12:39:41 +00:00
|
|
|
|
2004-03-16 21:30:41 +00:00
|
|
|
/* Restore original IP address. */
|
|
|
|
DifferentialChecksum(&pip->ip_sum,
|
2004-03-31 21:32:58 +00:00
|
|
|
&src_addr, &pip->ip_dst, 2);
|
2004-03-16 21:30:41 +00:00
|
|
|
pip->ip_dst = src_addr;
|
|
|
|
}
|
|
|
|
return (0);
|
2000-06-20 11:41:48 +00:00
|
|
|
}
|