Skip to content

Commit

Permalink
Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszmrugalski committed Jun 21, 2004
1 parent 2ff9306 commit 503ca2c
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 67 deletions.
7 changes: 5 additions & 2 deletions AddrMgr/AddrIA.cpp
Expand Up @@ -6,9 +6,12 @@
*
* released under GNU GPL v2 or later licence
*
* $Id: AddrIA.cpp,v 1.5 2004-06-04 19:03:46 thomson Exp $
* $Id: AddrIA.cpp,v 1.6 2004-06-21 23:08:48 thomson Exp $
*
* $Log: not supported by cvs2svn $
* Revision 1.5 2004/06/04 19:03:46 thomson
* Resolved warnings with signed/unisigned
*
* Revision 1.4 2004/03/29 22:06:49 thomson
* 0.1.1 version
*
Expand Down Expand Up @@ -185,7 +188,7 @@ int TAddrIA::delAddr(SmartPtr<TIPv6Addr> addr)
return 0;
}
}
return 0; //FIXME
return -1;
}

int TAddrIA::getAddrCount()
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG
Expand Up @@ -10,6 +10,8 @@
- Doc: Now it is a real documentation
- Srv: class-max-lease, iface-max-lease parameters added
- Client: config file logic changed, no-config is no longer needed.
- Client: No more stupid "Interface is loopback, down, not multicast-capable or
not present in the system" message.
- Linux: build process rewritten

0.1.1
Expand Down
47 changes: 17 additions & 30 deletions Messages/Msg.cpp
Expand Up @@ -85,7 +85,6 @@ bool TMsg::check()

void TMsg::send()
{
//FIXME:what the hell means this is not initialized pointer
char *tmppkt = this->pkt;

*(tmppkt++) = (char)MsgType;
Expand All @@ -99,54 +98,42 @@ void TMsg::send()
Option->storeSelf(tmppkt);
tmppkt += Option->getSize();
}
}


// FIXME: So we have constructed a message. Should we send it?
SmartPtr<TOpt> TMsg::getOption(int type) {
SmartPtr<TOpt> Option;

Options.first();
while ( Option = Options.get() ) {
if (Option->getOptType()==type)
return Option;
}
return SmartPtr<TOpt>();
}

SmartPtr<TOpt> TMsg::getOption(int type)
{
SmartPtr<TOpt> Option;

Options.first();
while ( Option = Options.get() )
{
if (Option->getOptType()==type)
return Option;
}
return SmartPtr<TOpt>();
}

void TMsg::firstOption()
{
void TMsg::firstOption() {
Options.first();
}

int TMsg::countOption()
{
int TMsg::countOption() {
return Options.count();
}

SmartPtr<TOpt> TMsg::getOption()
{
SmartPtr<TOpt> TMsg::getOption() {
return Options.get();
}

TMsg::~TMsg()
{
TMsg::~TMsg() {
}

SmartPtr<TIPv6Addr> TMsg::getAddr()
{
SmartPtr<TIPv6Addr> TMsg::getAddr() {
return PeerAddr;
}

int TMsg::getIface()
{
int TMsg::getIface() {
return this->Iface;
}

bool TMsg::isDone()
{
bool TMsg::isDone() {
return IsDone;
}
26 changes: 6 additions & 20 deletions Port-win32/WinService.cpp
Expand Up @@ -6,9 +6,12 @@
*
* Released under GNU GPL v2 licence
*
* $Id: WinService.cpp,v 1.7 2004-05-24 21:16:37 thomson Exp $
* $Id: WinService.cpp,v 1.8 2004-06-21 23:08:49 thomson Exp $
*
* $Log: not supported by cvs2svn $
* Revision 1.7 2004/05/24 21:16:37 thomson
* Various fixes.
*
* Revision 1.6 2004/04/15 23:53:45 thomson
* Pathname installation fixed, run-time error checks disabled, winXP code cleanup.
*
Expand Down Expand Up @@ -59,13 +62,11 @@ void TWinService::ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv)
// Get a pointer to the C++ object
TWinService* pService = ServicePtr;

//FIXME:pService->DebugMsg("Entering CNTService::ServiceMain()");
// Register the control request handler
pService->Status.dwCurrentState = SERVICE_START_PENDING;
pService->hServiceStatus = RegisterServiceCtrlHandler(pService->ServiceName,Handler);
if (pService->hServiceStatus==NULL)
{
//FIXME:pService->LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_CTRLHANDLERNOTINSTALLED);
return;
}
// Start the initialisation
Expand All @@ -81,21 +82,18 @@ void TWinService::ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv)
}
// Tell the service manager we are stopped
pService->SetStatus(SERVICE_STOPPED);
//FIXME:pService->DebugMsg("Leaving CNTService::ServiceMain()");
}

void TWinService::Handler(DWORD dwOpcode) {
//DebugBreak();
// Get a pointer to the object
TWinService* pService = ServicePtr;

//FIXME:pService->DebugMsg("CNTService::Handler(%lu)", dwOpcode);
switch (dwOpcode) {
case SERVICE_CONTROL_STOP: // 1
pService->SetStatus(SERVICE_STOP_PENDING);
pService->OnStop();
pService->IsRunning = FALSE;
//FIXME:pService->LogEvent(EVENTLOG_INFORMATION_TYPE, EVMSG_STOPPED);
break;

case SERVICE_CONTROL_PAUSE: // 2
Expand All @@ -119,20 +117,15 @@ void TWinService::Handler(DWORD dwOpcode) {
{
if (!pService->OnUserControl(dwOpcode))
{
//FIXME:pService->LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_BADREQUEST);
}
}
else
{
//FIXME:pService->LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_BADREQUEST);
}
break;
}

// Report current status
//FIXME:pService->DebugMsg("Updating status (%lu, %lu)",
// pService->m_hServiceStatus,
// pService->m_Status.dwCurrentState);
SetServiceStatus(pService->hServiceStatus, &pService->Status);
}

Expand Down Expand Up @@ -265,22 +258,18 @@ bool TWinService::StartService()
{ServiceName, ServiceMain},
{NULL, NULL}
};
//FIXME:DebugMsg("Calling StartServiceCtrlDispatcher()");
BOOL result = StartServiceCtrlDispatcher(st);
//FIXME:DebugMsg("Returned from StartServiceCtrlDispatcher()");
return result?true:false;
return result?true:false;
}

void TWinService::SetStatus(DWORD dwState)
{
//FIXME:DebugMsg("CNTService::SetStatus(%lu, %lu)", m_hServiceStatus, dwState);
Status.dwCurrentState = dwState;
SetServiceStatus(hServiceStatus, &Status);
}

bool TWinService::Initialize()
{
//FIXME:DebugMsg("Entering CNTService::Initialize()");
// Start the initialization
SetStatus(SERVICE_START_PENDING);
// Perform the actual initialization
Expand All @@ -290,13 +279,10 @@ bool TWinService::Initialize()
Status.dwCheckPoint = 0;
Status.dwWaitHint = 0;
if (!result) {
//FIXME:LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_FAILEDINIT);
SetStatus(SERVICE_STOPPED);
return false;
}
//FIXME:LogEvent(EVENTLOG_INFORMATION_TYPE, EVMSG_STARTED);
SetStatus(SERVICE_RUNNING);
//FIXME:DebugMsg("Leaving CNTService::Initialize()");
return true;
}
void TWinService::Run()
Expand Down Expand Up @@ -370,4 +356,4 @@ void TWinService::showStatus() {
std::clog << "Dibbler client :" << (clientInstalled?"INSTALLED":"NOT INSTALLED")
<< logger::endl;
std::clog << "Client running: " << (this->isRunning("DHCPv6Client") ? "YES":"NO") << logger::endl;
}
}
7 changes: 5 additions & 2 deletions SrvAddrMgr/SrvAddrMgr.cpp
Expand Up @@ -6,9 +6,12 @@
*
* released under GNU GPL v2 or later licence
*
* $Id: SrvAddrMgr.cpp,v 1.5 2004-06-20 21:00:26 thomson Exp $
* $Id: SrvAddrMgr.cpp,v 1.6 2004-06-21 23:08:48 thomson Exp $
*
* $Log: not supported by cvs2svn $
* Revision 1.5 2004/06/20 21:00:26 thomson
* quiet flag added.
*
* Revision 1.4 2004/06/20 19:29:23 thomson
* New address assignment finally works.
*
Expand Down Expand Up @@ -171,7 +174,7 @@ bool TSrvAddrMgr::delClntAddr(SmartPtr<TDUID> clntDuid,
/*
* how many addresses does this client have?
*/
unsigned long TSrvAddrMgr::getAddrCount(SmartPtr<TDUID> duid, int iface)
unsigned long TSrvAddrMgr::getAddrCount(SmartPtr<TDUID> duid)
{
SmartPtr <TAddrClient> ptrClient;
ClntsLst.first();
Expand Down
7 changes: 5 additions & 2 deletions SrvAddrMgr/SrvAddrMgr.h
Expand Up @@ -6,9 +6,12 @@
*
* released under GNU GPL v2 or later licence
*
* $Id: SrvAddrMgr.h,v 1.3 2004-06-20 21:00:26 thomson Exp $
* $Id: SrvAddrMgr.h,v 1.4 2004-06-21 23:08:48 thomson Exp $
*
* $Log: not supported by cvs2svn $
* Revision 1.3 2004/06/20 21:00:26 thomson
* quiet flag added.
*
* Revision 1.2 2004/06/17 23:53:54 thomson
* Server Address Assignment rewritten.
*
Expand All @@ -35,7 +38,7 @@ class TSrvAddrMgr : public TAddrMgr
bool quiet);

// how many addresses does this client have?
unsigned long getAddrCount(SmartPtr<TDUID> duid, int iface);
unsigned long getAddrCount(SmartPtr<TDUID> duid);

void doDuties();

Expand Down
20 changes: 11 additions & 9 deletions SrvOptions/SrvOptIA_NA.cpp
Expand Up @@ -6,9 +6,12 @@
*
* released under GNU GPL v2 or later licence
*
* $Id: SrvOptIA_NA.cpp,v 1.5 2004-06-20 21:00:45 thomson Exp $
* $Id: SrvOptIA_NA.cpp,v 1.6 2004-06-21 23:08:49 thomson Exp $
*
* $Log: not supported by cvs2svn $
* Revision 1.5 2004/06/20 21:00:45 thomson
* Various fixes.
*
* Revision 1.4 2004/06/20 19:29:23 thomson
* New address assignment finally works.
*
Expand Down Expand Up @@ -135,16 +138,15 @@ TSrvOptIA_NA::TSrvOptIA_NA(SmartPtr<TSrvAddrMgr> addrMgr, SmartPtr<TSrvCfgMgr>
}

// --- check address counts, how many we've got, how many assigned etc. ---
unsigned long addrsAssigned;
unsigned long addrsRequested;
unsigned long addrsFree;
unsigned long addrsMax;
unsigned long addrsAssigned = 0;
unsigned long addrsRequested = 0;
unsigned long addrsFree = 0;
unsigned long addrsMax = 0;

addrsAssigned = addrMgr->getAddrCount(clntDuid, iface);
addrsAssigned = addrMgr->getAddrCount(clntDuid);
addrsRequested= queryOpt->countAddrs();
addrsFree = this->countFreeAddrsForClient();
addrsMax = cfgMgr->getMaxAddrsPerClient(clntDuid, clntAddr, iface);
addrsAssigned = 0;

Log(Debug) << "Client got " << addrsAssigned << " addrs, requests for "
<< addrsRequested << ", " << addrsFree << " is free, max. "
Expand Down Expand Up @@ -271,7 +273,7 @@ unsigned long TSrvOptIA_NA::countFreeAddrsForClient()
maxAddrs = this->CfgMgr->getMaxAddrsPerClient(this->ClntDuid,
this->ClntAddr,
this->Iface) -
this->AddrMgr->getAddrCount(this->ClntDuid, this->Iface);
this->AddrMgr->getAddrCount(this->ClntDuid);

// FIXME: unsigned long long long int (128bit) type would come in handy here
SmartPtr<TSrvCfgAddrClass> ptrClass;
Expand All @@ -292,7 +294,7 @@ unsigned long TSrvOptIA_NA::countFreeAddrsForClient()
}
}
//substract addresses which has been already assigned to this client
tmpcnt -= this->AddrMgr->getAddrCount(this->ClntDuid, this->Iface);
tmpcnt -= this->AddrMgr->getAddrCount(this->ClntDuid);

float bigNumber = this->CfgMgr->getFreeAddrsCount(this->ClntDuid, this->ClntAddr, this->Iface);
if (maxAddrs > bigNumber ) {
Expand Down
3 changes: 1 addition & 2 deletions WILD-IDEAS
@@ -1,5 +1,5 @@

WILD IDEAS $Id: WILD-IDEAS,v 1.6 2004-06-05 23:38:08 thomson Exp $
WILD IDEAS $Id: WILD-IDEAS,v 1.7 2004-06-21 23:08:48 thomson Exp $
------------

This file contains various ideas and concepts which are not yet approved.
Expand All @@ -10,4 +10,3 @@
pointer to my handler". When system receives an option, looks in option table.
If it finds appropriate handler, it passes nessesary data (4xMgr, parent-option ptr,
msg ptr). If not, drops this option.
- interoperability: is IA without IAADDR (received from client) legal?

0 comments on commit 503ca2c

Please sign in to comment.