2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5 * WvIpSecGuide is a "gateway" object that groups all the routes
6 * belonging to one IPSec Tunnel.
10 #include "wvipsecguide.h"
11 #include "wvipseckeeper.h"
18 WvIpSecGuide::WvIpSecGuide(WvIpSecKeeper
*_parent
, const WvIPAddr
&_gateway
)
19 : WvNGRouteContainer(_parent
), cfg(_parent
->cfg
), keeper(*_parent
),
20 log("WvIpSecGuide", WvLog::Debug3
)
27 WvIPAddr
addr(cfg
.get("Global", "IPAddr", "192.168.42.42"));
28 tundev
= new WvTunDev(addr
, 1400 /*mtu*/);
32 metric() = METRIC_TUNNEL
;
33 ifcname() = tundev
->ifcname
;
35 keeper
.selectlist
.append(&selectlist
, false);
40 WvIpSecGuide::~WvIpSecGuide()
46 selectlist
.unlink(isakmp
);
60 void WvIpSecGuide::changed_sa(int spi
, WvCryptoEncoder
*enc
,
61 WvCryptoEncoder
*dec
, WvIsaKmp::actions action
)
67 case WvIsaKmp::Create
:
69 selectlist
.seterr("Multiple esp connections not supported!\n");
72 esp
= new WvEsp(this, cfg
);
74 esp
->set_cryptcoders(enc
, dec
);
75 esp
->set_tundev(tundev
);
76 // shouldn't have to add to selectlist, cause that already happens
77 // and WvEsp isn't a stream anyways :)
80 case WvIsaKmp::Change
:
82 case WvIsaKmp::Delete
:
90 selectlist
.seterr("Something fishy - trying to delete non-existant esp!\n");
94 log(WvLog::Error
, "How did we get here??");
95 selectlist
.seterr("Weasels are NOT funny!\n");
99 void WvIpSecGuide::create_routes()
104 void WvIpSecGuide::forget_my_routes()
109 void WvIpSecGuide::start_isakmp()
111 WvString localaddr
= cfg
.get("Global", "IPAddr", "192.168.42.42");
112 WvString remoteaddr
= cfg
.get("WvIpSec", "connection", "10.1.0.10");
113 WvString shared_secret
= cfg
.get("WvIpSec", "Preshared key", NULL
);
115 isakmp
= new WvIsaKmp(cfg
, true, shared_secret
, localaddr
, remoteaddr
);
116 isakmp
->set_espcallback(WvIsaKmp::EspCallback(this, &WvIpSecGuide::changed_sa
));
117 selectlist
.append(isakmp
, true);