Use Visual Studio .NET 2005.
authorThomas Lopatic <thomas@lopatic.de>
Tue, 27 Mar 2007 03:01:12 +0000 (03:01 +0000)
committerThomas Lopatic <thomas@lopatic.de>
Tue, 27 Mar 2007 03:01:12 +0000 (03:01 +0000)
45 files changed:
gui/win32/Frontend.dsw [deleted file]
gui/win32/Frontend.ncb [deleted file]
gui/win32/Frontend.opt [deleted file]
gui/win32/Main/Frontend.clw [deleted file]
gui/win32/Main/Frontend.cpp
gui/win32/Main/Frontend.dsp [deleted file]
gui/win32/Main/Frontend.h
gui/win32/Main/Frontend.rc
gui/win32/Main/FrontendDlg.cpp
gui/win32/Main/FrontendDlg.h
gui/win32/Main/HnaEntry.cpp
gui/win32/Main/HnaEntry.h
gui/win32/Main/Ipc.h
gui/win32/Main/LQ-Default.olsr
gui/win32/Main/Main.vcproj [new file with mode: 0644]
gui/win32/Main/MidEntry.cpp
gui/win32/Main/MidEntry.h
gui/win32/Main/MprEntry.cpp
gui/win32/Main/MprEntry.h
gui/win32/Main/MyDialog1.cpp
gui/win32/Main/MyDialog1.h
gui/win32/Main/MyDialog2.cpp
gui/win32/Main/MyDialog2.h
gui/win32/Main/MyDialog3.cpp
gui/win32/Main/MyDialog3.h
gui/win32/Main/MyDialog4.cpp
gui/win32/Main/MyDialog4.h
gui/win32/Main/MyEdit.cpp
gui/win32/Main/MyEdit.h
gui/win32/Main/MyTabCtrl.cpp
gui/win32/Main/MyTabCtrl.h
gui/win32/Main/NodeEntry.cpp
gui/win32/Main/NodeEntry.h
gui/win32/Main/RFC-Default.olsr
gui/win32/Main/StdAfx.cpp
gui/win32/Main/StdAfx.h
gui/win32/Main/Switch.exe.manifest [deleted file]
gui/win32/Main/TrayIcon.cpp
gui/win32/Main/TrayIcon.h
gui/win32/Main/res/Frontend.rc2
gui/win32/Main/resource.h
gui/win32/Shim/Shim.dsp [deleted file]
gui/win32/Shim/Shim.vcproj [new file with mode: 0644]
gui/win32/Shim/shim.c
gui/win32/Switch.sln [new file with mode: 0644]

diff --git a/gui/win32/Frontend.dsw b/gui/win32/Frontend.dsw
deleted file mode 100644 (file)
index 5078a71..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00\r
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r
-\r
-###############################################################################\r
-\r
-Project: "Frontend"=.\Main\Frontend.dsp - Package Owner=<4>\r
-\r
-Package=<5>\r
-{{{\r
-}}}\r
-\r
-Package=<4>\r
-{{{\r
-}}}\r
-\r
-###############################################################################\r
-\r
-Project: "Shim"=.\Shim\Shim.dsp - Package Owner=<4>\r
-\r
-Package=<5>\r
-{{{\r
-}}}\r
-\r
-Package=<4>\r
-{{{\r
-}}}\r
-\r
-###############################################################################\r
-\r
-Global:\r
-\r
-Package=<5>\r
-{{{\r
-}}}\r
-\r
-Package=<3>\r
-{{{\r
-}}}\r
-\r
-###############################################################################\r
-\r
diff --git a/gui/win32/Frontend.ncb b/gui/win32/Frontend.ncb
deleted file mode 100644 (file)
index 81a38a9..0000000
Binary files a/gui/win32/Frontend.ncb and /dev/null differ
diff --git a/gui/win32/Frontend.opt b/gui/win32/Frontend.opt
deleted file mode 100644 (file)
index 8ec1ba3..0000000
Binary files a/gui/win32/Frontend.opt and /dev/null differ
diff --git a/gui/win32/Main/Frontend.clw b/gui/win32/Main/Frontend.clw
deleted file mode 100644 (file)
index a001b3b..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-; CLW file contains information for the MFC ClassWizard\r
-\r
-[General Info]\r
-Version=1\r
-LastClass=MyDialog2\r
-LastTemplate=CDialog\r
-NewFileInclude1=#include "stdafx.h"\r
-NewFileInclude2=#include "frontend.h"\r
-LastPage=0\r
-\r
-ClassCount=8\r
-Class1=CFrontendApp\r
-Class2=CFrontendDlg\r
-Class3=MyDialog1\r
-Class4=MyDialog2\r
-Class5=MyDialog3\r
-Class6=MyDialog4\r
-Class7=MyEdit\r
-Class8=MyTabCtrl\r
-\r
-ResourceCount=6\r
-Resource1=IDD_DIALOG2\r
-Resource2=IDD_DIALOG1\r
-Resource3=IDD_DIALOG4\r
-Resource4=IDD_DIALOG3\r
-Resource5=IDD_FRONTEND_DIALOG\r
-Resource6=IDR_TRAYMENU\r
-\r
-[CLS:CFrontendApp]\r
-Type=0\r
-BaseClass=CWinApp\r
-HeaderFile=Frontend.h\r
-ImplementationFile=Frontend.cpp\r
-LastObject=CFrontendApp\r
-\r
-[CLS:CFrontendDlg]\r
-Type=0\r
-BaseClass=CDialog\r
-HeaderFile=FrontendDlg.h\r
-ImplementationFile=FrontendDlg.cpp\r
-LastObject=CFrontendDlg\r
-\r
-[CLS:MyDialog1]\r
-Type=0\r
-BaseClass=CDialog\r
-HeaderFile=MyDialog1.h\r
-ImplementationFile=MyDialog1.cpp\r
-Filter=D\r
-LastObject=MyDialog1\r
-\r
-[CLS:MyDialog2]\r
-Type=0\r
-BaseClass=CDialog\r
-HeaderFile=MyDialog2.h\r
-ImplementationFile=MyDialog2.cpp\r
-Filter=D\r
-VirtualFilter=dWC\r
-LastObject=IDC_EDIT7\r
-\r
-[CLS:MyDialog3]\r
-Type=0\r
-BaseClass=CDialog\r
-HeaderFile=MyDialog3.h\r
-ImplementationFile=MyDialog3.cpp\r
-Filter=D\r
-VirtualFilter=dWC\r
-LastObject=IDC_LIST1\r
-\r
-[CLS:MyDialog4]\r
-Type=0\r
-BaseClass=CDialog\r
-HeaderFile=MyDialog4.h\r
-ImplementationFile=MyDialog4.cpp\r
-\r
-[CLS:MyEdit]\r
-Type=0\r
-BaseClass=CEdit\r
-HeaderFile=MyEdit.h\r
-ImplementationFile=MyEdit.cpp\r
-\r
-[CLS:MyTabCtrl]\r
-Type=0\r
-BaseClass=CTabCtrl\r
-HeaderFile=MyTabCtrl.h\r
-ImplementationFile=MyTabCtrl.cpp\r
-\r
-[DLG:IDD_FRONTEND_DIALOG]\r
-Type=1\r
-Class=CFrontendDlg\r
-ControlCount=4\r
-Control1=IDC_TAB1,SysTabControl32,1342177280\r
-Control2=IDC_BUTTON1,button,1342242816\r
-Control3=IDC_BUTTON2,button,1342242816\r
-Control4=IDC_BUTTON3,button,1342242816\r
-\r
-[DLG:IDD_DIALOG1]\r
-Type=1\r
-Class=MyDialog1\r
-ControlCount=5\r
-Control1=IDC_EDIT1,edit,1353783300\r
-Control2=IDC_BUTTON3,button,1342242816\r
-Control3=IDC_BUTTON2,button,1342242816\r
-Control4=IDC_BUTTON4,button,1342242816\r
-Control5=IDC_BUTTON1,button,1342242816\r
-\r
-[DLG:IDD_DIALOG2]\r
-Type=1\r
-Class=MyDialog2\r
-ControlCount=53\r
-Control1=IDC_LIST1,SysListView32,1350631427\r
-Control2=IDC_SLIDER2,msctls_trackbar32,1342242825\r
-Control3=IDC_EDIT7,edit,1350631426\r
-Control4=IDC_CHECK3,button,1476460547\r
-Control5=IDC_CHECK2,button,1342242819\r
-Control6=IDC_EDIT1,edit,1350631426\r
-Control7=IDC_EDIT2,edit,1350631426\r
-Control8=IDC_EDIT3,edit,1350631426\r
-Control9=IDC_EDIT9,edit,1350631426\r
-Control10=IDC_EDIT4,edit,1350631426\r
-Control11=IDC_EDIT10,edit,1350631426\r
-Control12=IDC_EDIT5,edit,1350631426\r
-Control13=IDC_EDIT6,edit,1350631426\r
-Control14=IDC_COMBO1,combobox,1344340227\r
-Control15=IDC_EDIT15,edit,1350639618\r
-Control16=IDC_CHECK1,button,1342242819\r
-Control17=IDC_EDIT12,edit,1350631426\r
-Control18=IDC_EDIT13,edit,1350631426\r
-Control19=IDC_EDIT11,edit,1350631426\r
-Control20=IDC_CHECK4,button,1342242819\r
-Control21=IDC_RADIO1,button,1342373897\r
-Control22=IDC_RADIO2,button,1342373897\r
-Control23=IDC_EDIT14,edit,1350639618\r
-Control24=IDC_BUTTON4,button,1342242816\r
-Control25=IDC_BUTTON5,button,1342242816\r
-Control26=IDC_BUTTON1,button,1342242816\r
-Control27=IDC_STATIC,static,1342308352\r
-Control28=IDC_STATIC,static,1342308352\r
-Control29=IDC_STATIC,static,1342308354\r
-Control30=IDC_STATIC,static,1342308354\r
-Control31=IDC_STATIC,static,1342308354\r
-Control32=IDC_STATIC,static,1342308354\r
-Control33=IDC_STATIC,static,1342308354\r
-Control34=IDC_STATIC,static,1342308354\r
-Control35=IDC_STATIC,static,1342308354\r
-Control36=IDC_STATIC,static,1342308354\r
-Control37=IDC_STATIC,static,1342308354\r
-Control38=IDC_STATIC,static,1342308354\r
-Control39=IDC_STATIC,static,1342308352\r
-Control40=IDC_STATIC,static,1342308352\r
-Control41=IDC_STATIC,static,1342308352\r
-Control42=IDC_STATIC,static,1342308352\r
-Control43=IDC_STATIC,static,1342308352\r
-Control44=IDC_STATIC,static,1342308352\r
-Control45=IDC_STATIC,static,1342308352\r
-Control46=IDC_STATIC,static,1342308352\r
-Control47=IDC_STATIC,static,1342308354\r
-Control48=IDC_STATIC,static,1342308352\r
-Control49=IDC_TEXT1,static,1342308353\r
-Control50=IDC_STATIC,static,1342308354\r
-Control51=IDC_STATIC,static,1342308354\r
-Control52=IDC_STATIC,static,1342308354\r
-Control53=IDC_STATIC,static,1342308354\r
-\r
-[DLG:IDD_DIALOG3]\r
-Type=1\r
-Class=MyDialog3\r
-ControlCount=6\r
-Control1=IDC_LIST1,SysListView32,1350631429\r
-Control2=IDC_LIST4,SysListView32,1350631429\r
-Control3=IDC_LIST5,SysListView32,1350631429\r
-Control4=IDC_LIST6,SysListView32,1350631429\r
-Control5=IDC_STATIC,static,1342308352\r
-Control6=IDC_STATIC,static,1342308352\r
-\r
-[DLG:IDD_DIALOG4]\r
-Type=1\r
-Class=MyDialog4\r
-ControlCount=2\r
-Control1=IDC_LIST1,SysListView32,1350631425\r
-Control2=IDC_STATIC,static,1342308352\r
-\r
-[MNU:IDR_TRAYMENU]\r
-Type=1\r
-Class=?\r
-Command1=IDM_START\r
-Command2=IDM_STOP\r
-Command3=IDM_WINDOW\r
-Command4=IDM_SETTINGS\r
-Command5=IDM_OUTPUT\r
-Command6=IDM_EXIT\r
-CommandCount=6\r
-\r
index dbecb58..57ceeaf 100644 (file)
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: Frontend.cpp,v 1.7 2005/01/17 11:52:35 tlopatic Exp $\r
- */\r
-\r
-#include "stdafx.h"\r
-#include "Frontend.h"\r
-#include "FrontendDlg.h"\r
-#include "TrayIcon.h"\r
-\r
-#ifdef _DEBUG\r
-#define new DEBUG_NEW\r
-#undef THIS_FILE\r
-static char THIS_FILE[] = __FILE__;\r
-#endif\r
-\r
-BEGIN_MESSAGE_MAP(CFrontendApp, CWinApp)\r
-       //{{AFX_MSG_MAP(CFrontendApp)\r
-       //}}AFX_MSG\r
-       ON_COMMAND(ID_HELP, CWinApp::OnHelp)\r
-END_MESSAGE_MAP()\r
-\r
-CFrontendApp::CFrontendApp()\r
-{\r
-}\r
-\r
-CFrontendApp theApp;\r
-\r
-static int SetEnableRedirKey(unsigned long New)\r
-{\r
-       HKEY Key;\r
-       unsigned long Type;\r
-       unsigned long Len;\r
-       unsigned long Old;\r
-       \r
-       if (::RegOpenKeyEx(HKEY_LOCAL_MACHINE,\r
-               "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",\r
-               0, KEY_READ | KEY_WRITE, &Key) != ERROR_SUCCESS)\r
-               return -1;\r
-       \r
-       Len = sizeof (Old);\r
-       \r
-       if (::RegQueryValueEx(Key, "EnableICMPRedirect", NULL, &Type,\r
-               (unsigned char *)&Old, &Len) != ERROR_SUCCESS ||\r
-               Type != REG_DWORD)\r
-               Old = 1;\r
-       \r
-       if (::RegSetValueEx(Key, "EnableICMPRedirect", 0, REG_DWORD,\r
-               (unsigned char *)&New, sizeof (New)))\r
-       {\r
-               ::RegCloseKey(Key);\r
-               return -1;\r
-       }\r
-       \r
-       ::RegCloseKey(Key);\r
-       return Old;\r
-}\r
-\r
-BOOL CFrontendApp::InitInstance()\r
-{\r
-       int Res;\r
-\r
-#ifdef _AFXDLL\r
-       Enable3dControls();\r
-#else\r
-       Enable3dControlsStatic();\r
-#endif\r
-\r
-       CCommandLineInfo CmdLineInfo;\r
-       ParseCommandLine(CmdLineInfo);\r
-\r
-       CFrontendDlg dlg;\r
-\r
-       tray_icon = new TrayIcon( dlg, AfxGetInstanceHandle() );\r
-\r
-       dlg.ConfigFile = CmdLineInfo.m_strFileName;\r
-\r
-       m_pMainWnd = &dlg;\r
-\r
-       Res = SetEnableRedirKey(0);\r
-\r
-       if (Res == 1)\r
-       {\r
-               Res = AfxMessageBox("- WARNING -\n\n"\r
-                       "The OLSR software has just switched off the processing of incoming ICMP "\r
-                       " redirect messages in your registry.\n\n"\r
-                       " Please REBOOT your computer for this change to take effect.\n\n"\r
-                       " Do you want to allow the OLSR software to reboot your computer now?\n\n"\r
-                       " (Please say \"Yes\".)", MB_YESNO | MB_ICONEXCLAMATION);\r
-\r
-               if (Res == IDYES)\r
-               {\r
-                       HANDLE Proc;\r
-                       HMODULE Lib;\r
-                       BOOL (*Open)(HANDLE, DWORD, HANDLE *);\r
-                       BOOL (*Lookup)(char *, char *, LUID *);\r
-                       BOOL (*Adjust)(HANDLE, BOOL, TOKEN_PRIVILEGES *, DWORD,\r
-                               TOKEN_PRIVILEGES *, DWORD *);\r
-                       HANDLE Token;\r
-\r
-                       Proc = ::GetCurrentProcess();\r
-\r
-                       Lib = ::LoadLibrary("advapi32.dll");\r
-\r
-                       if (Lib != NULL)\r
-                       {\r
-                               Open = (BOOL (*)(HANDLE, DWORD, HANDLE *))\r
-                                       ::GetProcAddress(Lib, "OpenProcessToken");\r
-\r
-                               Lookup = (BOOL (*)(char *, char *, LUID *))\r
-                                       ::GetProcAddress(Lib, "LookupPrivilegeValueA");\r
-\r
-                               Adjust = (BOOL (*)(HANDLE, BOOL, TOKEN_PRIVILEGES *, DWORD,\r
-                                       TOKEN_PRIVILEGES *, DWORD *))\r
-                                       ::GetProcAddress(Lib, "AdjustTokenPrivileges");\r
-\r
-                               if (Open != NULL && Lookup != NULL && Adjust != NULL)\r
-                               {\r
-                                       struct\r
-                                       {\r
-                                               DWORD Count;\r
-                                               LUID_AND_ATTRIBUTES Priv;\r
-                                       }\r
-                                       TokPriv;\r
-\r
-                                       Proc = ::GetCurrentProcess();\r
-\r
-                                       if (!Open(Proc, TOKEN_ALL_ACCESS, &Token))\r
-                                               AfxMessageBox("OpenProcessToken() failed.");\r
-\r
-                                       else if (!Lookup("", "SeShutdownPrivilege", &TokPriv.Priv.Luid))\r
-                                               AfxMessageBox("LookupPrivilegeValue() failed.");\r
-\r
-                                       else\r
-                                       {\r
-                                               TokPriv.Count = 1;\r
-                                               TokPriv.Priv.Attributes = SE_PRIVILEGE_ENABLED;\r
-\r
-                                               if (!Adjust(Token, FALSE, (TOKEN_PRIVILEGES *)&TokPriv,\r
-                                                       0, NULL, NULL))\r
-                                                       AfxMessageBox("AdjustTokenPrivilege() failed.");\r
-                                       }\r
-                               }\r
-\r
-                               ::FreeLibrary(Lib);\r
-                       }\r
-\r
-                       ::ExitWindowsEx(EWX_REBOOT, 0);\r
-                       ::TerminateProcess(Proc, 0);\r
-               }\r
-       }\r
-\r
-       RedirectStdHandles();\r
-\r
-       dlg.DoModal();\r
-\r
-       return FALSE;\r
-}\r
-\r
-unsigned int CFrontendApp::RedirectThreadFunc(void)\r
-{\r
-       char Buff[1000];\r
-       int Len;\r
-       int Left, Right;\r
-       CString Line;\r
-       CString Int;\r
-\r
-       while (::ReadFile(OutRead, Buff, sizeof (Buff) - 1, (unsigned long *)&Len, NULL))\r
-       {\r
-               if (Len == 0)\r
-                       break;\r
-\r
-               Left = 0;\r
-\r
-               for (Right = 0; Right < Len; Right++)\r
-               {\r
-                       if (Buff[Right] != 13)\r
-                               Buff[Left++] = Buff[Right];\r
-               }\r
-\r
-               Len = Left;\r
-\r
-               Left = 0;\r
-\r
-               for (Right = 0; Right < Len; Right++)\r
-               {\r
-                       if (Buff[Right] == 10)\r
-                       {\r
-                               Buff[Right] = 0;\r
-                               Line += (Buff + Left);\r
-\r
-                               AfxMessageBox(Line);\r
-\r
-                               Line.Empty();\r
-\r
-                               Left = Right + 1;\r
-                       }\r
-               }\r
-\r
-               Buff[Right] = 0;\r
-               Line += (Buff + Left);\r
-       }\r
-\r
-       AfxEndThread(0);\r
-       return 0;\r
-}\r
-\r
-static unsigned int RedirectThreadStub(void *Arg)\r
-{\r
-       class CFrontendApp *This;\r
-\r
-       This = (class CFrontendApp *)Arg;\r
-\r
-       return This->RedirectThreadFunc();\r
-}\r
-\r
-struct IoInfo\r
-{\r
-       HANDLE Hand;\r
-       unsigned char Attr;\r
-       char Buff;\r
-#if defined _MT\r
-       int Flag;\r
-       CRITICAL_SECTION Lock;\r
-#endif\r
-};\r
-\r
-extern "C" struct IoInfo *__pioinfo[];\r
-\r
-extern "C" void win32_stdio_hack(unsigned int handle);\r
-\r
-int CFrontendApp::RedirectStdHandles(void)\r
-{\r
-       SECURITY_ATTRIBUTES SecAttr;\r
-       HANDLE OutWrite;\r
-       struct IoInfo *Info;\r
-\r
-       SecAttr.nLength = sizeof (SECURITY_ATTRIBUTES);\r
-       SecAttr.lpSecurityDescriptor = NULL;\r
-       SecAttr.bInheritHandle = TRUE;\r
-\r
-       if (!::CreatePipe(&OutRead, &OutWrite, &SecAttr, 0))\r
-       {\r
-               AfxMessageBox("Cannot create stdout pipe.");\r
-               return -1;\r
-       }\r
-\r
-       AfxBeginThread(RedirectThreadStub, (void *)this);\r
-\r
-       Info = __pioinfo[0];\r
-\r
-       // Info[1].Hand = OutWrite;\r
-       // Info[1].Attr = 0x89; // FOPEN | FTEXT | FPIPE;\r
-\r
-       Info[2].Hand = OutWrite;\r
-       Info[2].Attr = 0x89;\r
-\r
-       // stdout->_file = 1;\r
-       stderr->_file = 2;\r
-\r
-       win32_stdio_hack((unsigned int)OutWrite);\r
-\r
-       return 0;\r
-}\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: Frontend.cpp,v 1.8 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#include "stdafx.h"
+#include "Frontend.h"
+#include "FrontendDlg.h"
+#include "TrayIcon.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+BEGIN_MESSAGE_MAP(CFrontendApp, CWinApp)
+       //{{AFX_MSG_MAP(CFrontendApp)
+       //}}AFX_MSG
+       ON_COMMAND(ID_HELP, CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+CFrontendApp::CFrontendApp()
+{
+}
+
+CFrontendApp theApp;
+
+static int SetEnableRedirKey(unsigned long New)
+{
+       HKEY Key;
+       unsigned long Type;
+       unsigned long Len;
+       unsigned long Old;
+       
+       if (::RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+               "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
+               0, KEY_READ | KEY_WRITE, &Key) != ERROR_SUCCESS)
+               return -1;
+       
+       Len = sizeof (Old);
+       
+       if (::RegQueryValueEx(Key, "EnableICMPRedirect", NULL, &Type,
+               (unsigned char *)&Old, &Len) != ERROR_SUCCESS ||
+               Type != REG_DWORD)
+               Old = 1;
+       
+       if (::RegSetValueEx(Key, "EnableICMPRedirect", 0, REG_DWORD,
+               (unsigned char *)&New, sizeof (New)))
+       {
+               ::RegCloseKey(Key);
+               return -1;
+       }
+       
+       ::RegCloseKey(Key);
+       return Old;
+}
+
+BOOL CFrontendApp::InitInstance()
+{
+       int Res;
+
+       CCommandLineInfo CmdLineInfo;
+       ParseCommandLine(CmdLineInfo);
+
+       CFrontendDlg dlg;
+
+       tray_icon = new TrayIcon( dlg, AfxGetInstanceHandle() );
+
+       dlg.ConfigFile = CmdLineInfo.m_strFileName;
+
+       m_pMainWnd = &dlg;
+
+       Res = SetEnableRedirKey(0);
+
+       if (Res == 1)
+       {
+               Res = AfxMessageBox("- WARNING -\n\n"
+                       "The OLSR software has just switched off the processing of incoming ICMP "
+                       " redirect messages in your registry.\n\n"
+                       " Please REBOOT your computer for this change to take effect.\n\n"
+                       " Do you want to allow the OLSR software to reboot your computer now?\n\n"
+                       " (Please say \"Yes\".)", MB_YESNO | MB_ICONEXCLAMATION);
+
+               if (Res == IDYES)
+               {
+                       HANDLE Proc;
+                       HMODULE Lib;
+                       BOOL (*Open)(HANDLE, DWORD, HANDLE *);
+                       BOOL (*Lookup)(char *, char *, LUID *);
+                       BOOL (*Adjust)(HANDLE, BOOL, TOKEN_PRIVILEGES *, DWORD,
+                               TOKEN_PRIVILEGES *, DWORD *);
+                       HANDLE Token;
+
+                       Proc = ::GetCurrentProcess();
+
+                       Lib = ::LoadLibrary("advapi32.dll");
+
+                       if (Lib != NULL)
+                       {
+                               Open = (BOOL (*)(HANDLE, DWORD, HANDLE *))
+                                       ::GetProcAddress(Lib, "OpenProcessToken");
+
+                               Lookup = (BOOL (*)(char *, char *, LUID *))
+                                       ::GetProcAddress(Lib, "LookupPrivilegeValueA");
+
+                               Adjust = (BOOL (*)(HANDLE, BOOL, TOKEN_PRIVILEGES *, DWORD,
+                                       TOKEN_PRIVILEGES *, DWORD *))
+                                       ::GetProcAddress(Lib, "AdjustTokenPrivileges");
+
+                               if (Open != NULL && Lookup != NULL && Adjust != NULL)
+                               {
+                                       struct
+                                       {
+                                               DWORD Count;
+                                               LUID_AND_ATTRIBUTES Priv;
+                                       }
+                                       TokPriv;
+
+                                       Proc = ::GetCurrentProcess();
+
+                                       if (!Open(Proc, TOKEN_ALL_ACCESS, &Token))
+                                               AfxMessageBox("OpenProcessToken() failed.");
+
+                                       else if (!Lookup("", "SeShutdownPrivilege", &TokPriv.Priv.Luid))
+                                               AfxMessageBox("LookupPrivilegeValue() failed.");
+
+                                       else
+                                       {
+                                               TokPriv.Count = 1;
+                                               TokPriv.Priv.Attributes = SE_PRIVILEGE_ENABLED;
+
+                                               if (!Adjust(Token, FALSE, (TOKEN_PRIVILEGES *)&TokPriv,
+                                                       0, NULL, NULL))
+                                                       AfxMessageBox("AdjustTokenPrivilege() failed.");
+                                       }
+                               }
+
+                               ::FreeLibrary(Lib);
+                       }
+
+                       ::ExitWindowsEx(EWX_REBOOT, 0);
+                       ::TerminateProcess(Proc, 0);
+               }
+       }
+
+       RedirectStdHandles();
+
+       dlg.DoModal();
+
+       return FALSE;
+}
+
+unsigned int CFrontendApp::RedirectThreadFunc(void)
+{
+       char Buff[1000];
+       int Len;
+       int Left, Right;
+       CString Line;
+       CString Int;
+
+       while (::ReadFile(OutRead, Buff, sizeof (Buff) - 1, (unsigned long *)&Len, NULL))
+       {
+               if (Len == 0)
+                       break;
+
+               Left = 0;
+
+               for (Right = 0; Right < Len; Right++)
+               {
+                       if (Buff[Right] != 13)
+                               Buff[Left++] = Buff[Right];
+               }
+
+               Len = Left;
+
+               Left = 0;
+
+               for (Right = 0; Right < Len; Right++)
+               {
+                       if (Buff[Right] == 10)
+                       {
+                               Buff[Right] = 0;
+                               Line += (Buff + Left);
+
+                               AfxMessageBox(Line);
+
+                               Line.Empty();
+
+                               Left = Right + 1;
+                       }
+               }
+
+               Buff[Right] = 0;
+               Line += (Buff + Left);
+       }
+
+       AfxEndThread(0);
+       return 0;
+}
+
+static unsigned int RedirectThreadStub(void *Arg)
+{
+       class CFrontendApp *This;
+
+       This = (class CFrontendApp *)Arg;
+
+       return This->RedirectThreadFunc();
+}
+
+struct IoInfo
+{
+       HANDLE Hand;
+       unsigned char Attr;
+       char Buff;
+#if defined _MT
+       int Flag;
+       CRITICAL_SECTION Lock;
+#endif
+};
+
+extern "C" struct IoInfo *__pioinfo[];
+
+extern "C" void win32_stdio_hack(unsigned int handle);
+
+int CFrontendApp::RedirectStdHandles(void)
+{
+       SECURITY_ATTRIBUTES SecAttr;
+       HANDLE OutWrite;
+       struct IoInfo *Info;
+
+       SecAttr.nLength = sizeof (SECURITY_ATTRIBUTES);
+       SecAttr.lpSecurityDescriptor = NULL;
+       SecAttr.bInheritHandle = TRUE;
+
+       if (!::CreatePipe(&OutRead, &OutWrite, &SecAttr, 0))
+       {
+               AfxMessageBox("Cannot create stdout pipe.");
+               return -1;
+       }
+
+       AfxBeginThread(RedirectThreadStub, (void *)this);
+
+       Info = __pioinfo[0];
+
+       // Info[1].Hand = OutWrite;
+       // Info[1].Attr = 0x89; // FOPEN | FTEXT | FPIPE;
+
+       Info[2].Hand = OutWrite;
+       Info[2].Attr = 0x89;
+
+       // stdout->_file = 1;
+       stderr->_file = 2;
+
+       win32_stdio_hack((unsigned int)OutWrite);
+
+       return 0;
+}
diff --git a/gui/win32/Main/Frontend.dsp b/gui/win32/Main/Frontend.dsp
deleted file mode 100644 (file)
index 493df1a..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-# Microsoft Developer Studio Project File - Name="Frontend" - Package Owner=<4>\r
-# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
-# ** DO NOT EDIT **\r
-\r
-# TARGTYPE "Win32 (x86) Application" 0x0101\r
-\r
-CFG=Frontend - Win32 Debug\r
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
-!MESSAGE use the Export Makefile command and run\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "Frontend.mak".\r
-!MESSAGE \r
-!MESSAGE You can specify a configuration when running NMAKE\r
-!MESSAGE by defining the macro CFG on the command line. For example:\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "Frontend.mak" CFG="Frontend - Win32 Debug"\r
-!MESSAGE \r
-!MESSAGE Possible choices for configuration are:\r
-!MESSAGE \r
-!MESSAGE "Frontend - Win32 Release" (based on "Win32 (x86) Application")\r
-!MESSAGE "Frontend - Win32 Debug" (based on "Win32 (x86) Application")\r
-!MESSAGE \r
-\r
-# Begin Project\r
-# PROP AllowPerConfigDependencies 0\r
-# PROP Scc_ProjName ""\r
-# PROP Scc_LocalPath ""\r
-CPP=cl.exe\r
-MTL=midl.exe\r
-RSC=rc.exe\r
-\r
-!IF  "$(CFG)" == "Frontend - Win32 Release"\r
-\r
-# PROP BASE Use_MFC 5\r
-# PROP BASE Use_Debug_Libraries 0\r
-# PROP BASE Output_Dir "Release"\r
-# PROP BASE Intermediate_Dir "Release"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 5\r
-# PROP Use_Debug_Libraries 0\r
-# PROP Output_Dir "Release"\r
-# PROP Intermediate_Dir "Release"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c\r
-# ADD CPP /nologo /MT /W4 /GX /O1 /I "..\..\..\src" /I "..\..\..\src\win32" /I "C:\Program Files\Microsoft SDK\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c\r
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
-# ADD RSC /l 0x409 /d "NDEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386\r
-# ADD LINK32 ws2_32.lib iphlpapi.lib olsrd_cfgparser.lib /nologo /subsystem:windows /debug /machine:I386 /out:"Release/Switch.exe" /libpath:"C:\Program Files\Microsoft SDK\lib"\r
-\r
-!ELSEIF  "$(CFG)" == "Frontend - Win32 Debug"\r
-\r
-# PROP BASE Use_MFC 5\r
-# PROP BASE Use_Debug_Libraries 1\r
-# PROP BASE Output_Dir "Debug"\r
-# PROP BASE Intermediate_Dir "Debug"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 5\r
-# PROP Use_Debug_Libraries 1\r
-# PROP Output_Dir "Debug"\r
-# PROP Intermediate_Dir "Debug"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /GZ /c\r
-# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\..\..\src" /I "..\..\..\src\win32" /I "C:\Program Files\Microsoft SDK\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c\r
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
-# ADD RSC /l 0x409 /d "_DEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept\r
-# ADD LINK32 ws2_32.lib iphlpapi.lib olsrd_cfgparser.lib /nologo /subsystem:windows /debug /machine:I386 /out:"Debug/Switch.exe" /pdbtype:sept /libpath:"C:\Program Files\Microsoft SDK\lib"\r
-\r
-!ENDIF \r
-\r
-# Begin Target\r
-\r
-# Name "Frontend - Win32 Release"\r
-# Name "Frontend - Win32 Debug"\r
-# Begin Group "Source Files"\r
-\r
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
-# Begin Source File\r
-\r
-SOURCE=.\Frontend.cpp\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\Frontend.rc\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FrontendDlg.cpp\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\HnaEntry.cpp\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MidEntry.cpp\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MprEntry.cpp\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MyDialog1.cpp\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MyDialog2.cpp\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MyDialog3.cpp\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MyDialog4.cpp\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MyEdit.cpp\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MyTabCtrl.cpp\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\NodeEntry.cpp\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\StdAfx.cpp\r
-# ADD CPP /Yc"stdafx.h"\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\TrayIcon.cpp\r
-# End Source File\r
-# End Group\r
-# Begin Group "Header Files"\r
-\r
-# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
-# Begin Source File\r
-\r
-SOURCE=.\Frontend.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FrontendDlg.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\HnaEntry.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\Ipc.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MidEntry.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MprEntry.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MyDialog1.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MyDialog2.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MyDialog3.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MyDialog4.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MyEdit.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\MyTabCtrl.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\NodeEntry.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\Resource.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\StdAfx.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\TrayIcon.h\r
-# End Source File\r
-# End Group\r
-# Begin Group "Resource Files"\r
-\r
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
-# Begin Source File\r
-\r
-SOURCE=.\res\Frontend.bmp\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\res\Frontend.ico\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\res\Frontend.rc2\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\res\Tray1.ico\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\res\Tray2.ico\r
-# End Source File\r
-# End Group\r
-# Begin Source File\r
-\r
-SOURCE=.\Switch.exe.manifest\r
-# End Source File\r
-# End Target\r
-# End Project\r
index 37b5426..b0ba3cd 100644 (file)
@@ -1,81 +1,81 @@
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: Frontend.h,v 1.5 2005/01/17 11:52:36 tlopatic Exp $\r
- */\r
-\r
-#if !defined(AFX_FRONTEND_H__8033A41F_6FDC_4054_A582_AB7B6AC5EEAE__INCLUDED_)\r
-#define AFX_FRONTEND_H__8033A41F_6FDC_4054_A582_AB7B6AC5EEAE__INCLUDED_\r
-\r
-#if _MSC_VER > 1000\r
-#pragma once\r
-#endif\r
-\r
-#ifndef __AFXWIN_H__\r
-       #error include 'stdafx.h' before including this file for PCH\r
-#endif\r
-\r
-#include "resource.h"\r
-\r
-class TrayIcon;\r
-\r
-class CFrontendApp : public CWinApp\r
-{\r
-public:\r
-       CFrontendApp();\r
-\r
-       int RedirectStdHandles(void);\r
-       unsigned int RedirectThreadFunc(void);\r
-\r
-       HANDLE OutRead;\r
-       TrayIcon* tray_icon;\r
-\r
-       //{{AFX_VIRTUAL(CFrontendApp)\r
-       public:\r
-       virtual BOOL InitInstance();\r
-       //}}AFX_VIRTUAL\r
-\r
-       //{{AFX_MSG(CFrontendApp)\r
-       //}}AFX_MSG\r
-       DECLARE_MESSAGE_MAP()\r
-};\r
-\r
-\r
-//{{AFX_INSERT_LOCATION}}\r
-\r
-#endif\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: Frontend.h,v 1.6 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#if !defined(AFX_FRONTEND_H__8033A41F_6FDC_4054_A582_AB7B6AC5EEAE__INCLUDED_)
+#define AFX_FRONTEND_H__8033A41F_6FDC_4054_A582_AB7B6AC5EEAE__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#ifndef __AFXWIN_H__
+       #error include 'stdafx.h' before including this file for PCH
+#endif
+
+#include "resource.h"
+
+class TrayIcon;
+
+class CFrontendApp : public CWinApp
+{
+public:
+       CFrontendApp();
+
+       int RedirectStdHandles(void);
+       unsigned int RedirectThreadFunc(void);
+
+       HANDLE OutRead;
+       TrayIcon* tray_icon;
+
+       //{{AFX_VIRTUAL(CFrontendApp)
+       public:
+       virtual BOOL InitInstance();
+       //}}AFX_VIRTUAL
+
+       //{{AFX_MSG(CFrontendApp)
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+
+//{{AFX_INSERT_LOCATION}}
+
+#endif
index eacbe73..da40751 100644 (file)
-//Microsoft Developer Studio generated resource script.\r
-//\r
-#include "resource.h"\r
-\r
-#define APSTUDIO_READONLY_SYMBOLS\r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Generated from the TEXTINCLUDE 2 resource.\r
-//\r
-#include "afxres.h"\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-#undef APSTUDIO_READONLY_SYMBOLS\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// English (U.S.) resources\r
-\r
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r
-#ifdef _WIN32\r
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\r
-#pragma code_page(1252)\r
-#endif //_WIN32\r
-\r
-#ifdef APSTUDIO_INVOKED\r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// TEXTINCLUDE\r
-//\r
-\r
-1 TEXTINCLUDE MOVEABLE PURE \r
-BEGIN\r
-    "resource.h\0"\r
-END\r
-\r
-2 TEXTINCLUDE MOVEABLE PURE \r
-BEGIN\r
-    "#include ""afxres.h""\r\n"\r
-    "\0"\r
-END\r
-\r
-3 TEXTINCLUDE MOVEABLE PURE \r
-BEGIN\r
-    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"\r
-    "#define _AFX_NO_OLE_RESOURCES\r\n"\r
-    "#define _AFX_NO_TRACKER_RESOURCES\r\n"\r
-    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"\r
-    "\r\n"\r
-    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"\r
-    "#ifdef _WIN32\r\n"\r
-    "LANGUAGE 9, 1\r\n"\r
-    "#pragma code_page(1252)\r\n"\r
-    "#endif //_WIN32\r\n"\r
-    "#include ""res\\Frontend.rc2""  // non-Microsoft Visual C++ edited resources\r\n"\r
-    "#include ""afxres.rc""         // Standard components\r\n"\r
-    "#endif\r\n"\r
-    "\0"\r
-END\r
-\r
-#endif    // APSTUDIO_INVOKED\r
-\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Dialog\r
-//\r
-\r
-IDD_FRONTEND_DIALOG DIALOGEX 0, 0, 399, 289\r
-STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | \r
-    WS_SYSMENU\r
-EXSTYLE WS_EX_APPWINDOW\r
-CAPTION "olsr.org Switch 0.4.9"\r
-FONT 8, "MS Sans Serif", 0, 0, 0x1\r
-BEGIN\r
-    CONTROL         "Tab1",IDC_TAB1,"SysTabControl32",0x0,7,7,383,256\r
-    PUSHBUTTON      "Start",IDC_BUTTON1,228,268,50,14\r
-    PUSHBUTTON      "Stop",IDC_BUTTON2,284,268,50,14\r
-    PUSHBUTTON      "Exit",IDC_BUTTON3,340,268,50,14\r
-END\r
-\r
-IDD_DIALOG1 DIALOG DISCARDABLE  0, 0, 377, 240\r
-STYLE WS_CHILD | WS_VISIBLE\r
-FONT 8, "MS Sans Serif"\r
-BEGIN\r
-    EDITTEXT        IDC_EDIT1,7,25,363,208,ES_MULTILINE | ES_READONLY | \r
-                    ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL\r
-    PUSHBUTTON      "Freeze",IDC_BUTTON3,152,7,50,14\r
-    PUSHBUTTON      "Continue",IDC_BUTTON2,208,7,50,14\r
-    PUSHBUTTON      "Save",IDC_BUTTON4,264,7,50,14\r
-    PUSHBUTTON      "Clear",IDC_BUTTON1,320,7,50,14\r
-END\r
-\r
-IDD_DIALOG2 DIALOG DISCARDABLE  0, 0, 377, 240\r
-STYLE WS_CHILD | WS_VISIBLE\r
-FONT 8, "MS Sans Serif"\r
-BEGIN\r
-    CONTROL         "List1",IDC_LIST1,"SysListView32",LVS_LIST | WS_BORDER | \r
-                    WS_TABSTOP,7,19,103,76\r
-    CONTROL         "Slider2",IDC_SLIDER2,"msctls_trackbar32",TBS_AUTOTICKS | \r
-                    TBS_BOTH | WS_TABSTOP,8,116,87,26\r
-    EDITTEXT        IDC_EDIT7,55,153,26,12,ES_RIGHT\r
-    CONTROL         "Enable IP version 6",IDC_CHECK3,"Button",\r
-                    BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,7,171,93,10\r
-    CONTROL         "Offer Internet connection",IDC_CHECK2,"Button",\r
-                    BS_AUTOCHECKBOX | WS_TABSTOP,7,187,93,10\r
-    EDITTEXT        IDC_EDIT1,189,7,26,12,ES_RIGHT\r
-    EDITTEXT        IDC_EDIT2,305,7,26,12,ES_RIGHT\r
-    EDITTEXT        IDC_EDIT3,189,23,26,12,ES_RIGHT\r
-    EDITTEXT        IDC_EDIT9,305,23,26,12,ES_RIGHT\r
-    EDITTEXT        IDC_EDIT4,189,39,26,12,ES_RIGHT\r
-    EDITTEXT        IDC_EDIT10,305,39,26,12,ES_RIGHT\r
-    EDITTEXT        IDC_EDIT5,189,55,26,12,ES_RIGHT\r
-    EDITTEXT        IDC_EDIT6,305,55,26,12,ES_RIGHT\r
-    COMBOBOX        IDC_COMBO1,189,76,26,41,CBS_DROPDOWNLIST | CBS_SORT | \r
-                    WS_VSCROLL | WS_TABSTOP\r
-    EDITTEXT        IDC_EDIT15,305,77,26,12,ES_RIGHT | ES_NUMBER\r
-    CONTROL         "Enable hysteresis",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | \r
-                    WS_TABSTOP,134,101,74,10\r
-    EDITTEXT        IDC_EDIT12,189,115,26,12,ES_RIGHT\r
-    EDITTEXT        IDC_EDIT13,305,115,26,12,ES_RIGHT\r
-    EDITTEXT        IDC_EDIT11,189,131,26,12,ES_RIGHT\r
-    CONTROL         "Enable ETX link quality",IDC_CHECK4,"Button",\r
-                    BS_AUTOCHECKBOX | WS_TABSTOP,132,155,92,10\r
-    CONTROL         "for MPR selection only",IDC_RADIO1,"Button",\r
-                    BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,132,171,87,10\r
-    CONTROL         "for MPR selection and routing",IDC_RADIO2,"Button",\r
-                    BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,132,187,109,\r
-                    10\r
-    EDITTEXT        IDC_EDIT14,305,169,26,12,ES_RIGHT | ES_NUMBER\r
-    PUSHBUTTON      "Open",IDC_BUTTON4,210,219,50,14\r
-    PUSHBUTTON      "Save",IDC_BUTTON5,265,219,50,14\r
-    PUSHBUTTON      "Reset",IDC_BUTTON1,320,219,50,14\r
-    LTEXT           "Interface list",IDC_STATIC,7,8,39,8\r
-    LTEXT           "Debug level",IDC_STATIC,7,105,39,8\r
-    RTEXT           "HELLO interval:",IDC_STATIC,132,9,51,8\r
-    RTEXT           "HELLO hold:",IDC_STATIC,247,9,42,8\r
-    RTEXT           "MID interval:",IDC_STATIC,132,25,41,8\r
-    RTEXT           "MID hold:",IDC_STATIC,247,25,32,8\r
-    RTEXT           "HNA interval:",IDC_STATIC,132,41,43,8\r
-    RTEXT           "HNA hold:",IDC_STATIC,247,41,34,8\r
-    RTEXT           "TC interval:",IDC_STATIC,132,57,37,8\r
-    RTEXT           "TC hold:",IDC_STATIC,247,57,28,8\r
-    RTEXT           "TC redundancy:",IDC_STATIC,132,79,52,8\r
-    RTEXT           "MPR coverage:",IDC_STATIC,247,79,51,8\r
-    LTEXT           "sec",IDC_STATIC,219,9,12,8\r
-    LTEXT           "sec",IDC_STATIC,335,9,12,8\r
-    LTEXT           "sec",IDC_STATIC,219,25,12,8\r
-    LTEXT           "sec",IDC_STATIC,335,25,12,8\r
-    LTEXT           "sec",IDC_STATIC,219,41,12,8\r
-    LTEXT           "sec",IDC_STATIC,335,41,12,8\r
-    LTEXT           "sec",IDC_STATIC,219,57,12,8\r
-    LTEXT           "sec",IDC_STATIC,335,57,12,8\r
-    RTEXT           "Poll interval:",IDC_STATIC,7,155,39,8\r
-    LTEXT           "sec",IDC_STATIC,85,155,12,8\r
-    CTEXT           "0",IDC_TEXT1,96,123,11,8\r
-    RTEXT           "Low mark:",IDC_STATIC,132,117,34,8\r
-    RTEXT           "Scaling:",IDC_STATIC,132,133,26,8\r
-    RTEXT           "High mark:",IDC_STATIC,247,117,35,8\r
-    RTEXT           "Window size:",IDC_STATIC,247,171,43,8\r
-END\r
-\r
-IDD_DIALOG3 DIALOG DISCARDABLE  0, 0, 377, 240\r
-STYLE WS_CHILD | WS_VISIBLE\r
-FONT 8, "MS Sans Serif"\r
-BEGIN\r
-    CONTROL         "List1",IDC_LIST1,"SysListView32",LVS_REPORT | \r
-                    LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,7,18,239,215\r
-    CONTROL         "List4",IDC_LIST4,"SysListView32",LVS_REPORT | \r
-                    LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,255,18,115,66\r
-    CONTROL         "List4",IDC_LIST5,"SysListView32",LVS_REPORT | \r
-                    LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,255,92,115,66\r
-    CONTROL         "List4",IDC_LIST6,"SysListView32",LVS_REPORT | \r
-                    LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,255,167,115,66\r
-    LTEXT           "Node list",IDC_STATIC,7,7,32,8\r
-    LTEXT           "Node information",IDC_STATIC,257,7,59,8\r
-END\r
-\r
-IDD_DIALOG4 DIALOG DISCARDABLE  0, 0, 377, 240\r
-STYLE WS_CHILD | WS_VISIBLE\r
-FONT 8, "MS Sans Serif"\r
-BEGIN\r
-    CONTROL         "List1",IDC_LIST1,"SysListView32",LVS_REPORT | WS_BORDER | \r
-                    WS_TABSTOP,7,18,363,215\r
-    LTEXT           "Routing table",IDC_STATIC,7,7,48,8\r
-END\r
-\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// DESIGNINFO\r
-//\r
-\r
-#ifdef APSTUDIO_INVOKED\r
-GUIDELINES DESIGNINFO MOVEABLE PURE \r
-BEGIN\r
-    IDD_FRONTEND_DIALOG, DIALOG\r
-    BEGIN\r
-        LEFTMARGIN, 7\r
-        RIGHTMARGIN, 390\r
-        TOPMARGIN, 7\r
-        BOTTOMMARGIN, 282\r
-    END\r
-\r
-    IDD_DIALOG1, DIALOG\r
-    BEGIN\r
-        LEFTMARGIN, 7\r
-        RIGHTMARGIN, 370\r
-        TOPMARGIN, 7\r
-        BOTTOMMARGIN, 233\r
-    END\r
-\r
-    IDD_DIALOG2, DIALOG\r
-    BEGIN\r
-        LEFTMARGIN, 7\r
-        RIGHTMARGIN, 370\r
-        TOPMARGIN, 6\r
-        BOTTOMMARGIN, 233\r
-    END\r
-\r
-    IDD_DIALOG3, DIALOG\r
-    BEGIN\r
-        LEFTMARGIN, 7\r
-        RIGHTMARGIN, 370\r
-        TOPMARGIN, 7\r
-        BOTTOMMARGIN, 233\r
-    END\r
-\r
-    IDD_DIALOG4, DIALOG\r
-    BEGIN\r
-        LEFTMARGIN, 7\r
-        RIGHTMARGIN, 370\r
-        TOPMARGIN, 7\r
-        BOTTOMMARGIN, 233\r
-    END\r
-END\r
-#endif    // APSTUDIO_INVOKED\r
-\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Icon\r
-//\r
-\r
-// Icon with lowest ID value placed first to ensure application icon\r
-// remains consistent on all systems.\r
-IDI_ICON1               ICON    DISCARDABLE     "res\\Frontend.ico"\r
-IDI_ICON3               ICON    DISCARDABLE     "res\\Tray2.ico"\r
-IDI_ICON2               ICON    DISCARDABLE     "res\\Tray1.ico"\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// RT_MANIFEST\r
-//\r
-\r
-IDR_241                 RT_MANIFEST MOVEABLE PURE "Switch.exe.manifest"\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Menu\r
-//\r
-\r
-IDR_TRAYMENU MENU DISCARDABLE \r
-BEGIN\r
-    POPUP "IDR_TRAYMENU"\r
-    BEGIN\r
-        MENUITEM "Start",                       IDM_START\r
-        MENUITEM "Stop",                        IDM_STOP\r
-        POPUP "Show"\r
-        BEGIN\r
-            MENUITEM "Window",                      IDM_WINDOW\r
-            MENUITEM "Settings",                    IDM_SETTINGS\r
-            MENUITEM "Output",                      IDM_OUTPUT\r
-        END\r
-        MENUITEM "Exit",                        IDM_EXIT\r
-    END\r
-END\r
-\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Dialog Info\r
-//\r
-\r
-IDD_DIALOG2 DLGINIT\r
-BEGIN\r
-    IDC_COMBO1, 0x403, 2, 0\r
-0x0030, \r
-    IDC_COMBO1, 0x403, 2, 0\r
-0x0031, \r
-    IDC_COMBO1, 0x403, 2, 0\r
-0x0032, \r
-    0\r
-END\r
-\r
-#endif    // English (U.S.) resources\r
-/////////////////////////////////////////////////////////////////////////////\r
-\r
-\r
-\r
-#ifndef APSTUDIO_INVOKED\r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Generated from the TEXTINCLUDE 3 resource.\r
-//\r
-#define _AFX_NO_SPLITTER_RESOURCES\r
-#define _AFX_NO_OLE_RESOURCES\r
-#define _AFX_NO_TRACKER_RESOURCES\r
-#define _AFX_NO_PROPERTY_RESOURCES\r
-\r
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r
-#ifdef _WIN32\r
-LANGUAGE 9, 1\r
-#pragma code_page(1252)\r
-#endif //_WIN32\r
-#include "res\Frontend.rc2"  // non-Microsoft Visual C++ edited resources\r
-#include "afxres.rc"         // Standard components\r
-#endif\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-#endif    // not APSTUDIO_INVOKED\r
-\r
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE 
+BEGIN
+    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+    "#define _AFX_NO_OLE_RESOURCES\r\n"
+    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+    "\r\n"
+    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
+    "#ifdef _WIN32\r\n"
+    "LANGUAGE 9, 1\r\n"
+    "#pragma code_page(1252)\r\n"
+    "#endif //_WIN32\r\n"
+    "#include ""res\\Frontend.rc2""  // non-Microsoft Visual C++ edited resources\r\n"
+    "#include ""afxres.rc""         // Standard components\r\n"
+    "#endif\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_FRONTEND_DIALOG DIALOGEX 0, 0, 399, 289
+STYLE DS_SETFONT | DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_APPWINDOW
+CAPTION "olsr.org Switch 0.5.0"
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+    CONTROL         "Tab1",IDC_TAB1,"SysTabControl32",0x0,7,7,383,256
+    PUSHBUTTON      "Start",IDC_BUTTON1,228,268,50,14
+    PUSHBUTTON      "Stop",IDC_BUTTON2,284,268,50,14
+    PUSHBUTTON      "Exit",IDC_BUTTON3,340,268,50,14
+END
+
+IDD_DIALOG1 DIALOG  0, 0, 377, 240
+STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_EDIT1,7,25,363,208,ES_MULTILINE | ES_READONLY | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL
+    PUSHBUTTON      "Freeze",IDC_BUTTON3,152,7,50,14
+    PUSHBUTTON      "Continue",IDC_BUTTON2,208,7,50,14
+    PUSHBUTTON      "Save",IDC_BUTTON4,264,7,50,14
+    PUSHBUTTON      "Clear",IDC_BUTTON1,320,7,50,14
+END
+
+IDD_DIALOG2 DIALOGEX 0, 0, 377, 240
+STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE
+FONT 8, "MS Sans Serif", 0, 0, 0x0
+BEGIN
+    CONTROL         "List1",IDC_LIST1,"SysListView32",LVS_LIST | WS_BORDER | WS_TABSTOP,7,19,103,76
+    CONTROL         "Slider2",IDC_SLIDER2,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | WS_TABSTOP,8,116,87,26
+    EDITTEXT        IDC_EDIT7,55,153,26,12,ES_RIGHT
+    CONTROL         "Enable IP version 6",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,7,171,93,10
+    CONTROL         "Offer Internet connection",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,187,93,10
+    EDITTEXT        IDC_EDIT1,189,7,26,12,ES_RIGHT
+    EDITTEXT        IDC_EDIT2,305,7,26,12,ES_RIGHT
+    EDITTEXT        IDC_EDIT3,189,23,26,12,ES_RIGHT
+    EDITTEXT        IDC_EDIT9,305,23,26,12,ES_RIGHT
+    EDITTEXT        IDC_EDIT4,189,39,26,12,ES_RIGHT
+    EDITTEXT        IDC_EDIT10,305,39,26,12,ES_RIGHT
+    EDITTEXT        IDC_EDIT5,189,55,26,12,ES_RIGHT
+    EDITTEXT        IDC_EDIT6,305,55,26,12,ES_RIGHT
+    COMBOBOX        IDC_COMBO1,189,76,26,41,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+    EDITTEXT        IDC_EDIT15,305,77,26,12,ES_RIGHT | ES_NUMBER
+    CONTROL         "Enable hysteresis",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,134,101,74,10
+    EDITTEXT        IDC_EDIT12,189,115,26,12,ES_RIGHT
+    EDITTEXT        IDC_EDIT13,305,115,26,12,ES_RIGHT
+    EDITTEXT        IDC_EDIT11,189,131,26,12,ES_RIGHT
+    CONTROL         "Enable ETX link quality",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,132,155,92,10
+    CONTROL         "for MPR selection only",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,132,171,87,10
+    CONTROL         "for MPR selection and routing",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,132,187,109,10
+    EDITTEXT        IDC_EDIT14,305,169,26,12,ES_RIGHT | ES_NUMBER
+    PUSHBUTTON      "Open",IDC_BUTTON4,210,219,50,14
+    PUSHBUTTON      "Save",IDC_BUTTON5,265,219,50,14
+    PUSHBUTTON      "Reset",IDC_BUTTON1,320,219,50,14
+    LTEXT           "Interface list",IDC_STATIC,7,8,39,8
+    LTEXT           "Debug level",IDC_STATIC,7,105,39,8
+    RTEXT           "HELLO interval:",IDC_STATIC,132,9,51,8
+    RTEXT           "HELLO hold:",IDC_STATIC,247,9,42,8
+    RTEXT           "MID interval:",IDC_STATIC,132,25,41,8
+    RTEXT           "MID hold:",IDC_STATIC,247,25,32,8
+    RTEXT           "HNA interval:",IDC_STATIC,132,41,43,8
+    RTEXT           "HNA hold:",IDC_STATIC,247,41,34,8
+    RTEXT           "TC interval:",IDC_STATIC,132,57,37,8
+    RTEXT           "TC hold:",IDC_STATIC,247,57,28,8
+    RTEXT           "TC redundancy:",IDC_STATIC,132,79,52,8
+    RTEXT           "MPR coverage:",IDC_STATIC,247,79,51,8
+    LTEXT           "sec",IDC_STATIC,219,9,12,8
+    LTEXT           "sec",IDC_STATIC,335,9,12,8
+    LTEXT           "sec",IDC_STATIC,219,25,12,8
+    LTEXT           "sec",IDC_STATIC,335,25,12,8
+    LTEXT           "sec",IDC_STATIC,219,41,12,8
+    LTEXT           "sec",IDC_STATIC,335,41,12,8
+    LTEXT           "sec",IDC_STATIC,219,57,12,8
+    LTEXT           "sec",IDC_STATIC,335,57,12,8
+    RTEXT           "Poll interval:",IDC_STATIC,7,155,39,8
+    LTEXT           "sec",IDC_STATIC,85,155,12,8
+    CTEXT           "0",IDC_TEXT1,96,123,11,8
+    RTEXT           "Low mark:",IDC_STATIC,132,117,34,8
+    RTEXT           "Scaling:",IDC_STATIC,132,133,26,8
+    RTEXT           "High mark:",IDC_STATIC,247,117,35,8
+    RTEXT           "Window size:",IDC_STATIC,247,171,43,8
+    CONTROL         "Enable Fish Eye",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,249,187,92,10
+END
+
+IDD_DIALOG3 DIALOG  0, 0, 377, 240
+STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE
+FONT 8, "MS Sans Serif"
+BEGIN
+    CONTROL         "List1",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,7,18,239,215
+    CONTROL         "List4",IDC_LIST4,"SysListView32",LVS_REPORT | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,255,18,115,66
+    CONTROL         "List4",IDC_LIST5,"SysListView32",LVS_REPORT | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,255,92,115,66
+    CONTROL         "List4",IDC_LIST6,"SysListView32",LVS_REPORT | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,255,167,115,66
+    LTEXT           "Node list",IDC_STATIC,7,7,32,8
+    LTEXT           "Node information",IDC_STATIC,257,7,59,8
+END
+
+IDD_DIALOG4 DIALOG  0, 0, 377, 240
+STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE
+FONT 8, "MS Sans Serif"
+BEGIN
+    CONTROL         "List1",IDC_LIST1,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,7,18,363,215
+    LTEXT           "Routing table",IDC_STATIC,7,7,48,8
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO 
+BEGIN
+    IDD_FRONTEND_DIALOG, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 390
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 282
+    END
+
+    IDD_DIALOG1, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 370
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 233
+    END
+
+    IDD_DIALOG2, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 370
+        TOPMARGIN, 6
+        BOTTOMMARGIN, 233
+    END
+
+    IDD_DIALOG3, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 370
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 233
+    END
+
+    IDD_DIALOG4, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 370
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 233
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON1               ICON                    "res\\Frontend.ico"
+IDI_ICON3               ICON                    "res\\Tray2.ico"
+IDI_ICON2               ICON                    "res\\Tray1.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDR_TRAYMENU MENU 
+BEGIN
+    POPUP "IDR_TRAYMENU"
+    BEGIN
+        MENUITEM "Start",                       IDM_START
+        MENUITEM "Stop",                        IDM_STOP
+        POPUP "Show"
+        BEGIN
+            MENUITEM "Window",                      IDM_WINDOW
+            MENUITEM "Settings",                    IDM_SETTINGS
+            MENUITEM "Output",                      IDM_OUTPUT
+        END
+        MENUITEM "Exit",                        IDM_EXIT
+    END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog Info
+//
+
+IDD_DIALOG2 DLGINIT
+BEGIN
+    IDC_COMBO1, 0x403, 2, 0
+0x0030, 
+    IDC_COMBO1, 0x403, 2, 0
+0x0031, 
+    IDC_COMBO1, 0x403, 2, 0
+0x0032, 
+    0
+END
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE 9, 1
+#pragma code_page(1252)
+#endif //_WIN32
+#include "res\Frontend.rc2"  // non-Microsoft Visual C++ edited resources
+#include "afxres.rc"         // Standard components
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
index 42fd9c7..207dfd4 100644 (file)
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: FrontendDlg.cpp,v 1.10 2005/03/30 21:29:05 tlopatic Exp $\r
- */\r
-\r
-#include "stdafx.h"\r
-#include "Frontend.h"\r
-#include "FrontendDlg.h"\r
-#include "TrayIcon.h"\r
-\r
-#include "Ipc.h"\r
-\r
-#ifdef _DEBUG\r
-#define new DEBUG_NEW\r
-#undef THIS_FILE\r
-static char THIS_FILE[] = __FILE__;\r
-#endif\r
-\r
-CFrontendDlg::CFrontendDlg(CWnd* pParent)\r
-       : CDialog(CFrontendDlg::IDD, pParent)\r
-{\r
-       //{{AFX_DATA_INIT(CFrontendDlg)\r
-       //}}AFX_DATA_INIT\r
-\r
-       Event = CreateEvent(NULL, FALSE, FALSE, "TheOlsrdShimEvent");\r
-\r
-       LogThread = NULL;\r
-       NetThread = NULL;\r
-}\r
-\r
-void CFrontendDlg::DoDataExchange(CDataExchange* pDX)\r
-{\r
-       CDialog::DoDataExchange(pDX);\r
-       //{{AFX_DATA_MAP(CFrontendDlg)\r
-       DDX_Control(pDX, IDC_BUTTON2, m_StopButton);\r
-       DDX_Control(pDX, IDC_BUTTON1, m_StartButton);\r
-       DDX_Control(pDX, IDC_TAB1, m_TabCtrl);\r
-       //}}AFX_DATA_MAP\r
-}\r
-\r
-BEGIN_MESSAGE_MAP(CFrontendDlg, CDialog)\r
-       //{{AFX_MSG_MAP(CFrontendDlg)\r
-       ON_BN_CLICKED(IDC_BUTTON1, OnStartButton)\r
-       ON_BN_CLICKED(IDC_BUTTON2, OnStopButton)\r
-       ON_BN_CLICKED(IDC_BUTTON3, OnExitButton)\r
-       ON_BN_CLICKED(IDOK, OnOK)\r
-       ON_BN_CLICKED(IDCANCEL, OnCancel)\r
-       //}}AFX_MSG_MAP\r
-END_MESSAGE_MAP()\r
-\r
-#if 0\r
-static void HexDump(unsigned char *Mem, int Len)\r
-{\r
-       char Buff[10000];\r
-       int i, k;\r
-       char *Walker = Buff;\r
-\r
-       for (i = 0; i < Len; i += k)\r
-       {\r
-               Walker += sprintf(Walker, "%08x:", i);\r
-\r
-               for (k = 0; i + k < Len && k < 16; k++)\r
-                       Walker += sprintf(Walker, " %02x", Mem[i + k]);\r
-\r
-               while (k < 16)\r
-               {\r
-                       Walker += sprintf(Walker, "   ");\r
-                       k++;\r
-               }\r
-\r
-               Walker += sprintf(Walker, " ");\r
-\r
-               for (k = 0; i + k < Len && k < 16; k++)\r
-                       if (Mem[i + k] < 32 || Mem[i + k] > 126)\r
-                               Walker += sprintf(Walker, ".");\r
-\r
-                       else\r
-                               Walker += sprintf(Walker, "%c", Mem[i + k]);\r
-\r
-               Walker += sprintf(Walker, "\r\n");\r
-       }\r
-\r
-       ::MessageBox(NULL, Buff, "HEXDUMP", MB_OK);\r
-}\r
-#endif\r
-\r
-// XXX - pretty inefficient\r
-\r
-void CFrontendDlg::Timeout(void)\r
-{\r
-       POSITION Pos, Pos2;\r
-       class NodeEntry Entry;\r
-       class MprEntry MprEntry;\r
-       class MidEntry MidEntry;\r
-       class HnaEntry HnaEntry;\r
-\r
-Restart0:\r
-       Pos = NodeList.GetHeadPosition();\r
-\r
-       while (Pos != NULL)\r
-       {\r
-               Entry = NodeList.GetAt(Pos);\r
-\r
-               if (Entry.Timeout < Now)\r
-               {\r
-                       NodeList.RemoveAt(Pos);\r
-                       goto Restart0;\r
-               }\r
-\r
-Restart1:\r
-               Pos2 = Entry.MprList.GetHeadPosition();\r
-\r
-               while (Pos2 != NULL)\r
-               {\r
-                       MprEntry = Entry.MprList.GetAt(Pos2);\r
-\r
-                       if (MprEntry.Timeout < Now)\r
-                       {\r
-                               Entry.MprList.RemoveAt(Pos2);\r
-                               goto Restart1;\r
-                       }\r
-\r
-                       Entry.MprList.GetNext(Pos2);\r
-               }\r
-\r
-Restart2:\r
-               Pos2 = Entry.MidList.GetHeadPosition();\r
-\r
-               while (Pos2 != NULL)\r
-               {\r
-                       MidEntry = Entry.MidList.GetAt(Pos2);\r
-\r
-                       if (MidEntry.Timeout < Now)\r
-                       {\r
-                               Entry.MidList.RemoveAt(Pos2);\r
-                               goto Restart2;\r
-                       }\r
-\r
-                       Entry.MidList.GetNext(Pos2);\r
-               }\r
-\r
-Restart3:\r
-               Pos2 = Entry.HnaList.GetHeadPosition();\r
-\r
-               while (Pos2 != NULL)\r
-               {\r
-                       HnaEntry = Entry.HnaList.GetAt(Pos2);\r
-\r
-                       if (HnaEntry.Timeout < Now)\r
-                       {\r
-                               Entry.HnaList.RemoveAt(Pos2);\r
-                               goto Restart3;\r
-                       }\r
-\r
-                       Entry.HnaList.GetNext(Pos2);\r
-               }\r
-\r
-               NodeList.GetNext(Pos);\r
-       }\r
-\r
-       if( NodeList.IsEmpty() )\r
-               TrayIcon::getInstance()->setStatus( TrayIcon::ON, "No nodes found" );\r
-       else\r
-               TrayIcon::getInstance()->setStatus( TrayIcon::CONNECTED, "Nodes available" );\r
-\r
-       m_TabCtrl.m_Dialog3.UpdateNodeInfo(NodeList);\r
-}\r
-\r
-unsigned int VTimeToInt(unsigned int VTime)\r
-{\r
-       return ((0x10 | ((VTime & 0xf0) >> 4)) << (VTime & 0x0f)) >> 8;\r
-}\r
-\r
-void CFrontendDlg::AddMpr(unsigned int MprAddr, unsigned int NodeAddr,\r
-                                                 unsigned int VTime)\r
-{\r
-       class NodeEntry NewEntry;\r
-       POSITION Pos;\r
-       unsigned __int64 Timeout;\r
-\r
-       Timeout = Now +\r
-               (unsigned __int64)VTimeToInt(VTime) * (unsigned __int64)10000000;\r
-\r
-       AddNode(NodeAddr, VTime);\r
-       AddNode(MprAddr, VTime);\r
-\r
-       NewEntry.Addr = NodeAddr;\r
-\r
-       Pos = NodeList.Find(NewEntry);\r
-\r
-       if (Pos == NULL)\r
-               return;\r
-\r
-       class NodeEntry &OldEntry = NodeList.GetAt(Pos);\r
-\r
-       OldEntry.AddMpr(MprAddr, Timeout);\r
-\r
-       m_TabCtrl.m_Dialog3.UpdateNodeInfo(NodeList);\r
-}\r
-\r
-void CFrontendDlg::AddMid(unsigned int IntAddr, unsigned int NodeAddr,\r
-                                                 unsigned int VTime)\r
-{\r
-       class NodeEntry NewEntry;\r
-       POSITION Pos;\r
-       unsigned __int64 Timeout;\r
-\r
-       Timeout = Now +\r
-               (unsigned __int64)VTimeToInt(VTime) * (unsigned __int64)10000000;\r
-\r
-       AddNode(NodeAddr, VTime);\r
-\r
-       NewEntry.Addr = NodeAddr;\r
-\r
-       Pos = NodeList.Find(NewEntry);\r
-\r
-       if (Pos == NULL)\r
-               return;\r
-\r
-       class NodeEntry &OldEntry = NodeList.GetAt(Pos);\r
-\r
-       OldEntry.AddMid(IntAddr, Timeout);\r
-\r
-       m_TabCtrl.m_Dialog3.UpdateNodeInfo(NodeList);\r
-}\r
-\r
-void CFrontendDlg::AddHna(unsigned int NetAddr, unsigned int NetMask,\r
-                                                 unsigned int NodeAddr, unsigned int VTime)\r
-{\r
-       class NodeEntry NewEntry;\r
-       POSITION Pos;\r
-       unsigned __int64 Timeout;\r
-\r
-       Timeout = Now +\r
-               (unsigned __int64)VTimeToInt(VTime) * (unsigned __int64)10000000;\r
-\r
-       AddNode(NodeAddr, VTime);\r
-\r
-       NewEntry.Addr = NodeAddr;\r
-\r
-       Pos = NodeList.Find(NewEntry);\r
-\r
-       if (Pos == NULL)\r
-               return;\r
-\r
-       class NodeEntry &OldEntry = NodeList.GetAt(Pos);\r
-\r
-       OldEntry.AddHna(NetAddr, NetMask, Timeout);\r
-\r
-       m_TabCtrl.m_Dialog3.UpdateNodeInfo(NodeList);\r
-}\r
-\r
-void CFrontendDlg::AddNode(unsigned int NodeAddr, unsigned int VTime)\r
-{\r
-       class NodeEntry NewEntry;\r
-       POSITION Pos;\r
-       unsigned __int64 Timeout;\r
-\r
-       if (NodeAddr == LocalHost)\r
-               return;\r
-\r
-       Timeout = Now +\r
-               (unsigned __int64)VTimeToInt(VTime) * (unsigned __int64)10000000;\r
-\r
-       NewEntry.Addr = NodeAddr;\r
-\r
-       Pos = NodeList.Find(NewEntry);\r
-\r
-       if (Pos != NULL)\r
-       {\r
-               class NodeEntry &OldEntry = NodeList.GetAt(Pos);\r
-               OldEntry.Timeout = Timeout;\r
-       }\r
-\r
-       else\r
-       {\r
-               NewEntry.Timeout = Timeout;\r
-               NodeList.AddTail(NewEntry);\r
-       }\r
-\r
-       m_TabCtrl.m_Dialog3.UpdateNodeInfo(NodeList);\r
-}\r
-\r
-void CFrontendDlg::HandleOlsrTc(struct OlsrTc *Msg, int UseLq)\r
-{\r
-       int Size;\r
-       unsigned int *Addr;\r
-\r
-       Msg->Header.SeqNo = ::ntohs(Msg->Header.SeqNo);\r
-       Msg->Ansn = ::ntohs(Msg->Ansn);\r
-\r
-       AddNode(Msg->Header.Orig, Msg->Header.VTime);\r
-\r
-       Size = Msg->Header.Size;\r
-\r
-       Size -= sizeof (struct OlsrTc);\r
-\r
-       Addr = (unsigned int *)(Msg + 1);\r
-\r
-       while (Size > 0)\r
-       {\r
-               Size -= 4;\r
-\r
-               AddMpr(*Addr, Msg->Header.Orig, Msg->Header.VTime);\r
-\r
-               Addr++;\r
-\r
-               if (UseLq != 0)\r
-               {\r
-                       Size -= 4;\r
-                       Addr++;\r
-               }\r
-\r
-       }\r
-}\r
-\r
-void CFrontendDlg::HandleOlsrMid(struct OlsrHeader *Msg)\r
-{\r
-       int Size;\r
-       unsigned int *Addr;\r
-\r
-       Msg->SeqNo = ::ntohs(Msg->SeqNo);\r
-\r
-       AddNode(Msg->Orig, Msg->VTime);\r
-\r
-       Size = Msg->Size;\r
-\r
-       Size -= sizeof (struct OlsrHeader);\r
-\r
-       Addr = (unsigned int *)(Msg + 1);\r
-\r
-       while (Size > 0)\r
-       {\r
-               Size -= 4;\r
-\r
-               AddMid(*Addr, Msg->Orig, Msg->VTime);\r
-\r
-               Addr++;\r
-       }\r
-}\r
-\r
-void CFrontendDlg::HandleOlsrHna(struct OlsrHeader *Msg)\r
-{\r
-       int Size;\r
-       unsigned int *Addr;\r
-\r
-       Msg->SeqNo = ::ntohs(Msg->SeqNo);\r
-\r
-       AddNode(Msg->Orig, Msg->VTime);\r
-\r
-       Size = Msg->Size;\r
-\r
-       Size -= sizeof (struct OlsrHeader);\r
-\r
-       Addr = (unsigned int *)(Msg + 1);\r
-\r
-       while (Size > 0)\r
-       {\r
-               Size -= 8;\r
-\r
-               AddHna(Addr[0], Addr[1], Msg->Orig, Msg->VTime);\r
-\r
-               Addr += 2;\r
-       }\r
-}\r
-\r
-void CFrontendDlg::HandleOlsrHello(struct OlsrHello *Msg, int UseLq)\r
-{\r
-       int Size, LinkSize;\r
-       struct OlsrHelloLink *Link;\r
-       unsigned int *Addr;\r
-\r
-       Msg->Header.SeqNo = ::ntohs(Msg->Header.SeqNo);\r
-\r
-       AddNode(Msg->Header.Orig, Msg->Header.VTime);\r
-\r
-       Size = Msg->Header.Size;\r
-\r
-       Size -= sizeof (struct OlsrHello);\r
-\r
-       Link = (struct OlsrHelloLink *)(Msg + 1);\r
-\r
-       while (Size > 0)\r
-       {\r
-               Link->Size = ::ntohs(Link->Size);\r
-\r
-               LinkSize = Link->Size;\r
-\r
-               Size -= LinkSize;\r
-\r
-               LinkSize -= sizeof (struct OlsrHelloLink);\r
-\r
-               Addr = (unsigned int *)(Link + 1);\r
-\r
-               while (LinkSize > 0)\r
-               {\r
-                       LinkSize -= 4;\r
-\r
-                       AddNode(*Addr, Msg->Header.VTime);\r
-\r
-                       if ((Link->LinkCode & 0x0c) == 0x08)\r
-                               AddMpr(*Addr, Msg->Header.Orig, Msg->Header.VTime);\r
-\r
-                       Addr++;\r
-\r
-                       if (UseLq != 0)\r
-                       {\r
-                               LinkSize -= 4;\r
-                               Addr++;\r
-                       }\r
-               }\r
-\r
-               Link = (struct OlsrHelloLink *)Addr;\r
-       }\r
-}\r
-\r
-void CFrontendDlg::HandleIpcRoute(struct IpcRoute *Msg)\r
-{\r
-       if (Msg->Header.Size != sizeof (struct IpcRoute))\r
-               return;\r
-\r
-       if (Msg->Add == 0)\r
-               m_TabCtrl.m_Dialog4.DeleteRoute(Msg->Dest.v4);\r
-\r
-       else\r
-               m_TabCtrl.m_Dialog4.AddRoute(Msg->Dest.v4, Msg->Gate.v4, Msg->Metric,\r
-               Msg->Int);\r
-}\r
-\r
-void CFrontendDlg::HandleIpcConfig(struct IpcConfig *Msg)\r
-{\r
-       if (Msg->Header.Size != sizeof (struct IpcConfig))\r
-               return;\r
-\r
-       Msg->HelloInt = ::ntohs(Msg->HelloInt);\r
-       Msg->WiredHelloInt = ::ntohs(Msg->WiredHelloInt);\r
-       Msg->TcInt = ::ntohs(Msg->TcInt);\r
-\r
-       Msg->HelloHold = ::ntohs(Msg->HelloHold);\r
-       Msg->TcHold = ::ntohs(Msg->TcHold);\r
-\r
-       LocalHost = Msg->MainAddr.v4;\r
-}\r
-\r
-static int FullRead(SOCKET SockHand, char *Buff, int Len)\r
-{\r
-       int Res;\r
-\r
-       do\r
-       {\r
-               Res = ::recv(SockHand, Buff, Len, 0);\r
-\r
-               if (Res <= 0)\r
-                       return -1;\r
-\r
-               Len -= Res;\r
-               Buff += Res;\r
-       }\r
-       while (Len > 0);\r
-\r
-       return 0;\r
-}\r
-\r
-// XXX - we should have access to olsrd's internal data structures instead\r
-\r
-unsigned int CFrontendDlg::NetThreadFunc(void)\r
-{\r
-       struct IpcHeader Header;\r
-       int Res;\r
-       char *Msg;\r
-\r
-       for (;;)\r
-       {\r
-               Res = FullRead(SockHand, (char *)&Header, sizeof (struct IpcHeader));\r
-\r
-               if (Res < 0)\r
-                       break;\r
-\r
-               Header.Size = ntohs(Header.Size);\r
-\r
-               Msg = new char [Header.Size];\r
-\r
-               ::memcpy(Msg, &Header, sizeof (struct IpcHeader));\r
-\r
-               Res = FullRead(SockHand, Msg + sizeof (struct IpcHeader),\r
-                       Header.Size - sizeof (struct IpcHeader));\r
-\r
-               if (Res < 0)\r
-                       break;\r
-\r
-               SYSTEMTIME SysTime;\r
-               FILETIME FileTime;\r
-\r
-               ::GetSystemTime(&SysTime);\r
-               ::SystemTimeToFileTime(&SysTime, &FileTime);\r
-\r
-               Now = *(unsigned __int64 *)&FileTime;\r
-\r
-               switch (Header.Type)\r
-               {\r
-               case MSG_TYPE_IPC_ROUTE:\r
-                       HandleIpcRoute((struct IpcRoute *)Msg);\r
-                       break;\r
-\r
-               case MSG_TYPE_IPC_CONFIG:\r
-                       HandleIpcConfig((struct IpcConfig *)Msg);\r
-                       break;\r
-\r
-               case MSG_TYPE_OLSR_HELLO:\r
-                       HandleOlsrHello((struct OlsrHello *)Msg, 0);\r
-                       break;\r
-\r
-               case MSG_TYPE_OLSR_TC:\r
-                       HandleOlsrTc((struct OlsrTc *)Msg, 0);\r
-                       break;\r
-\r
-               case MSG_TYPE_OLSR_MID:\r
-                       HandleOlsrMid((struct OlsrHeader *)Msg);\r
-                       break;\r
-\r
-               case MSG_TYPE_OLSR_HNA:\r
-                       HandleOlsrHna((struct OlsrHeader *)Msg);\r
-                       break;\r
-\r
-               case MSG_TYPE_OLSR_LQ_HELLO:\r
-                       HandleOlsrHello((struct OlsrHello *)Msg, 1);\r
-                       break;\r
-\r
-               case MSG_TYPE_OLSR_LQ_TC:\r
-                       HandleOlsrTc((struct OlsrTc *)Msg, 1);\r
-                       break;\r
-               }\r
-\r
-               delete[] Msg;\r
-\r
-               // XXX - nodes are only timed out while messages keep coming in\r
-\r
-               Timeout();\r
-       }\r
-\r
-       AfxEndThread(0);\r
-       return 0;\r
-}\r
-\r
-unsigned int CFrontendDlg::LogThreadFunc(void)\r
-{\r
-       char Buff[1000];\r
-       int Len;\r
-       int Left, Right;\r
-       CString Line;\r
-       CString Int;\r
-\r
-       while (::ReadFile(OutRead, Buff, sizeof (Buff) - 1, (unsigned long *)&Len, NULL))\r
-       {\r
-               if (Len == 0)\r
-                       break;\r
-\r
-               Left = 0;\r
-\r
-               for (Right = 0; Right < Len; Right++)\r
-               {\r
-                       if (Buff[Right] != 13)\r
-                               Buff[Left++] = Buff[Right];\r
-               }\r
-\r
-               Len = Left;\r
-\r
-               Left = 0;\r
-\r
-               for (Right = 0; Right < Len; Right++)\r
-               {\r
-                       if (Buff[Right] == 10)\r
-                       {\r
-                               Buff[Right] = 0;\r
-                               Line += (Buff + Left);\r
-\r
-                               if (PipeMode == PIPE_MODE_RUN)\r
-                                       m_TabCtrl.m_Dialog1.AddOutputLine(Line);\r
-\r
-                               else if (Line.GetLength() > 8 && Line[0] == 'i' && Line[1] == 'f')\r
-                               {\r
-                                       Int = Line.Mid(0, 4);\r
-                                       Int.MakeUpper();\r
-\r
-                                       Interfaces.Add(Int);\r
-                                       IsWlan.Add(Line.Mid(6, 1));\r
-                                       Addresses.Add(Line.Mid(8));\r
-                               }\r
-\r
-                               Line.Empty();\r
-\r
-                               Left = Right + 1;\r
-                       }\r
-               }\r
-\r
-               Buff[Right] = 0;\r
-               Line += (Buff + Left);\r
-       }\r
-\r
-       if (PipeMode == PIPE_MODE_RUN)\r
-       {\r
-               m_StopButton.EnableWindow(FALSE);\r
-               m_StartButton.EnableWindow(TRUE);\r
-       }\r
-\r
-       AfxEndThread(0);\r
-       return 0;\r
-}\r
-\r
-static unsigned int LogThreadStub(void *Arg)\r
-{\r
-       class CFrontendDlg *This;\r
-\r
-       This = (class CFrontendDlg *)Arg;\r
-\r
-       return This->LogThreadFunc();\r
-}\r
-\r
-static unsigned int NetThreadStub(void *Arg)\r
-{\r
-       class CFrontendDlg *This;\r
-\r
-       This = (class CFrontendDlg *)Arg;\r
-\r
-       return This->NetThreadFunc();\r
-}\r
-\r
-int CFrontendDlg::ExecutePipe(const char *CmdLine, HANDLE *InWrite,\r
-                                                         HANDLE *OutRead, HANDLE *ShimProc)\r
-{\r
-       SECURITY_ATTRIBUTES SecAttr;\r
-       HANDLE OutWrite, OutReadTmp;\r
-       HANDLE ErrWrite;\r
-       HANDLE InRead, InWriteTmp;\r
-       HANDLE Proc;\r
-       STARTUPINFO StartupInfo;\r
-       PROCESS_INFORMATION ProcessInfo;\r
-\r
-       SecAttr.nLength = sizeof (SECURITY_ATTRIBUTES);\r
-       SecAttr.lpSecurityDescriptor = NULL;\r
-       SecAttr.bInheritHandle = TRUE;\r
-\r
-       Proc = ::GetCurrentProcess();\r
-\r
-       if (!::CreatePipe(&OutReadTmp, &OutWrite, &SecAttr, 0))\r
-       {\r
-               AfxMessageBox("Cannot create stdout pipe.");\r
-               return -1;\r
-       }\r
-\r
-       if (!::DuplicateHandle(Proc, OutReadTmp, Proc, OutRead,\r
-               0, FALSE, DUPLICATE_SAME_ACCESS))\r
-       {\r
-               AfxMessageBox("Cannot duplicate temporary stdout read handle.");\r
-               return -1;\r
-       }\r
-\r
-       if (!::CloseHandle(OutReadTmp))\r
-       {\r
-               AfxMessageBox("Cannot close temporary stdout read handle.");\r
-               return -1;\r
-       }\r
-\r
-       if (!::CreatePipe(&InRead, &InWriteTmp, &SecAttr, 0))\r
-       {\r
-               AfxMessageBox("Cannot create stdin pipe.");\r
-               return -1;\r
-       }\r
-\r
-       if (!::DuplicateHandle(Proc, InWriteTmp, Proc, InWrite,\r
-               0, FALSE, DUPLICATE_SAME_ACCESS))\r
-       {\r
-               AfxMessageBox("Cannot duplicate temporary stdin write handle.");\r
-               return -1;\r
-       }\r
-\r
-       if (!::CloseHandle(InWriteTmp))\r
-       {\r
-               AfxMessageBox("Cannot close temporary stdin write handle.");\r
-               return -1;\r
-       }\r
-\r
-       if (!::DuplicateHandle(Proc, OutWrite, Proc, &ErrWrite,\r
-               0, TRUE, DUPLICATE_SAME_ACCESS))\r
-       {\r
-               AfxMessageBox("Cannot duplicate stdout write handle for stderr.");\r
-               return -1;\r
-       }\r
-\r
-       ::memset(&StartupInfo, 0, sizeof (STARTUPINFO));\r
-\r
-       StartupInfo.cb = sizeof (STARTUPINFO);\r
-\r
-       StartupInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;\r
-\r
-       StartupInfo.hStdInput = InRead;\r
-       StartupInfo.hStdOutput = OutWrite;\r
-       StartupInfo.hStdError = ErrWrite;\r
-\r
-       StartupInfo.wShowWindow = SW_HIDE;\r
-\r
-       if (!::CreateProcess(NULL, (char *)CmdLine, NULL, NULL, TRUE,\r
-               0, NULL, NULL, &StartupInfo, &ProcessInfo))\r
-       {\r
-               AfxMessageBox("Cannot create OLSR server process.");\r
-               return -1;\r
-       }\r
-\r
-       if (!::CloseHandle(InRead))\r
-       {\r
-               AfxMessageBox("Cannot close stdin read handle.");\r
-               return -1;\r
-       }\r
-\r
-       if (!::CloseHandle(OutWrite))\r
-       {\r
-               AfxMessageBox("Cannot close stdout write handle.");\r
-               return -1;\r
-       }\r
-\r
-       if (!::CloseHandle(ErrWrite))\r
-       {\r
-               AfxMessageBox("Cannot close stderr write handle.");\r
-               return -1;\r
-       }\r
-\r
-       *ShimProc = ProcessInfo.hProcess;\r
-\r
-       return 0;\r
-}\r
-\r
-int CFrontendDlg::GetInterfaces()\r
-{\r
-       char GuiPath[MAX_PATH];\r
-       CString CmdLine;\r
-       CWinThread *IntThread;\r
-\r
-       ::GetModuleFileName(NULL, GuiPath, MAX_PATH);\r
-\r
-       CmdLine = GuiPath;\r
-       CmdLine = CmdLine.Mid(0, CmdLine.ReverseFind('\\')) + "\\olsrd.exe -int";\r
-\r
-       if (ExecutePipe((const char *)CmdLine, &InWrite, &OutRead, &ShimProc) < 0)\r
-       {\r
-               AfxMessageBox("Cannot execute '" + CmdLine + "'.");\r
-               return -1;\r
-       }\r
-\r
-       PipeMode = PIPE_MODE_INT;\r
-\r
-       IntThread = AfxBeginThread(LogThreadStub, (void *)this);\r
-\r
-       ::WaitForSingleObject((HANDLE)(*IntThread), INFINITE);\r
-\r
-       return 0;\r
-}\r
-\r
-int CFrontendDlg::StartOlsrd()\r
-{\r
-       WSADATA WsaData;\r
-       CString CmdLine;\r
-       char Path[MAX_PATH];\r
-       char TempPath[MAX_PATH];\r
-       int Try;\r
-\r
-       m_TabCtrl.m_Dialog3.ClearNodeInfo();\r
-       m_TabCtrl.m_Dialog4.ClearRoutes();\r
-\r
-       if (WSAStartup(0x0202, &WsaData))\r
-       {\r
-               AfxMessageBox("Cannot initialize WinSock library.");\r
-               return -1;\r
-       }\r
-\r
-       ::GetModuleFileName(NULL, Path, MAX_PATH);\r
-\r
-       CmdLine = Path;\r
-       CmdLine = CmdLine.Mid(0, CmdLine.ReverseFind('\\')) + "\\Shim.exe";\r
-\r
-       ::GetTempPath(MAX_PATH - 16, Path);\r
-       ::GetTempFileName(Path, "GNU", 0, TempPath);\r
-\r
-       StoredTempFile = TempPath;\r
-\r
-       if (m_TabCtrl.m_Dialog2.SaveConfigFile(StoredTempFile, 0) < 0)\r
-       {\r
-               AfxMessageBox("Cannot save temporary configuration file '" + \r
-                       StoredTempFile + "'.");\r
-               return -1;\r
-       }\r
-\r
-       CmdLine += " -f " + StoredTempFile;\r
-\r
-       if (ExecutePipe((const char *)CmdLine, &InWrite, &OutRead, &ShimProc) < 0)\r
-       {\r
-               AfxMessageBox("Cannot execute '" + CmdLine + "'.");\r
-               return -1;\r
-       }\r
-\r
-       PipeMode = PIPE_MODE_RUN;\r
-\r
-       LogThread = AfxBeginThread(LogThreadStub, (void *)this);\r
-\r
-       struct sockaddr_in Addr;\r
-\r
-       Addr.sin_family = AF_INET;\r
-       Addr.sin_port = ::htons(1212);\r
-       Addr.sin_addr.s_addr = ::inet_addr("127.0.0.1");\r
-\r
-       SockHand = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);\r
-\r
-       if (SockHand < 0)\r
-       {\r
-               AfxMessageBox("Cannot create IPC socket.");\r
-\r
-               ::SetEvent(Event);\r
-               ::WaitForSingleObject((HANDLE)LogThread, INFINITE);\r
-\r
-               LogThread = NULL;\r
-\r
-               return -1;\r
-       }\r
-\r
-       for (Try = 0; Try < 5; Try++)\r
-       {\r
-               if (::connect(SockHand, (struct sockaddr *)&Addr,\r
-                       sizeof (struct sockaddr_in)) >= 0)\r
-                       break;\r
-\r
-               ::Sleep(500);\r
-       }\r
-\r
-       if (Try == 10)\r
-       {\r
-               AfxMessageBox("Cannot connect to IPC port.");\r
-\r
-               ::SetEvent(Event);\r
-               ::WaitForSingleObject((HANDLE)LogThread, INFINITE);\r
-\r
-               ::closesocket(SockHand);\r
-\r
-               LogThread = NULL;\r
-\r
-               return -1;\r
-       }\r
-\r
-       NetThread = AfxBeginThread(NetThreadStub, (void *)this);\r
-\r
-       return 0;\r
-}\r
-\r
-int CFrontendDlg::StopOlsrd()\r
-{\r
-       if (LogThread == NULL && NetThread == NULL)\r
-               return 0;\r
-\r
-       TrayIcon::getInstance()->setStatus( TrayIcon::OFF, "Off" );\r
-\r
-       ::SetEvent(Event);\r
-\r
-       ::WaitForSingleObject((HANDLE)LogThread, INFINITE);\r
-       ::WaitForSingleObject((HANDLE)NetThread, INFINITE);\r
-\r
-       LogThread = NULL;\r
-       NetThread = NULL;\r
-\r
-       ::DeleteFile(StoredTempFile);\r
-\r
-       return 0;\r
-}\r
-\r
-BOOL CFrontendDlg::OnInitDialog()\r
-{\r
-       HICON Small, Large;\r
-\r
-       CDialog::OnInitDialog();\r
-\r
-       Small = (HICON)::LoadImage(AfxGetApp()->m_hInstance,\r
-               MAKEINTRESOURCE(IDI_ICON1),\r
-               IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),\r
-               GetSystemMetrics(SM_CYSMICON), 0);\r
-\r
-       Large = (HICON)::LoadImage(AfxGetApp()->m_hInstance,\r
-               MAKEINTRESOURCE(IDI_ICON1),\r
-               IMAGE_ICON, GetSystemMetrics(SM_CXICON),\r
-               GetSystemMetrics(SM_CYICON), 0);\r
-\r
-       SetIcon(Small, FALSE);\r
-       SetIcon(Large, TRUE);\r
-\r
-       GetInterfaces();\r
-\r
-       m_TabCtrl.InsertItem(0, "Settings");\r
-       m_TabCtrl.InsertItem(1, "Output");\r
-       m_TabCtrl.InsertItem(2, "Nodes");\r
-       m_TabCtrl.InsertItem(3, "Routes");\r
-\r
-       m_TabCtrl.InitTabDialogs(&Interfaces, &Addresses, &IsWlan);\r
-\r
-       m_StopButton.EnableWindow(FALSE);\r
-\r
-       if (!ConfigFile.IsEmpty())\r
-       {\r
-               if (m_TabCtrl.m_Dialog2.OpenConfigFile(ConfigFile) < 0)\r
-                       AfxMessageBox("Cannot open configuration file '" + ConfigFile + "'.");\r
-\r
-               else\r
-               {\r
-                       OnStartButton();\r
-\r
-                       m_TabCtrl.SetCurSel(1);\r
-                       m_TabCtrl.DisplayTabDialog();\r
-               }\r
-       }\r
-\r
-       return TRUE;\r
-}\r
-\r
-void CFrontendDlg::OnOK()\r
-{\r
-}\r
-\r
-void CFrontendDlg::OnCancel()\r
-{\r
-       OnExitButton();\r
-}\r
-\r
-void CFrontendDlg::OnStartButton() \r
-{\r
-       m_StartButton.EnableWindow(FALSE);\r
-\r
-       m_TabCtrl.m_Dialog1.SetFrozen(1);\r
-\r
-       if (StartOlsrd() < 0)\r
-       {\r
-               m_TabCtrl.m_Dialog1.SetFrozen(0);\r
-               m_TabCtrl.m_Dialog1.AddOutputLine("");\r
-\r
-               AfxMessageBox("Cannot start OLSR server.");\r
-\r
-               m_StartButton.EnableWindow(TRUE);\r
-\r
-               return;\r
-       }\r
-\r
-       m_TabCtrl.m_Dialog1.HandleStart();\r
-\r
-       m_StopButton.EnableWindow(TRUE);\r
-}\r
-\r
-void CFrontendDlg::OnStopButton() \r
-{\r
-       if (StopOlsrd() < 0)\r
-               return;\r
-\r
-       m_TabCtrl.m_Dialog1.HandleStop();\r
-\r
-       m_StopButton.EnableWindow(FALSE);\r
-       m_StartButton.EnableWindow(TRUE);\r
-}\r
-\r
-void CFrontendDlg::OnExitButton()\r
-{\r
-       delete TrayIcon::getInstance();\r
-\r
-       if (StopOlsrd() < 0)\r
-               return;\r
-\r
-       m_TabCtrl.m_Dialog3.ClearNodeInfo();\r
-       m_TabCtrl.m_Dialog4.ClearRoutes();\r
-\r
-       DestroyWindow();\r
-}\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: FrontendDlg.cpp,v 1.11 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#include "stdafx.h"
+#include "Frontend.h"
+#include "FrontendDlg.h"
+#include "TrayIcon.h"
+
+#include "Ipc.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+CFrontendDlg::CFrontendDlg(CWnd* pParent)
+       : CDialog(CFrontendDlg::IDD, pParent)
+{
+       //{{AFX_DATA_INIT(CFrontendDlg)
+       //}}AFX_DATA_INIT
+
+       Event = CreateEvent(NULL, FALSE, FALSE, "TheOlsrdShimEvent");
+
+       LogThread = NULL;
+       NetThread = NULL;
+}
+
+void CFrontendDlg::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CFrontendDlg)
+       DDX_Control(pDX, IDC_BUTTON2, m_StopButton);
+       DDX_Control(pDX, IDC_BUTTON1, m_StartButton);
+       DDX_Control(pDX, IDC_TAB1, m_TabCtrl);
+       //}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CFrontendDlg, CDialog)
+       //{{AFX_MSG_MAP(CFrontendDlg)
+       ON_BN_CLICKED(IDC_BUTTON1, OnStartButton)
+       ON_BN_CLICKED(IDC_BUTTON2, OnStopButton)
+       ON_BN_CLICKED(IDC_BUTTON3, OnExitButton)
+       ON_BN_CLICKED(IDOK, OnOK)
+       ON_BN_CLICKED(IDCANCEL, OnCancel)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+#if 0
+static void HexDump(unsigned char *Mem, int Len)
+{
+       char Buff[10000];
+       int i, k;
+       char *Walker = Buff;
+
+       for (i = 0; i < Len; i += k)
+       {
+               Walker += sprintf(Walker, "%08x:", i);
+
+               for (k = 0; i + k < Len && k < 16; k++)
+                       Walker += sprintf(Walker, " %02x", Mem[i + k]);
+
+               while (k < 16)
+               {
+                       Walker += sprintf(Walker, "   ");
+                       k++;
+               }
+
+               Walker += sprintf(Walker, " ");
+
+               for (k = 0; i + k < Len && k < 16; k++)
+                       if (Mem[i + k] < 32 || Mem[i + k] > 126)
+                               Walker += sprintf(Walker, ".");
+
+                       else
+                               Walker += sprintf(Walker, "%c", Mem[i + k]);
+
+               Walker += sprintf(Walker, "\r\n");
+       }
+
+       ::MessageBox(NULL, Buff, "HEXDUMP", MB_OK);
+}
+#endif
+
+// XXX - pretty inefficient
+
+void CFrontendDlg::Timeout(void)
+{
+       POSITION Pos, Pos2;
+       class NodeEntry Entry;
+       class MprEntry MprEntry;
+       class MidEntry MidEntry;
+       class HnaEntry HnaEntry;
+
+Restart0:
+       Pos = NodeList.GetHeadPosition();
+
+       while (Pos != NULL)
+       {
+               Entry = NodeList.GetAt(Pos);
+
+               if (Entry.Timeout < Now)
+               {
+                       NodeList.RemoveAt(Pos);
+                       goto Restart0;
+               }
+
+Restart1:
+               Pos2 = Entry.MprList.GetHeadPosition();
+
+               while (Pos2 != NULL)
+               {
+                       MprEntry = Entry.MprList.GetAt(Pos2);
+
+                       if (MprEntry.Timeout < Now)
+                       {
+                               Entry.MprList.RemoveAt(Pos2);
+                               goto Restart1;
+                       }
+
+                       Entry.MprList.GetNext(Pos2);
+               }
+
+Restart2:
+               Pos2 = Entry.MidList.GetHeadPosition();
+
+               while (Pos2 != NULL)
+               {
+                       MidEntry = Entry.MidList.GetAt(Pos2);
+
+                       if (MidEntry.Timeout < Now)
+                       {
+                               Entry.MidList.RemoveAt(Pos2);
+                               goto Restart2;
+                       }
+
+                       Entry.MidList.GetNext(Pos2);
+               }
+
+Restart3:
+               Pos2 = Entry.HnaList.GetHeadPosition();
+
+               while (Pos2 != NULL)
+               {
+                       HnaEntry = Entry.HnaList.GetAt(Pos2);
+
+                       if (HnaEntry.Timeout < Now)
+                       {
+                               Entry.HnaList.RemoveAt(Pos2);
+                               goto Restart3;
+                       }
+
+                       Entry.HnaList.GetNext(Pos2);
+               }
+
+               NodeList.GetNext(Pos);
+       }
+
+       if( NodeList.IsEmpty() )
+               TrayIcon::getInstance()->setStatus( TrayIcon::ON, "No nodes found" );
+       else
+               TrayIcon::getInstance()->setStatus( TrayIcon::CONNECTED, "Nodes available" );
+
+       m_TabCtrl.m_Dialog3.UpdateNodeInfo(NodeList);
+}
+
+unsigned int VTimeToInt(unsigned int VTime)
+{
+       return ((0x10 | ((VTime & 0xf0) >> 4)) << (VTime & 0x0f)) >> 8;
+}
+
+void CFrontendDlg::AddMpr(unsigned int MprAddr, unsigned int NodeAddr,
+                                                 unsigned int VTime)
+{
+       class NodeEntry NewEntry;
+       POSITION Pos;
+       unsigned __int64 Timeout;
+
+       Timeout = Now +
+               (unsigned __int64)VTimeToInt(VTime) * (unsigned __int64)10000000;
+
+       AddNode(NodeAddr, VTime);
+       AddNode(MprAddr, VTime);
+
+       NewEntry.Addr = NodeAddr;
+
+       Pos = NodeList.Find(NewEntry);
+
+       if (Pos == NULL)
+               return;
+
+       class NodeEntry &OldEntry = NodeList.GetAt(Pos);
+
+       OldEntry.AddMpr(MprAddr, Timeout);
+
+       m_TabCtrl.m_Dialog3.UpdateNodeInfo(NodeList);
+}
+
+void CFrontendDlg::AddMid(unsigned int IntAddr, unsigned int NodeAddr,
+                                                 unsigned int VTime)
+{
+       class NodeEntry NewEntry;
+       POSITION Pos;
+       unsigned __int64 Timeout;
+
+       Timeout = Now +
+               (unsigned __int64)VTimeToInt(VTime) * (unsigned __int64)10000000;
+
+       AddNode(NodeAddr, VTime);
+
+       NewEntry.Addr = NodeAddr;
+
+       Pos = NodeList.Find(NewEntry);
+
+       if (Pos == NULL)
+               return;
+
+       class NodeEntry &OldEntry = NodeList.GetAt(Pos);
+
+       OldEntry.AddMid(IntAddr, Timeout);
+
+       m_TabCtrl.m_Dialog3.UpdateNodeInfo(NodeList);
+}
+
+void CFrontendDlg::AddHna(unsigned int NetAddr, unsigned int NetMask,
+                                                 unsigned int NodeAddr, unsigned int VTime)
+{
+       class NodeEntry NewEntry;
+       POSITION Pos;
+       unsigned __int64 Timeout;
+
+       Timeout = Now +
+               (unsigned __int64)VTimeToInt(VTime) * (unsigned __int64)10000000;
+
+       AddNode(NodeAddr, VTime);
+
+       NewEntry.Addr = NodeAddr;
+
+       Pos = NodeList.Find(NewEntry);
+
+       if (Pos == NULL)
+               return;
+
+       class NodeEntry &OldEntry = NodeList.GetAt(Pos);
+
+       OldEntry.AddHna(NetAddr, NetMask, Timeout);
+
+       m_TabCtrl.m_Dialog3.UpdateNodeInfo(NodeList);
+}
+
+void CFrontendDlg::AddNode(unsigned int NodeAddr, unsigned int VTime)
+{
+       class NodeEntry NewEntry;
+       POSITION Pos;
+       unsigned __int64 Timeout;
+
+       if (NodeAddr == LocalHost)
+               return;
+
+       Timeout = Now +
+               (unsigned __int64)VTimeToInt(VTime) * (unsigned __int64)10000000;
+
+       NewEntry.Addr = NodeAddr;
+
+       Pos = NodeList.Find(NewEntry);
+
+       if (Pos != NULL)
+       {
+               class NodeEntry &OldEntry = NodeList.GetAt(Pos);
+               OldEntry.Timeout = Timeout;
+       }
+
+       else
+       {
+               NewEntry.Timeout = Timeout;
+               NodeList.AddTail(NewEntry);
+       }
+
+       m_TabCtrl.m_Dialog3.UpdateNodeInfo(NodeList);
+}
+
+void CFrontendDlg::HandleOlsrTc(struct OlsrTc *Msg, int UseLq)
+{
+       int Size;
+       unsigned int *Addr;
+
+       Msg->Header.SeqNo = ::ntohs(Msg->Header.SeqNo);
+       Msg->Ansn = ::ntohs(Msg->Ansn);
+
+       AddNode(Msg->Header.Orig, Msg->Header.VTime);
+
+       Size = Msg->Header.Size;
+
+       Size -= sizeof (struct OlsrTc);
+
+       Addr = (unsigned int *)(Msg + 1);
+
+       while (Size > 0)
+       {
+               Size -= 4;
+
+               AddMpr(*Addr, Msg->Header.Orig, Msg->Header.VTime);
+
+               Addr++;
+
+               if (UseLq != 0)
+               {
+                       Size -= 4;
+                       Addr++;
+               }
+
+       }
+}
+
+void CFrontendDlg::HandleOlsrMid(struct OlsrHeader *Msg)
+{
+       int Size;
+       unsigned int *Addr;
+
+       Msg->SeqNo = ::ntohs(Msg->SeqNo);
+
+       AddNode(Msg->Orig, Msg->VTime);
+
+       Size = Msg->Size;
+
+       Size -= sizeof (struct OlsrHeader);
+
+       Addr = (unsigned int *)(Msg + 1);
+
+       while (Size > 0)
+       {
+               Size -= 4;
+
+               AddMid(*Addr, Msg->Orig, Msg->VTime);
+
+               Addr++;
+       }
+}
+
+void CFrontendDlg::HandleOlsrHna(struct OlsrHeader *Msg)
+{
+       int Size;
+       unsigned int *Addr;
+
+       Msg->SeqNo = ::ntohs(Msg->SeqNo);
+
+       AddNode(Msg->Orig, Msg->VTime);
+
+       Size = Msg->Size;
+
+       Size -= sizeof (struct OlsrHeader);
+
+       Addr = (unsigned int *)(Msg + 1);
+
+       while (Size > 0)
+       {
+               Size -= 8;
+
+               AddHna(Addr[0], Addr[1], Msg->Orig, Msg->VTime);
+
+               Addr += 2;
+       }
+}
+
+void CFrontendDlg::HandleOlsrHello(struct OlsrHello *Msg, int UseLq)
+{
+       int Size, LinkSize;
+       struct OlsrHelloLink *Link;
+       unsigned int *Addr;
+
+       Msg->Header.SeqNo = ::ntohs(Msg->Header.SeqNo);
+
+       AddNode(Msg->Header.Orig, Msg->Header.VTime);
+
+       Size = Msg->Header.Size;
+
+       Size -= sizeof (struct OlsrHello);
+
+       Link = (struct OlsrHelloLink *)(Msg + 1);
+
+       while (Size > 0)
+       {
+               Link->Size = ::ntohs(Link->Size);
+
+               LinkSize = Link->Size;
+
+               Size -= LinkSize;
+
+               LinkSize -= sizeof (struct OlsrHelloLink);
+
+               Addr = (unsigned int *)(Link + 1);
+
+               while (LinkSize > 0)
+               {
+                       LinkSize -= 4;
+
+                       AddNode(*Addr, Msg->Header.VTime);
+
+                       if ((Link->LinkCode & 0x0c) == 0x08)
+                               AddMpr(*Addr, Msg->Header.Orig, Msg->Header.VTime);
+
+                       Addr++;
+
+                       if (UseLq != 0)
+                       {
+                               LinkSize -= 4;
+                               Addr++;
+                       }
+               }
+
+               Link = (struct OlsrHelloLink *)Addr;
+       }
+}
+
+void CFrontendDlg::HandleIpcRoute(struct IpcRoute *Msg)
+{
+       if (Msg->Header.Size != sizeof (struct IpcRoute))
+               return;
+
+       if (Msg->Add == 0)
+               m_TabCtrl.m_Dialog4.DeleteRoute(Msg->Dest.v4);
+
+       else
+               m_TabCtrl.m_Dialog4.AddRoute(Msg->Dest.v4, Msg->Gate.v4, Msg->Metric,
+               Msg->Int);
+}
+
+void CFrontendDlg::HandleIpcConfig(struct IpcConfig *Msg)
+{
+       if (Msg->Header.Size != sizeof (struct IpcConfig))
+               return;
+
+       Msg->HelloInt = ::ntohs(Msg->HelloInt);
+       Msg->WiredHelloInt = ::ntohs(Msg->WiredHelloInt);
+       Msg->TcInt = ::ntohs(Msg->TcInt);
+
+       Msg->HelloHold = ::ntohs(Msg->HelloHold);
+       Msg->TcHold = ::ntohs(Msg->TcHold);
+
+       LocalHost = Msg->MainAddr.v4;
+}
+
+static int FullRead(SOCKET SockHand, char *Buff, int Len)
+{
+       int Res;
+
+       do
+       {
+               Res = ::recv(SockHand, Buff, Len, 0);
+
+               if (Res <= 0)
+                       return -1;
+
+               Len -= Res;
+               Buff += Res;
+       }
+       while (Len > 0);
+
+       return 0;
+}
+
+// XXX - we should have access to olsrd's internal data structures instead
+
+unsigned int CFrontendDlg::NetThreadFunc(void)
+{
+       struct IpcHeader Header;
+       int Res;
+       char *Msg;
+
+       for (;;)
+       {
+               Res = FullRead(SockHand, (char *)&Header, sizeof (struct IpcHeader));
+
+               if (Res < 0)
+                       break;
+
+               Header.Size = ntohs(Header.Size);
+
+               Msg = new char [Header.Size];
+
+               ::memcpy(Msg, &Header, sizeof (struct IpcHeader));
+
+               Res = FullRead(SockHand, Msg + sizeof (struct IpcHeader),
+                       Header.Size - sizeof (struct IpcHeader));
+
+               if (Res < 0)
+                       break;
+
+               SYSTEMTIME SysTime;
+               FILETIME FileTime;
+
+               ::GetSystemTime(&SysTime);
+               ::SystemTimeToFileTime(&SysTime, &FileTime);
+
+               Now = *(unsigned __int64 *)&FileTime;
+
+               switch (Header.Type)
+               {
+               case MSG_TYPE_IPC_ROUTE:
+                       HandleIpcRoute((struct IpcRoute *)Msg);
+                       break;
+
+               case MSG_TYPE_IPC_CONFIG:
+                       HandleIpcConfig((struct IpcConfig *)Msg);
+                       break;
+
+               case MSG_TYPE_OLSR_HELLO:
+                       HandleOlsrHello((struct OlsrHello *)Msg, 0);
+                       break;
+
+               case MSG_TYPE_OLSR_TC:
+                       HandleOlsrTc((struct OlsrTc *)Msg, 0);
+                       break;
+
+               case MSG_TYPE_OLSR_MID:
+                       HandleOlsrMid((struct OlsrHeader *)Msg);
+                       break;
+
+               case MSG_TYPE_OLSR_HNA:
+                       HandleOlsrHna((struct OlsrHeader *)Msg);
+                       break;
+
+               case MSG_TYPE_OLSR_LQ_HELLO:
+                       HandleOlsrHello((struct OlsrHello *)Msg, 1);
+                       break;
+
+               case MSG_TYPE_OLSR_LQ_TC:
+                       HandleOlsrTc((struct OlsrTc *)Msg, 1);
+                       break;
+               }
+
+               delete[] Msg;
+
+               // XXX - nodes are only timed out while messages keep coming in
+
+               Timeout();
+       }
+
+       AfxEndThread(0);
+       return 0;
+}
+
+unsigned int CFrontendDlg::LogThreadFunc(void)
+{
+       char Buff[1000];
+       int Len;
+       int Left, Right;
+       CString Line;
+       CString Int;
+
+       while (::ReadFile(OutRead, Buff, sizeof (Buff) - 1, (unsigned long *)&Len, NULL))
+       {
+               if (Len == 0)
+                       break;
+
+               Left = 0;
+
+               for (Right = 0; Right < Len; Right++)
+               {
+                       if (Buff[Right] != 13)
+                               Buff[Left++] = Buff[Right];
+               }
+
+               Len = Left;
+
+               Left = 0;
+
+               for (Right = 0; Right < Len; Right++)
+               {
+                       if (Buff[Right] == 10)
+                       {
+                               Buff[Right] = 0;
+                               Line += (Buff + Left);
+
+                               if (PipeMode == PIPE_MODE_RUN)
+                                       m_TabCtrl.m_Dialog1.AddOutputLine(Line);
+
+                               else if (Line.GetLength() > 8 && Line[0] == 'i' && Line[1] == 'f')
+                               {
+                                       Int = Line.Mid(0, 4);
+                                       Int.MakeUpper();
+
+                                       Interfaces.Add(Int);
+                                       IsWlan.Add(Line.Mid(6, 1));
+                                       Addresses.Add(Line.Mid(8));
+                               }
+
+                               Line.Empty();
+
+                               Left = Right + 1;
+                       }
+               }
+
+               Buff[Right] = 0;
+               Line += (Buff + Left);
+       }
+
+       if (PipeMode == PIPE_MODE_RUN)
+       {
+               m_StopButton.EnableWindow(FALSE);
+               m_StartButton.EnableWindow(TRUE);
+       }
+
+       AfxEndThread(0);
+       return 0;
+}
+
+static unsigned int LogThreadStub(void *Arg)
+{
+       class CFrontendDlg *This;
+
+       This = (class CFrontendDlg *)Arg;
+
+       return This->LogThreadFunc();
+}
+
+static unsigned int NetThreadStub(void *Arg)
+{
+       class CFrontendDlg *This;
+
+       This = (class CFrontendDlg *)Arg;
+
+       return This->NetThreadFunc();
+}
+
+int CFrontendDlg::ExecutePipe(const char *CmdLine, HANDLE *InWrite,
+                                                         HANDLE *OutRead, HANDLE *ShimProc)
+{
+       SECURITY_ATTRIBUTES SecAttr;
+       HANDLE OutWrite, OutReadTmp;
+       HANDLE ErrWrite;
+       HANDLE InRead, InWriteTmp;
+       HANDLE Proc;
+       STARTUPINFO StartupInfo;
+       PROCESS_INFORMATION ProcessInfo;
+
+       SecAttr.nLength = sizeof (SECURITY_ATTRIBUTES);
+       SecAttr.lpSecurityDescriptor = NULL;
+       SecAttr.bInheritHandle = TRUE;
+
+       Proc = ::GetCurrentProcess();
+
+       if (!::CreatePipe(&OutReadTmp, &OutWrite, &SecAttr, 0))
+       {
+               AfxMessageBox("Cannot create stdout pipe.");
+               return -1;
+       }
+
+       if (!::DuplicateHandle(Proc, OutReadTmp, Proc, OutRead,
+               0, FALSE, DUPLICATE_SAME_ACCESS))
+       {
+               AfxMessageBox("Cannot duplicate temporary stdout read handle.");
+               return -1;
+       }
+
+       if (!::CloseHandle(OutReadTmp))
+       {
+               AfxMessageBox("Cannot close temporary stdout read handle.");
+               return -1;
+       }
+
+       if (!::CreatePipe(&InRead, &InWriteTmp, &SecAttr, 0))
+       {
+               AfxMessageBox("Cannot create stdin pipe.");
+               return -1;
+       }
+
+       if (!::DuplicateHandle(Proc, InWriteTmp, Proc, InWrite,
+               0, FALSE, DUPLICATE_SAME_ACCESS))
+       {
+               AfxMessageBox("Cannot duplicate temporary stdin write handle.");
+               return -1;
+       }
+
+       if (!::CloseHandle(InWriteTmp))
+       {
+               AfxMessageBox("Cannot close temporary stdin write handle.");
+               return -1;
+       }
+
+       if (!::DuplicateHandle(Proc, OutWrite, Proc, &ErrWrite,
+               0, TRUE, DUPLICATE_SAME_ACCESS))
+       {
+               AfxMessageBox("Cannot duplicate stdout write handle for stderr.");
+               return -1;
+       }
+
+       ::memset(&StartupInfo, 0, sizeof (STARTUPINFO));
+
+       StartupInfo.cb = sizeof (STARTUPINFO);
+
+       StartupInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
+
+       StartupInfo.hStdInput = InRead;
+       StartupInfo.hStdOutput = OutWrite;
+       StartupInfo.hStdError = ErrWrite;
+
+       StartupInfo.wShowWindow = SW_HIDE;
+
+       if (!::CreateProcess(NULL, (char *)CmdLine, NULL, NULL, TRUE,
+               0, NULL, NULL, &StartupInfo, &ProcessInfo))
+       {
+               AfxMessageBox("Cannot create OLSR server process.");
+               return -1;
+       }
+
+       if (!::CloseHandle(InRead))
+       {
+               AfxMessageBox("Cannot close stdin read handle.");
+               return -1;
+       }
+
+       if (!::CloseHandle(OutWrite))
+       {
+               AfxMessageBox("Cannot close stdout write handle.");
+               return -1;
+       }
+
+       if (!::CloseHandle(ErrWrite))
+       {
+               AfxMessageBox("Cannot close stderr write handle.");
+               return -1;
+       }
+
+       *ShimProc = ProcessInfo.hProcess;
+
+       return 0;
+}
+
+int CFrontendDlg::GetInterfaces()
+{
+       char GuiPath[MAX_PATH];
+       CString CmdLine;
+       CWinThread *IntThread;
+
+       ::GetModuleFileName(NULL, GuiPath, MAX_PATH);
+
+       CmdLine = GuiPath;
+       CmdLine = CmdLine.Mid(0, CmdLine.ReverseFind('\\')) + "\\olsrd.exe -int";
+
+       if (ExecutePipe((const char *)CmdLine, &InWrite, &OutRead, &ShimProc) < 0)
+       {
+               AfxMessageBox("Cannot execute '" + CmdLine + "'.");
+               return -1;
+       }
+
+       PipeMode = PIPE_MODE_INT;
+
+       IntThread = AfxBeginThread(LogThreadStub, (void *)this);
+
+       ::WaitForSingleObject((HANDLE)(*IntThread), INFINITE);
+
+       return 0;
+}
+
+int CFrontendDlg::StartOlsrd()
+{
+       WSADATA WsaData;
+       CString CmdLine;
+       char Path[MAX_PATH];
+       char TempPath[MAX_PATH];
+       int Try;
+
+       m_TabCtrl.m_Dialog3.ClearNodeInfo();
+       m_TabCtrl.m_Dialog4.ClearRoutes();
+
+       if (WSAStartup(0x0202, &WsaData))
+       {
+               AfxMessageBox("Cannot initialize WinSock library.");
+               return -1;
+       }
+
+       ::GetModuleFileName(NULL, Path, MAX_PATH);
+
+       CmdLine = Path;
+       CmdLine = CmdLine.Mid(0, CmdLine.ReverseFind('\\')) + "\\Shim.exe";
+
+       ::GetTempPath(MAX_PATH - 16, Path);
+       ::GetTempFileName(Path, "GNU", 0, TempPath);
+
+       StoredTempFile = TempPath;
+
+       if (m_TabCtrl.m_Dialog2.SaveConfigFile(StoredTempFile, 0) < 0)
+       {
+               AfxMessageBox("Cannot save temporary configuration file '" + 
+                       StoredTempFile + "'.");
+               return -1;
+       }
+
+       CmdLine += " -f " + StoredTempFile;
+
+       if (ExecutePipe((const char *)CmdLine, &InWrite, &OutRead, &ShimProc) < 0)
+       {
+               AfxMessageBox("Cannot execute '" + CmdLine + "'.");
+               return -1;
+       }
+
+       PipeMode = PIPE_MODE_RUN;
+
+       LogThread = AfxBeginThread(LogThreadStub, (void *)this);
+
+       struct sockaddr_in Addr;
+
+       Addr.sin_family = AF_INET;
+       Addr.sin_port = ::htons(1212);
+       Addr.sin_addr.s_addr = ::inet_addr("127.0.0.1");
+
+       SockHand = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+
+       if (SockHand < 0)
+       {
+               AfxMessageBox("Cannot create IPC socket.");
+
+               ::SetEvent(Event);
+               ::WaitForSingleObject((HANDLE)LogThread, INFINITE);
+
+               LogThread = NULL;
+
+               return -1;
+       }
+
+       for (Try = 0; Try < 5; Try++)
+       {
+               if (::connect(SockHand, (struct sockaddr *)&Addr,
+                       sizeof (struct sockaddr_in)) >= 0)
+                       break;
+
+               ::Sleep(500);
+       }
+
+       if (Try == 10)
+       {
+               AfxMessageBox("Cannot connect to IPC port.");
+
+               ::SetEvent(Event);
+               ::WaitForSingleObject((HANDLE)LogThread, INFINITE);
+
+               ::closesocket(SockHand);
+
+               LogThread = NULL;
+
+               return -1;
+       }
+
+       NetThread = AfxBeginThread(NetThreadStub, (void *)this);
+
+       return 0;
+}
+
+int CFrontendDlg::StopOlsrd()
+{
+       if (LogThread == NULL && NetThread == NULL)
+               return 0;
+
+       TrayIcon::getInstance()->setStatus( TrayIcon::OFF, "Off" );
+
+       ::SetEvent(Event);
+
+       ::WaitForSingleObject((HANDLE)LogThread, INFINITE);
+       ::WaitForSingleObject((HANDLE)NetThread, INFINITE);
+
+       LogThread = NULL;
+       NetThread = NULL;
+
+       ::DeleteFile(StoredTempFile);
+
+       return 0;
+}
+
+BOOL CFrontendDlg::OnInitDialog()
+{
+       HICON Small, Large;
+
+       CDialog::OnInitDialog();
+
+       Small = (HICON)::LoadImage(AfxGetApp()->m_hInstance,
+               MAKEINTRESOURCE(IDI_ICON1),
+               IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
+               GetSystemMetrics(SM_CYSMICON), 0);
+
+       Large = (HICON)::LoadImage(AfxGetApp()->m_hInstance,
+               MAKEINTRESOURCE(IDI_ICON1),
+               IMAGE_ICON, GetSystemMetrics(SM_CXICON),
+               GetSystemMetrics(SM_CYICON), 0);
+
+       SetIcon(Small, FALSE);
+       SetIcon(Large, TRUE);
+
+       GetInterfaces();
+
+       m_TabCtrl.InsertItem(0, "Settings");
+       m_TabCtrl.InsertItem(1, "Output");
+       m_TabCtrl.InsertItem(2, "Nodes");
+       m_TabCtrl.InsertItem(3, "Routes");
+
+       m_TabCtrl.InitTabDialogs(&Interfaces, &Addresses, &IsWlan);
+
+       m_StopButton.EnableWindow(FALSE);
+
+       if (!ConfigFile.IsEmpty())
+       {
+               if (m_TabCtrl.m_Dialog2.OpenConfigFile(ConfigFile) < 0)
+                       AfxMessageBox("Cannot open configuration file '" + ConfigFile + "'.");
+
+               else
+               {
+                       OnStartButton();
+
+                       m_TabCtrl.SetCurSel(1);
+                       m_TabCtrl.DisplayTabDialog();
+               }
+       }
+
+       return TRUE;
+}
+
+void CFrontendDlg::OnOK()
+{
+}
+
+void CFrontendDlg::OnCancel()
+{
+       OnExitButton();
+}
+
+void CFrontendDlg::OnStartButton() 
+{
+       m_StartButton.EnableWindow(FALSE);
+
+       m_TabCtrl.m_Dialog1.SetFrozen(1);
+
+       if (StartOlsrd() < 0)
+       {
+               m_TabCtrl.m_Dialog1.SetFrozen(0);
+               m_TabCtrl.m_Dialog1.AddOutputLine("");
+
+               AfxMessageBox("Cannot start OLSR server.");
+
+               m_StartButton.EnableWindow(TRUE);
+
+               return;
+       }
+
+       m_TabCtrl.m_Dialog1.HandleStart();
+
+       m_StopButton.EnableWindow(TRUE);
+}
+
+void CFrontendDlg::OnStopButton() 
+{
+       if (StopOlsrd() < 0)
+               return;
+
+       m_TabCtrl.m_Dialog1.HandleStop();
+
+       m_StopButton.EnableWindow(FALSE);
+       m_StartButton.EnableWindow(TRUE);
+}
+
+void CFrontendDlg::OnExitButton()
+{
+       delete TrayIcon::getInstance();
+
+       if (StopOlsrd() < 0)
+               return;
+
+       m_TabCtrl.m_Dialog3.ClearNodeInfo();
+       m_TabCtrl.m_Dialog4.ClearRoutes();
+
+       DestroyWindow();
+}
index 17d37a2..7fdb273 100644 (file)
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: FrontendDlg.h,v 1.6 2005/01/17 11:52:36 tlopatic Exp $\r
- */\r
-\r
-#if !defined(AFX_FRONTENDDLG_H__7D68FBC0_7448_479B_81F0_3FBBDE291395__INCLUDED_)\r
-#define AFX_FRONTENDDLG_H__7D68FBC0_7448_479B_81F0_3FBBDE291395__INCLUDED_\r
-\r
-#if _MSC_VER > 1000\r
-#pragma once\r
-#endif\r
-\r
-#include "MyTabCtrl.h"\r
-#include "NodeEntry.h"\r
-\r
-#define PIPE_MODE_RUN 0\r
-#define PIPE_MODE_INT 1\r
-\r
-class CFrontendDlg : public CDialog\r
-{\r
-public:\r
-       CFrontendDlg(CWnd* pParent = NULL);\r
-\r
-       //{{AFX_DATA(CFrontendDlg)\r
-       enum { IDD = IDD_FRONTEND_DIALOG };\r
-       CButton m_StopButton;\r
-       CButton m_StartButton;\r
-       MyTabCtrl m_TabCtrl;\r
-       //}}AFX_DATA\r
-\r
-       unsigned int LogThreadFunc(void);\r
-       unsigned int NetThreadFunc(void);\r
-\r
-       CString ConfigFile;\r
-protected:\r
-\r
-       //{{AFX_VIRTUAL(CFrontendDlg)\r
-       virtual void DoDataExchange(CDataExchange* pDX);\r
-       //}}AFX_VIRTUAL\r
-\r
-public:\r
-       //{{AFX_MSG(CFrontendDlg)\r
-       virtual BOOL OnInitDialog();\r
-       afx_msg void OnOK();\r
-       afx_msg void OnCancel();\r
-       afx_msg void OnStartButton();\r
-       afx_msg void OnStopButton();\r
-       afx_msg void OnExitButton();\r
-       //}}AFX_MSG\r
-\r
-protected:\r
-       DECLARE_MESSAGE_MAP()\r
-\r
-       int StartOlsrd(void);\r
-       int StopOlsrd(void);\r
-\r
-       int GetInterfaces(void);\r
-\r
-       HANDLE Event;\r
-\r
-       CString StoredTempFile;\r
-\r
-       SOCKET SockHand;\r
-\r
-       int PipeMode;\r
-       int ExecutePipe(const char *, HANDLE *, HANDLE *, HANDLE *);\r
-\r
-       CWinThread *LogThread;\r
-       CWinThread *NetThread;\r
-\r
-       CStringArray Interfaces;\r
-       CStringArray Addresses;\r
-       CStringArray IsWlan;\r
-\r
-       HANDLE OutRead, InWrite;\r
-       HANDLE ShimProc;\r
-\r
-       void HandleIpcRoute(struct IpcRoute *);\r
-       void HandleIpcConfig(struct IpcConfig *);\r
-       void HandleOlsrHello(struct OlsrHello *, int);\r
-       void HandleOlsrTc(struct OlsrTc *, int);\r
-       void HandleOlsrMid(struct OlsrHeader *);\r
-       void HandleOlsrHna(struct OlsrHeader *);\r
-\r
-       void AddNode(unsigned int, unsigned int);\r
-       void AddMpr(unsigned int, unsigned int, unsigned int);\r
-       void AddMid(unsigned int, unsigned int, unsigned int);\r
-       void AddHna(unsigned int, unsigned int, unsigned int, unsigned int);\r
-\r
-       CList<class NodeEntry, class NodeEntry &> NodeList;\r
-\r
-       void Timeout(void);\r
-\r
-       unsigned __int64 Now;\r
-\r
-       unsigned int LocalHost;\r
-};\r
-\r
-//{{AFX_INSERT_LOCATION}}\r
-\r
-#endif\r
-\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: FrontendDlg.h,v 1.7 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#if !defined(AFX_FRONTENDDLG_H__7D68FBC0_7448_479B_81F0_3FBBDE291395__INCLUDED_)
+#define AFX_FRONTENDDLG_H__7D68FBC0_7448_479B_81F0_3FBBDE291395__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#include "MyTabCtrl.h"
+#include "NodeEntry.h"
+
+#define PIPE_MODE_RUN 0
+#define PIPE_MODE_INT 1
+
+class CFrontendDlg : public CDialog
+{
+public:
+       CFrontendDlg(CWnd* pParent = NULL);
+
+       //{{AFX_DATA(CFrontendDlg)
+       enum { IDD = IDD_FRONTEND_DIALOG };
+       CButton m_StopButton;
+       CButton m_StartButton;
+       MyTabCtrl m_TabCtrl;
+       //}}AFX_DATA
+
+       unsigned int LogThreadFunc(void);
+       unsigned int NetThreadFunc(void);
+
+       CString ConfigFile;
+protected:
+
+       //{{AFX_VIRTUAL(CFrontendDlg)
+       virtual void DoDataExchange(CDataExchange* pDX);
+       //}}AFX_VIRTUAL
+
+public:
+       //{{AFX_MSG(CFrontendDlg)
+       virtual BOOL OnInitDialog();
+       afx_msg void OnOK();
+       afx_msg void OnCancel();
+       afx_msg void OnStartButton();
+       afx_msg void OnStopButton();
+       afx_msg void OnExitButton();
+       //}}AFX_MSG
+
+protected:
+       DECLARE_MESSAGE_MAP()
+
+       int StartOlsrd(void);
+       int StopOlsrd(void);
+
+       int GetInterfaces(void);
+
+       HANDLE Event;
+
+       CString StoredTempFile;
+
+       SOCKET SockHand;
+
+       int PipeMode;
+       int ExecutePipe(const char *, HANDLE *, HANDLE *, HANDLE *);
+
+       CWinThread *LogThread;
+       CWinThread *NetThread;
+
+       CStringArray Interfaces;
+       CStringArray Addresses;
+       CStringArray IsWlan;
+
+       HANDLE OutRead, InWrite;
+       HANDLE ShimProc;
+
+       void HandleIpcRoute(struct IpcRoute *);
+       void HandleIpcConfig(struct IpcConfig *);
+       void HandleOlsrHello(struct OlsrHello *, int);
+       void HandleOlsrTc(struct OlsrTc *, int);
+       void HandleOlsrMid(struct OlsrHeader *);
+       void HandleOlsrHna(struct OlsrHeader *);
+
+       void AddNode(unsigned int, unsigned int);
+       void AddMpr(unsigned int, unsigned int, unsigned int);
+       void AddMid(unsigned int, unsigned int, unsigned int);
+       void AddHna(unsigned int, unsigned int, unsigned int, unsigned int);
+
+       CList<class NodeEntry, class NodeEntry &> NodeList;
+
+       void Timeout(void);
+
+       unsigned __int64 Now;
+
+       unsigned int LocalHost;
+};
+
+//{{AFX_INSERT_LOCATION}}
+
+#endif
+
index 3891fa1..787bc64 100644 (file)
@@ -1,57 +1,57 @@
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: HnaEntry.cpp,v 1.3 2004/11/21 01:21:10 tlopatic Exp $\r
- */\r
-\r
-#include "stdafx.h"\r
-#include "HnaEntry.h"\r
-\r
-class HnaEntry &HnaEntry::operator=(class HnaEntry &Src)\r
-{\r
-       Addr = Src.Addr;\r
-       Mask = Src.Mask;\r
-       Timeout = Src.Timeout;\r
-\r
-       return *this;\r
-}\r
-\r
-BOOL HnaEntry::operator==(const class HnaEntry &Comp) const\r
-{\r
-       return Addr == Comp.Addr && Mask == Comp.Mask;\r
-}\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: HnaEntry.cpp,v 1.4 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#include "stdafx.h"
+#include "HnaEntry.h"
+
+class HnaEntry &HnaEntry::operator=(class HnaEntry &Src)
+{
+       Addr = Src.Addr;
+       Mask = Src.Mask;
+       Timeout = Src.Timeout;
+
+       return *this;
+}
+
+BOOL HnaEntry::operator==(const class HnaEntry &Comp) const
+{
+       return Addr == Comp.Addr && Mask == Comp.Mask;
+}
index 7c407d0..f847487 100644 (file)
@@ -1,56 +1,56 @@
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: HnaEntry.h,v 1.3 2004/11/21 01:21:10 tlopatic Exp $\r
- */\r
-\r
-#if !defined TL_HNAENTRY_H\r
-#define TL_HNAENTRY_H\r
-\r
-class HnaEntry\r
-{\r
-public:\r
-       unsigned int Addr;\r
-       unsigned int Mask;\r
-       unsigned __int64 Timeout;\r
-\r
-       class HnaEntry &HnaEntry::operator=(class HnaEntry &);\r
-       BOOL HnaEntry::operator==(const class HnaEntry &) const;\r
-};\r
-\r
-#endif\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: HnaEntry.h,v 1.4 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#if !defined TL_HNAENTRY_H
+#define TL_HNAENTRY_H
+
+class HnaEntry
+{
+public:
+       unsigned int Addr;
+       unsigned int Mask;
+       unsigned __int64 Timeout;
+
+       class HnaEntry &HnaEntry::operator=(class HnaEntry &);
+       BOOL HnaEntry::operator==(const class HnaEntry &) const;
+};
+
+#endif
index de62c9a..383739e 100644 (file)
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: Ipc.h,v 1.5 2004/12/05 20:37:18 tlopatic Exp $\r
- */\r
-\r
-#if !defined TL_IPC_H\r
-#define TL_IPC_H\r
-\r
-#define MSG_TYPE_OLSR_HELLO 1\r
-#define MSG_TYPE_OLSR_TC 2\r
-#define MSG_TYPE_OLSR_MID 3\r
-#define MSG_TYPE_OLSR_HNA 4\r
-#define MSG_TYPE_OLSR_LQ_HELLO 201\r
-#define MSG_TYPE_OLSR_LQ_TC 202\r
-\r
-#define MSG_TYPE_IPC_ROUTE 11\r
-#define MSG_TYPE_IPC_CONFIG 12\r
-\r
-#pragma pack(push, BeforeIpcMessages, 1)\r
-\r
-struct OlsrHeader\r
-{\r
-       unsigned char Type;\r
-       unsigned char VTime;\r
-       unsigned short Size;\r
-       unsigned int Orig;\r
-       unsigned char Ttl;\r
-       unsigned char Hops;\r
-       unsigned short SeqNo;\r
-};\r
-\r
-struct OlsrHello\r
-{\r
-       struct OlsrHeader Header;\r
-\r
-       unsigned short Reserved;\r
-       unsigned char HTime;\r
-       unsigned char Will;\r
-};\r
-\r
-struct OlsrHelloLink\r
-{\r
-       unsigned char LinkCode;\r
-       unsigned char Reserved;\r
-       unsigned short Size;\r
-};\r
-\r
-struct OlsrTc\r
-{\r
-       struct OlsrHeader Header;\r
-\r
-       unsigned short Ansn;\r
-       unsigned short Reserved;\r
-};\r
-\r
-union IpcIpAddr\r
-{\r
-       unsigned int v4;\r
-       unsigned char v6[16];\r
-};\r
-\r
-struct IpcHeader\r
-{\r
-       unsigned char Type;\r
-       unsigned char Reserved;\r
-       unsigned short Size;\r
-};\r
-\r
-struct IpcRoute\r
-{\r
-       struct IpcHeader Header;\r
-       \r
-       unsigned char Metric;\r
-       unsigned char Add;\r
-       unsigned char Reserved[2];\r
-       union IpcIpAddr Dest;\r
-       union IpcIpAddr Gate;\r
-       char Int[4];\r
-};\r
-\r
-struct IpcConfig\r
-{\r
-       struct IpcHeader Header;\r
-\r
-       unsigned char NumMid;\r
-       unsigned char NumHna;\r
-       unsigned char Reserved1[2];\r
-       unsigned short HelloInt;\r
-       unsigned short WiredHelloInt;\r
-       unsigned short TcInt;\r
-       unsigned short HelloHold;\r
-       unsigned short TcHold;\r
-       unsigned char Ipv6;\r
-       unsigned char Reserved2;\r
-       IpcIpAddr MainAddr;\r
-};\r
-\r
-#pragma pack (pop, BeforeIpcMessages)\r
-\r
-#endif\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: Ipc.h,v 1.6 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#if !defined TL_IPC_H
+#define TL_IPC_H
+
+#define MSG_TYPE_OLSR_HELLO 1
+#define MSG_TYPE_OLSR_TC 2
+#define MSG_TYPE_OLSR_MID 3
+#define MSG_TYPE_OLSR_HNA 4
+#define MSG_TYPE_OLSR_LQ_HELLO 201
+#define MSG_TYPE_OLSR_LQ_TC 202
+
+#define MSG_TYPE_IPC_ROUTE 11
+#define MSG_TYPE_IPC_CONFIG 12
+
+#pragma pack(push, BeforeIpcMessages, 1)
+
+struct OlsrHeader
+{
+       unsigned char Type;
+       unsigned char VTime;
+       unsigned short Size;
+       unsigned int Orig;
+       unsigned char Ttl;
+       unsigned char Hops;
+       unsigned short SeqNo;
+};
+
+struct OlsrHello
+{
+       struct OlsrHeader Header;
+
+       unsigned short Reserved;
+       unsigned char HTime;
+       unsigned char Will;
+};
+
+struct OlsrHelloLink
+{
+       unsigned char LinkCode;
+       unsigned char Reserved;
+       unsigned short Size;
+};
+
+struct OlsrTc
+{
+       struct OlsrHeader Header;
+
+       unsigned short Ansn;
+       unsigned short Reserved;
+};
+
+union IpcIpAddr
+{
+       unsigned int v4;
+       unsigned char v6[16];
+};
+
+struct IpcHeader
+{
+       unsigned char Type;
+       unsigned char Reserved;
+       unsigned short Size;
+};
+
+struct IpcRoute
+{
+       struct IpcHeader Header;
+       
+       unsigned char Metric;
+       unsigned char Add;
+       unsigned char Reserved[2];
+       union IpcIpAddr Dest;
+       union IpcIpAddr Gate;
+       char Int[4];
+};
+
+struct IpcConfig
+{
+       struct IpcHeader Header;
+
+       unsigned char NumMid;
+       unsigned char NumHna;
+       unsigned char Reserved1[2];
+       unsigned short HelloInt;
+       unsigned short WiredHelloInt;
+       unsigned short TcInt;
+       unsigned short HelloHold;
+       unsigned short TcHold;
+       unsigned char Ipv6;
+       unsigned char Reserved2;
+       IpcIpAddr MainAddr;
+};
+
+#pragma pack (pop, BeforeIpcMessages)
+
+#endif
index 21c0f03..6bb0a0a 100644 (file)
-#\r
-# Default configuration for the GUI\r
-#\r
-# $Id: LQ-Default.olsr,v 1.1 2005/03/31 18:20:02 tlopatic Exp $\r
-#\r
-\r
-#\r
-# By default don't print anything to save CPU cycles\r
-#\r
-\r
-DebugLevel             0\r
-\r
-#\r
-# Enable the link quality extensions?\r
-#\r
-# 0 - no\r
-# 1 - yes, use link quality for MPR selection\r
-# 2 - yes, use link quality for MPR selection and routing\r
-#\r
-\r
-LinkQualityLevel       2\r
-\r
-#\r
-# Windows size for packet loss calculation\r
-#\r
-\r
-LinkQualityWinSize     10\r
-\r
-#\r
-# Do not use hysteresis\r
-#\r
-\r
-UseHysteresis          no\r
-\r
-#\r
-# If using hysteresis, use "smooth" parameters\r
-#\r
-\r
-HystScaling            0.1\r
-HystThrHigh            0.8\r
-HystThrLow             0.3\r
-\r
-#\r
-# The pollrate used by the scheduler\r
-#\r
-\r
-Pollrate               0.1\r
-\r
-#\r
-# Which neighbours should be advertised via TC messages?\r
-#\r
-# 0 - only advertise our MPR selectors\r
-# 1 - advertise our MPR selectors and our MPRs\r
-# 2 - advertise all neighbors\r
-#\r
-\r
-TcRedundancy           2\r
-\r
-#\r
-# Specifies by how many MPRs each two-hop neighbour should be covered\r
-#\r
-\r
-MprCoverage            3\r
-\r
-#\r
-# Load the HTTP info plugin\r
-#\r
-\r
-LoadPlugin             "olsrd_httpinfo.dll"\r
-{\r
-       PlParam "Net"   "0.0.0.0 0.0.0.0"\r
-}\r
-\r
-#\r
-# This default gateway HNA will only be considered by the GUI if the\r
-# computer actually has a default route.\r
-#\r
-\r
-Hna4\r
-{\r
-       0.0.0.0 0.0.0.0\r
-}\r
-\r
-#\r
-# Pseudo interface used by the GUI. If we do not select any interface\r
-# in the GUI, we still have to store the per-interface settings of the\r
-# GUI somewhere. We then simply create a pseudo interfaced named GUI"\r
-# for storing this information. When parsing the configuration file,\r
-# the settings will be read and will be used to populate the GUI, but\r
-# after that the "GUI" interface will be discarded.\r
-#\r
-\r
-Interface "GUI"\r
-{\r
-       #\r
-       # HELLO interval and validity time in seconds (float)\r
-       #\r
-\r
-       HelloInterval           2.0\r
-       HelloValidityTime       20.0\r
-\r
-       #\r
-       # TC interval and validity time in seconds (float)\r
-       #\r
-\r
-       TcInterval              5.0\r
-       TcValidityTime          30.0\r
-\r
-       #\r
-       # MID interval and validity time in seconds (float)\r
-       #\r
-\r
-       MidInterval             5.0\r
-       MidValidityTime         30.0\r
-\r
-       #\r
-       # HNA interval and validity time in seconds (float)\r
-       #\r
-\r
-       HnaInterval             5.0\r
-       HnaValidityTime         30.0\r
-}\r
+#
+# Default configuration for the GUI
+#
+# $Id: LQ-Default.olsr,v 1.2 2007/03/27 03:01:06 tlopatic Exp $
+#
+
+#
+# By default don't print anything to save CPU cycles
+#
+
+DebugLevel             0
+
+#
+# Enable the link quality extensions?
+#
+# 0 - no
+# 1 - yes, use link quality for MPR selection
+# 2 - yes, use link quality for MPR selection and routing
+#
+
+LinkQualityLevel       2
+
+#
+# Enable the fish eye algorithm
+#
+# 0 - no
+# 1 - yes
+#
+
+LinkQualityFishEye     1
+
+#
+# Windows size for packet loss calculation
+#
+
+LinkQualityWinSize     10
+
+#
+# Do not use hysteresis
+#
+
+UseHysteresis          no
+
+#
+# If using hysteresis, use "smooth" parameters
+#
+
+HystScaling            0.1
+HystThrHigh            0.8
+HystThrLow             0.3
+
+#
+# The pollrate used by the scheduler
+#
+
+Pollrate               0.1
+
+#
+# Which neighbours should be advertised via TC messages?
+#
+# 0 - only advertise our MPR selectors
+# 1 - advertise our MPR selectors and our MPRs
+# 2 - advertise all neighbors
+#
+
+TcRedundancy           2
+
+#
+# Specifies by how many MPRs each two-hop neighbour should be covered
+#
+
+MprCoverage            3
+
+#
+# Load the HTTP info plugin
+#
+
+LoadPlugin             "olsrd_httpinfo.dll"
+{
+       PlParam "Net"   "0.0.0.0 0.0.0.0"
+}
+
+#
+# This default gateway HNA will only be considered by the GUI if the
+# computer actually has a default route.
+#
+
+Hna4
+{
+       0.0.0.0 0.0.0.0
+}
+
+#
+# Pseudo interface used by the GUI. If we do not select any interface
+# in the GUI, we still have to store the per-interface settings of the
+# GUI somewhere. We then simply create a pseudo interfaced named GUI"
+# for storing this information. When parsing the configuration file,
+# the settings will be read and will be used to populate the GUI, but
+# after that the "GUI" interface will be discarded.
+#
+
+Interface "GUI"
+{
+       #
+       # HELLO interval and validity time in seconds (float)
+       #
+
+       HelloInterval           2.0
+       HelloValidityTime       20.0
+
+       #
+       # TC interval and validity time in seconds (float)
+       #
+
+       TcInterval              5.0
+       TcValidityTime          30.0
+
+       #
+       # MID interval and validity time in seconds (float)
+       #
+
+       MidInterval             5.0
+       MidValidityTime         30.0
+
+       #
+       # HNA interval and validity time in seconds (float)
+       #
+
+       HnaInterval             5.0
+       HnaValidityTime         30.0
+}
diff --git a/gui/win32/Main/Main.vcproj b/gui/win32/Main/Main.vcproj
new file mode 100644 (file)
index 0000000..91d39ea
--- /dev/null
@@ -0,0 +1,382 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="8.00"
+       Name="Main"
+       ProjectGUID="{01BB6810-46BB-4BE5-BCE3-96FF48F5DF1D}"
+       RootNamespace="Main"
+       Keyword="MFCProj"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="1"
+                       UseOfMFC="1"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               PreprocessorDefinitions="_DEBUG"
+                               MkTypLibCompatible="false"
+                               ValidateParameters="false"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="..\..\..\src;..\..\..\src\win32"
+                               PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="1"
+                               UsePrecompiledHeader="2"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="true"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="_DEBUG"
+                               Culture="1033"
+                               AdditionalIncludeDirectories="$(IntDir)"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="iphlpapi.lib"
+                               LinkIncremental="2"
+                               AdditionalLibraryDirectories=""
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="1"
+                       UseOfMFC="1"
+                       CharacterSet="2"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               PreprocessorDefinitions="NDEBUG"
+                               MkTypLibCompatible="false"
+                               ValidateParameters="false"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalIncludeDirectories="..\..\..\src;..\..\..\src\win32"
+                               PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG"
+                               MinimalRebuild="false"
+                               RuntimeLibrary="0"
+                               UsePrecompiledHeader="2"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="true"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="NDEBUG"
+                               Culture="1033"
+                               AdditionalIncludeDirectories="$(IntDir)"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="iphlpapi.lib"
+                               LinkIncremental="1"
+                               AdditionalLibraryDirectories=""
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+                       >
+                       <File
+                               RelativePath=".\Frontend.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\FrontendDlg.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\HnaEntry.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MidEntry.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MprEntry.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MyDialog1.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MyDialog2.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MyDialog3.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MyDialog4.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MyEdit.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MyTabCtrl.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\NodeEntry.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\StdAfx.cpp"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               UsePrecompiledHeader="1"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               UsePrecompiledHeader="1"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath=".\TrayIcon.cpp"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+                       >
+                       <File
+                               RelativePath=".\Frontend.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\FrontendDlg.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\HnaEntry.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\Ipc.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MidEntry.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MprEntry.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MyDialog1.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MyDialog2.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MyDialog3.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MyDialog4.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MyEdit.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MyTabCtrl.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\NodeEntry.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\resource.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\StdAfx.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\TrayIcon.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+                       >
+                       <File
+                               RelativePath=".\res\Frontend.ico"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\Frontend.rc"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\res\Tray1.ico"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\res\Tray2.ico"
+                               >
+                       </File>
+               </Filter>
+               <File
+                       RelativePath=".\LQ-Default.olsr"
+                       >
+               </File>
+               <File
+                       RelativePath=".\olsrd_cfgparser.lib"
+                       >
+               </File>
+               <File
+                       RelativePath=".\RFC-Default.olsr"
+                       >
+               </File>
+       </Files>
+       <Globals>
+               <Global
+                       Name="RESOURCE_FILE"
+                       Value="Frontend.rc"
+               />
+       </Globals>
+</VisualStudioProject>
index 2b7cde9..f339f20 100644 (file)
@@ -1,56 +1,56 @@
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: MidEntry.cpp,v 1.3 2004/11/21 01:21:10 tlopatic Exp $\r
- */\r
-\r
-#include "stdafx.h"\r
-#include "MidEntry.h"\r
-\r
-class MidEntry &MidEntry::operator=(class MidEntry &Src)\r
-{\r
-       Addr = Src.Addr;\r
-       Timeout = Src.Timeout;\r
-\r
-       return *this;\r
-}\r
-\r
-BOOL MidEntry::operator==(const class MidEntry &Comp) const\r
-{\r
-       return Addr == Comp.Addr;\r
-}\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: MidEntry.cpp,v 1.4 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#include "stdafx.h"
+#include "MidEntry.h"
+
+class MidEntry &MidEntry::operator=(class MidEntry &Src)
+{
+       Addr = Src.Addr;
+       Timeout = Src.Timeout;
+
+       return *this;
+}
+
+BOOL MidEntry::operator==(const class MidEntry &Comp) const
+{
+       return Addr == Comp.Addr;
+}
index 2dbc31e..4d9c656 100644 (file)
@@ -1,55 +1,55 @@
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: MidEntry.h,v 1.3 2004/11/21 01:21:10 tlopatic Exp $\r
- */\r
-\r
-#if !defined TL_MIDENTRY_H\r
-#define TL_MIDENTRY_H\r
-\r
-class MidEntry\r
-{\r
-public:\r
-       unsigned int Addr;\r
-       unsigned __int64 Timeout;\r
-\r
-       class MidEntry &MidEntry::operator=(class MidEntry &);\r
-       BOOL MidEntry::operator==(const class MidEntry &) const;\r
-};\r
-\r
-#endif\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: MidEntry.h,v 1.4 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#if !defined TL_MIDENTRY_H
+#define TL_MIDENTRY_H
+
+class MidEntry
+{
+public:
+       unsigned int Addr;
+       unsigned __int64 Timeout;
+
+       class MidEntry &MidEntry::operator=(class MidEntry &);
+       BOOL MidEntry::operator==(const class MidEntry &) const;
+};
+
+#endif
index a6078a2..6f52058 100644 (file)
@@ -1,56 +1,56 @@
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: MprEntry.cpp,v 1.3 2004/11/21 01:21:10 tlopatic Exp $\r
- */\r
-\r
-#include "stdafx.h"\r
-#include "MprEntry.h"\r
-\r
-class MprEntry &MprEntry::operator=(class MprEntry &Src)\r
-{\r
-       Addr = Src.Addr;\r
-       Timeout = Src.Timeout;\r
-\r
-       return *this;\r
-}\r
-\r
-BOOL MprEntry::operator==(const class MprEntry &Comp) const\r
-{\r
-       return Addr == Comp.Addr;\r
-}\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: MprEntry.cpp,v 1.4 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#include "stdafx.h"
+#include "MprEntry.h"
+
+class MprEntry &MprEntry::operator=(class MprEntry &Src)
+{
+       Addr = Src.Addr;
+       Timeout = Src.Timeout;
+
+       return *this;
+}
+
+BOOL MprEntry::operator==(const class MprEntry &Comp) const
+{
+       return Addr == Comp.Addr;
+}
index 4a1b6c6..5edac45 100644 (file)
@@ -1,55 +1,55 @@
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: MprEntry.h,v 1.3 2004/11/21 01:21:10 tlopatic Exp $\r
- */\r
-\r
-#if !defined TL_MPRENTRY_H\r
-#define TL_MPRENTRY_H\r
-\r
-class MprEntry\r
-{\r
-public:\r
-       unsigned int Addr;\r
-       unsigned __int64 Timeout;\r
-\r
-       class MprEntry &MprEntry::operator=(class MprEntry &);\r
-       BOOL MprEntry::operator==(const class MprEntry &) const;\r
-};\r
-\r
-#endif\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: MprEntry.h,v 1.4 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#if !defined TL_MPRENTRY_H
+#define TL_MPRENTRY_H
+
+class MprEntry
+{
+public:
+       unsigned int Addr;
+       unsigned __int64 Timeout;
+
+       class MprEntry &MprEntry::operator=(class MprEntry &);
+       BOOL MprEntry::operator==(const class MprEntry &) const;
+};
+
+#endif
index a22c27a..5d0661c 100644 (file)
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: MyDialog1.cpp,v 1.6 2004/11/24 16:46:21 tlopatic Exp $\r
- */\r
-\r
-#include "stdafx.h"\r
-#include "Frontend.h"\r
-#include "MyDialog1.h"\r
-\r
-#ifdef _DEBUG\r
-#define new DEBUG_NEW\r
-#undef THIS_FILE\r
-static char THIS_FILE[] = __FILE__;\r
-#endif\r
-\r
-MyDialog1::MyDialog1(CWnd* pParent)\r
-       : CDialog(MyDialog1::IDD, pParent)\r
-{\r
-       NumLines = 0;\r
-\r
-       //{{AFX_DATA_INIT(MyDialog1)\r
-       //}}AFX_DATA_INIT\r
-}\r
-\r
-BOOL MyDialog1::Create(CWnd *Parent)\r
-{\r
-       return CDialog::Create(MyDialog1::IDD, Parent);\r
-}\r
-\r
-void MyDialog1::DoDataExchange(CDataExchange* pDX)\r
-{\r
-       CDialog::DoDataExchange(pDX);\r
-       //{{AFX_DATA_MAP(MyDialog1)\r
-       DDX_Control(pDX, IDC_BUTTON4, m_SaveButton);\r
-       DDX_Control(pDX, IDC_BUTTON3, m_FreezeButton);\r
-       DDX_Control(pDX, IDC_BUTTON2, m_ContinueButton);\r
-       DDX_Control(pDX, IDC_BUTTON1, m_ClearButton);\r
-       DDX_Control(pDX, IDC_EDIT1, m_OutputWindow);\r
-       //}}AFX_DATA_MAP\r
-}\r
-\r
-\r
-BEGIN_MESSAGE_MAP(MyDialog1, CDialog)\r
-       //{{AFX_MSG_MAP(MyDialog1)\r
-       ON_BN_CLICKED(IDC_BUTTON1, OnClearButton)\r
-       ON_BN_CLICKED(IDC_BUTTON2, OnContinueButton)\r
-       ON_BN_CLICKED(IDC_BUTTON3, OnFreezeButton)\r
-       ON_WM_CTLCOLOR()\r
-       ON_BN_CLICKED(IDOK, OnOK)\r
-       ON_BN_CLICKED(IDCANCEL, OnCancel)\r
-       ON_BN_CLICKED(IDC_BUTTON4, OnSaveButton)\r
-       //}}AFX_MSG_MAP\r
-END_MESSAGE_MAP()\r
-\r
-void MyDialog1::OnOK()\r
-{\r
-}\r
-\r
-void MyDialog1::OnCancel()\r
-{\r
-}\r
-\r
-void MyDialog1::AddOutputLine(CString Line)\r
-{\r
-       int Index;\r
-\r
-       CritSect.Lock();\r
-\r
-       Output += Line + "\r\n";\r
-\r
-       if (NumLines == 1000)\r
-       {\r
-               Index = Output.Find("\r\n");\r
-               Output.Delete(0, Index + 2);\r
-       }\r
-\r
-       else\r
-               NumLines++;\r
-\r
-       CritSect.Unlock();\r
-\r
-       if (Frozen == 0)\r
-       {\r
-               m_OutputWindow.SetWindowText(Output);\r
-               m_OutputWindow.SetSel(Output.GetLength(), Output.GetLength());\r
-       }\r
-}\r
-\r
-void MyDialog1::SetFrozen(int NewFrozen)\r
-{\r
-       Frozen = NewFrozen;\r
-}\r
-\r
-BOOL MyDialog1::OnInitDialog() \r
-{\r
-       CDialog::OnInitDialog();\r
-       \r
-       CClientDC DevCont(&m_OutputWindow);\r
-\r
-       EditFont.CreatePointFont(90, "Courier New", NULL);\r
-       m_OutputWindow.SetFont(&EditFont);\r
-\r
-       m_FreezeButton.EnableWindow(FALSE);\r
-       m_ContinueButton.EnableWindow(FALSE);\r
-\r
-       Frozen = 0;\r
-\r
-       WhiteBrush.CreateSolidBrush(RGB(255, 255, 255));\r
-\r
-       return TRUE;\r
-}\r
-\r
-void MyDialog1::OnClearButton() \r
-{\r
-       CritSect.Lock();\r
-       Output.Empty();\r
-       NumLines = 0;\r
-       CritSect.Unlock();\r
-\r
-       m_OutputWindow.SetWindowText(Output);\r
-       m_OutputWindow.SetSel(0, 0);\r
-}\r
-\r
-void MyDialog1::OnContinueButton()\r
-{\r
-       CString Copy;\r
-       int Len;\r
-\r
-       m_FreezeButton.EnableWindow(TRUE);\r
-       m_ContinueButton.EnableWindow(FALSE);\r
-\r
-       Frozen = 0;\r
-\r
-       CritSect.Lock();\r
-       Copy = Output;\r
-       Len = Output.GetLength();\r
-       CritSect.Unlock();\r
-\r
-       m_OutputWindow.SetWindowText(Copy);\r
-       m_OutputWindow.SetSel(Len, Len);\r
-}\r
-\r
-void MyDialog1::OnFreezeButton() \r
-{\r
-       m_FreezeButton.EnableWindow(FALSE);\r
-       m_ContinueButton.EnableWindow(TRUE);\r
-\r
-       Frozen = 1;\r
-}\r
-\r
-void MyDialog1::HandleStart(void)\r
-{\r
-       CString Copy;\r
-       int Len;\r
-\r
-       m_FreezeButton.EnableWindow(TRUE);\r
-       m_ContinueButton.EnableWindow(FALSE);\r
-\r
-       Frozen = 0;\r
-\r
-       CritSect.Lock();\r
-       Copy = Output;\r
-       Len = Output.GetLength();\r
-       CritSect.Unlock();\r
-\r
-       m_OutputWindow.SetWindowText(Copy);\r
-       m_OutputWindow.SetSel(Len, Len);\r
-}\r
-\r
-void MyDialog1::HandleStop(void)\r
-{\r
-       CString Copy;\r
-       int Len;\r
-\r
-       m_FreezeButton.EnableWindow(FALSE);\r
-       m_ContinueButton.EnableWindow(FALSE);\r
-\r
-       Frozen = 0;\r
-\r
-       CritSect.Lock();\r
-       Copy = Output;\r
-       Len = Output.GetLength();\r
-       CritSect.Unlock();\r
-\r
-       m_OutputWindow.SetWindowText(Copy);\r
-       m_OutputWindow.SetSel(Len, Len);\r
-}\r
-\r
-HBRUSH MyDialog1::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) \r
-{\r
-       HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);\r
-\r
-       if (pWnd == &m_OutputWindow)\r
-       {\r
-               pDC->SetBkColor(RGB(255, 255, 255));\r
-               hbr = WhiteBrush;\r
-       }\r
-       \r
-       return hbr;\r
-}\r
-\r
-void MyDialog1::OnSaveButton()\r
-{\r
-       CString Copy;\r
-       int Len;\r
-       CFileDialog FileDialog(FALSE);\r
-       CString FileName = "OLSR log.txt";\r
-       CString PathName;\r
-       CFile File;\r
-\r
-       CritSect.Lock();\r
-       Copy = Output;\r
-       Len = Output.GetLength();\r
-       CritSect.Unlock();\r
-\r
-       FileDialog.m_ofn.lpstrFilter = "Text file (*.txt)\0*.txt\0";\r
-       FileDialog.m_ofn.nFilterIndex = 1;\r
-\r
-       FileDialog.m_ofn.lpstrFile = FileName.GetBuffer(500);\r
-       FileDialog.m_ofn.nMaxFile = 500;\r
-\r
-       if (FileDialog.DoModal() == IDOK)\r
-       {\r
-               PathName = FileDialog.GetPathName();\r
-\r
-               if (File.Open(PathName, CFile::modeCreate | CFile::modeWrite |\r
-                       CFile::shareExclusive) == 0)\r
-                       AfxMessageBox("Cannot open logfile '" + PathName + "'.");\r
-\r
-               else\r
-               {\r
-                       File.Write((const char *)Copy, Len);\r
-                       File.Close();\r
-               }\r
-       }\r
-\r
-       FileName.ReleaseBuffer();\r
-}\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: MyDialog1.cpp,v 1.7 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#include "stdafx.h"
+#include "Frontend.h"
+#include "MyDialog1.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+MyDialog1::MyDialog1(CWnd* pParent)
+       : CDialog(MyDialog1::IDD, pParent)
+{
+       NumLines = 0;
+
+       //{{AFX_DATA_INIT(MyDialog1)
+       //}}AFX_DATA_INIT
+}
+
+BOOL MyDialog1::Create(CWnd *Parent)
+{
+       return CDialog::Create(MyDialog1::IDD, Parent);
+}
+
+void MyDialog1::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(MyDialog1)
+       DDX_Control(pDX, IDC_BUTTON4, m_SaveButton);
+       DDX_Control(pDX, IDC_BUTTON3, m_FreezeButton);
+       DDX_Control(pDX, IDC_BUTTON2, m_ContinueButton);
+       DDX_Control(pDX, IDC_BUTTON1, m_ClearButton);
+       DDX_Control(pDX, IDC_EDIT1, m_OutputWindow);
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(MyDialog1, CDialog)
+       //{{AFX_MSG_MAP(MyDialog1)
+       ON_BN_CLICKED(IDC_BUTTON1, OnClearButton)
+       ON_BN_CLICKED(IDC_BUTTON2, OnContinueButton)
+       ON_BN_CLICKED(IDC_BUTTON3, OnFreezeButton)
+       ON_WM_CTLCOLOR()
+       ON_BN_CLICKED(IDOK, OnOK)
+       ON_BN_CLICKED(IDCANCEL, OnCancel)
+       ON_BN_CLICKED(IDC_BUTTON4, OnSaveButton)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+void MyDialog1::OnOK()
+{
+}
+
+void MyDialog1::OnCancel()
+{
+}
+
+void MyDialog1::AddOutputLine(CString Line)
+{
+       int Index;
+
+       CritSect.Lock();
+
+       Output += Line + "\r\n";
+
+       if (NumLines == 1000)
+       {
+               Index = Output.Find("\r\n");
+               Output.Delete(0, Index + 2);
+       }
+
+       else
+               NumLines++;
+
+       CritSect.Unlock();
+
+       if (Frozen == 0)
+       {
+               m_OutputWindow.SetWindowText(Output);
+               m_OutputWindow.SetSel(Output.GetLength(), Output.GetLength());
+       }
+}
+
+void MyDialog1::SetFrozen(int NewFrozen)
+{
+       Frozen = NewFrozen;
+}
+
+BOOL MyDialog1::OnInitDialog() 
+{
+       CDialog::OnInitDialog();
+       
+       CClientDC DevCont(&m_OutputWindow);
+
+       EditFont.CreatePointFont(90, "Courier New", NULL);
+       m_OutputWindow.SetFont(&EditFont);
+
+       m_FreezeButton.EnableWindow(FALSE);
+       m_ContinueButton.EnableWindow(FALSE);
+
+       Frozen = 0;
+
+       WhiteBrush.CreateSolidBrush(RGB(255, 255, 255));
+
+       return TRUE;
+}
+
+void MyDialog1::OnClearButton() 
+{
+       CritSect.Lock();
+       Output.Empty();
+       NumLines = 0;
+       CritSect.Unlock();
+
+       m_OutputWindow.SetWindowText(Output);
+       m_OutputWindow.SetSel(0, 0);
+}
+
+void MyDialog1::OnContinueButton()
+{
+       CString Copy;
+       int Len;
+
+       m_FreezeButton.EnableWindow(TRUE);
+       m_ContinueButton.EnableWindow(FALSE);
+
+       Frozen = 0;
+
+       CritSect.Lock();
+       Copy = Output;
+       Len = Output.GetLength();
+       CritSect.Unlock();
+
+       m_OutputWindow.SetWindowText(Copy);
+       m_OutputWindow.SetSel(Len, Len);
+}
+
+void MyDialog1::OnFreezeButton() 
+{
+       m_FreezeButton.EnableWindow(FALSE);
+       m_ContinueButton.EnableWindow(TRUE);
+
+       Frozen = 1;
+}
+
+void MyDialog1::HandleStart(void)
+{
+       CString Copy;
+       int Len;
+
+       m_FreezeButton.EnableWindow(TRUE);
+       m_ContinueButton.EnableWindow(FALSE);
+
+       Frozen = 0;
+
+       CritSect.Lock();
+       Copy = Output;
+       Len = Output.GetLength();
+       CritSect.Unlock();
+
+       m_OutputWindow.SetWindowText(Copy);
+       m_OutputWindow.SetSel(Len, Len);
+}
+
+void MyDialog1::HandleStop(void)
+{
+       CString Copy;
+       int Len;
+
+       m_FreezeButton.EnableWindow(FALSE);
+       m_ContinueButton.EnableWindow(FALSE);
+
+       Frozen = 0;
+
+       CritSect.Lock();
+       Copy = Output;
+       Len = Output.GetLength();
+       CritSect.Unlock();
+
+       m_OutputWindow.SetWindowText(Copy);
+       m_OutputWindow.SetSel(Len, Len);
+}
+
+HBRUSH MyDialog1::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
+{
+       HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
+
+       if (pWnd == &m_OutputWindow)
+       {
+               pDC->SetBkColor(RGB(255, 255, 255));
+               hbr = WhiteBrush;
+       }
+       
+       return hbr;
+}
+
+void MyDialog1::OnSaveButton()
+{
+       CString Copy;
+       int Len;
+       CFileDialog FileDialog(FALSE);
+       CString FileName = "OLSR log.txt";
+       CString PathName;
+       CFile File;
+
+       CritSect.Lock();
+       Copy = Output;
+       Len = Output.GetLength();
+       CritSect.Unlock();
+
+       FileDialog.m_ofn.lpstrFilter = "Text file (*.txt)\0*.txt\0";
+       FileDialog.m_ofn.nFilterIndex = 1;
+
+       FileDialog.m_ofn.lpstrFile = FileName.GetBuffer(500);
+       FileDialog.m_ofn.nMaxFile = 500;
+
+       if (FileDialog.DoModal() == IDOK)
+       {
+               PathName = FileDialog.GetPathName();
+
+               if (File.Open(PathName, CFile::modeCreate | CFile::modeWrite |
+                       CFile::shareExclusive) == 0)
+                       AfxMessageBox("Cannot open logfile '" + PathName + "'.");
+
+               else
+               {
+                       File.Write((const char *)Copy, Len);
+                       File.Close();
+               }
+       }
+
+       FileName.ReleaseBuffer();
+}
index 7b2a1c3..37da713 100644 (file)
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: MyDialog1.h,v 1.5 2004/11/21 01:21:10 tlopatic Exp $\r
- */\r
-\r
-#if !defined(AFX_MYDIALOG1_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_)\r
-#define AFX_MYDIALOG1_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_\r
-\r
-#if _MSC_VER > 1000\r
-#pragma once\r
-#endif\r
-\r
-class MyDialog1 : public CDialog\r
-{\r
-public:\r
-       MyDialog1(CWnd* pParent = NULL);\r
-\r
-       BOOL Create(CWnd *Parent);\r
-\r
-       void AddOutputLine(CString);\r
-       void SetFrozen(int);\r
-       void HandleStart(void);\r
-       void HandleStop(void);\r
-\r
-       //{{AFX_DATA(MyDialog1)\r
-       enum { IDD = IDD_DIALOG1 };\r
-       CButton m_SaveButton;\r
-       CButton m_FreezeButton;\r
-       CButton m_ContinueButton;\r
-       CButton m_ClearButton;\r
-       CEdit   m_OutputWindow;\r
-       //}}AFX_DATA\r
-\r
-\r
-       //{{AFX_VIRTUAL(MyDialog1)\r
-       protected:\r
-       virtual void DoDataExchange(CDataExchange* pDX);\r
-       //}}AFX_VIRTUAL\r
-\r
-protected:\r
-\r
-       //{{AFX_MSG(MyDialog1)\r
-       afx_msg void OnOK();\r
-       afx_msg void OnCancel();\r
-       virtual BOOL OnInitDialog();\r
-       afx_msg void OnClearButton();\r
-       afx_msg void OnContinueButton();\r
-       afx_msg void OnFreezeButton();\r
-       afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);\r
-       afx_msg void OnSaveButton();\r
-       //}}AFX_MSG\r
-       DECLARE_MESSAGE_MAP()\r
-\r
-       CCriticalSection CritSect;\r
-       CString Output;\r
-       int NumLines;\r
-\r
-       int Frozen;\r
-\r
-       CFont EditFont;\r
-       CBrush WhiteBrush;\r
-};\r
-\r
-//{{AFX_INSERT_LOCATION}}\r
-\r
-#endif\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: MyDialog1.h,v 1.6 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#if !defined(AFX_MYDIALOG1_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_)
+#define AFX_MYDIALOG1_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+class MyDialog1 : public CDialog
+{
+public:
+       MyDialog1(CWnd* pParent = NULL);
+
+       BOOL Create(CWnd *Parent);
+
+       void AddOutputLine(CString);
+       void SetFrozen(int);
+       void HandleStart(void);
+       void HandleStop(void);
+
+       //{{AFX_DATA(MyDialog1)
+       enum { IDD = IDD_DIALOG1 };
+       CButton m_SaveButton;
+       CButton m_FreezeButton;
+       CButton m_ContinueButton;
+       CButton m_ClearButton;
+       CEdit   m_OutputWindow;
+       //}}AFX_DATA
+
+
+       //{{AFX_VIRTUAL(MyDialog1)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);
+       //}}AFX_VIRTUAL
+
+protected:
+
+       //{{AFX_MSG(MyDialog1)
+       afx_msg void OnOK();
+       afx_msg void OnCancel();
+       virtual BOOL OnInitDialog();
+       afx_msg void OnClearButton();
+       afx_msg void OnContinueButton();
+       afx_msg void OnFreezeButton();
+       afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+       afx_msg void OnSaveButton();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+
+       CCriticalSection CritSect;
+       CString Output;
+       int NumLines;
+
+       int Frozen;
+
+       CFont EditFont;
+       CBrush WhiteBrush;
+};
+
+//{{AFX_INSERT_LOCATION}}
+
+#endif
index e13c3c5..946ce62 100644 (file)
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: MyDialog2.cpp,v 1.8 2005/03/02 00:13:23 tlopatic Exp $\r
- */\r
-\r
-#include "stdafx.h"\r
-#include "Frontend.h"\r
-#include "MyDialog2.h"\r
-\r
-#ifdef _DEBUG\r
-#define new DEBUG_NEW\r
-#undef THIS_FILE\r
-static char THIS_FILE[] = __FILE__;\r
-#endif\r
-\r
-#define MAXIF 100\r
-\r
-MyDialog2::MyDialog2(CWnd* pParent)\r
-       : CDialog(MyDialog2::IDD, pParent)\r
-{\r
-       Conf = NULL;\r
-\r
-       //{{AFX_DATA_INIT(MyDialog2)\r
-       //}}AFX_DATA_INIT\r
-}\r
-\r
-void MyDialog2::SetDebugLevel(int Level)\r
-{\r
-       char LevelText[2];\r
-\r
-       LevelText[0] = (char)(Level + '0');\r
-       LevelText[1] = 0;\r
-\r
-       DebugLevel = Level;\r
-       m_DebugLevel.SetPos(Level);\r
-       m_DebugLevelText.SetWindowText(LevelText);\r
-}\r
-\r
-BOOL MyDialog2::Create(CWnd *Parent)\r
-{\r
-       return CDialog::Create(MyDialog2::IDD, Parent);\r
-}\r
-\r
-void MyDialog2::DoDataExchange(CDataExchange* pDX)\r
-{\r
-       CDialog::DoDataExchange(pDX);\r
-       //{{AFX_DATA_MAP(MyDialog2)\r
-       DDX_Control(pDX, IDC_COMBO1, m_TcRed);\r
-       DDX_Control(pDX, IDC_EDIT15, m_MprCov);\r
-       DDX_Control(pDX, IDC_RADIO2, m_EtxRadio2);\r
-       DDX_Control(pDX, IDC_RADIO1, m_EtxRadio1);\r
-       DDX_Control(pDX, IDC_EDIT14, m_EtxWindowSize);\r
-       DDX_Control(pDX, IDC_CHECK4, m_EtxCheck);\r
-       DDX_Control(pDX, IDC_CHECK3, m_Ipv6Check);\r
-       DDX_Control(pDX, IDC_CHECK2, m_InternetCheck);\r
-       DDX_Control(pDX, IDC_CHECK1, m_HystCheck);\r
-       DDX_Control(pDX, IDC_EDIT13, m_HystThresholdHigh);\r
-       DDX_Control(pDX, IDC_EDIT12, m_HystThresholdLow);\r
-       DDX_Control(pDX, IDC_EDIT11, m_HystScaling);\r
-       DDX_Control(pDX, IDC_EDIT10, m_HnaHold);\r
-       DDX_Control(pDX, IDC_EDIT9, m_MidHold);\r
-       DDX_Control(pDX, IDC_EDIT7, m_PollInt);\r
-       DDX_Control(pDX, IDC_EDIT6, m_TcHold);\r
-       DDX_Control(pDX, IDC_EDIT5, m_TcInt);\r
-       DDX_Control(pDX, IDC_EDIT4, m_HnaInt);\r
-       DDX_Control(pDX, IDC_EDIT3, m_MidInt);\r
-       DDX_Control(pDX, IDC_EDIT2, m_HelloHold);\r
-       DDX_Control(pDX, IDC_EDIT1, m_HelloInt);\r
-       DDX_Control(pDX, IDC_LIST1, m_InterfaceList);\r
-       DDX_Control(pDX, IDC_TEXT1, m_DebugLevelText);\r
-       DDX_Control(pDX, IDC_SLIDER2, m_DebugLevel);\r
-       //}}AFX_DATA_MAP\r
-}\r
-\r
-BEGIN_MESSAGE_MAP(MyDialog2, CDialog)\r
-       //{{AFX_MSG_MAP(MyDialog2)\r
-       ON_WM_HSCROLL()\r
-       ON_BN_CLICKED(IDC_CHECK1, OnHystCheck)\r
-       ON_BN_CLICKED(IDC_BUTTON4, OnOpenButton)\r
-       ON_BN_CLICKED(IDC_BUTTON5, OnSaveButton)\r
-       ON_BN_CLICKED(IDC_BUTTON1, OnResetButton)\r
-       ON_BN_CLICKED(IDC_CHECK4, OnEtxCheck)\r
-       ON_BN_CLICKED(IDC_RADIO1, OnEtxRadio1)\r
-       ON_BN_CLICKED(IDC_RADIO2, OnEtxRadio2)\r
-       ON_BN_CLICKED(IDOK, OnOK)\r
-       ON_BN_CLICKED(IDCANCEL, OnCancel)\r
-       ON_EN_KILLFOCUS(IDC_EDIT14, OnKillfocusEtxWinSize)\r
-       //}}AFX_MSG_MAP\r
-END_MESSAGE_MAP()\r
-\r
-void MyDialog2::OnOK()\r
-{\r
-}\r
-\r
-void MyDialog2::OnCancel()\r
-{\r
-}\r
-\r
-void MyDialog2::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) \r
-{\r
-       if (pScrollBar == (CScrollBar *)&m_DebugLevel)\r
-               SetDebugLevel(m_DebugLevel.GetPos());\r
-       \r
-       CDialog::OnHScroll(nSBCode, nPos, pScrollBar);\r
-}\r
-\r
-void MyDialog2::Reset(void)\r
-{\r
-       char PathName[MAX_PATH + 50];\r
-       char *Walker;\r
-       int i;\r
-\r
-       ::GetModuleFileName(NULL, PathName, MAX_PATH);\r
-\r
-       for (Walker = PathName; *Walker != 0; Walker++);\r
-       \r
-       while (*Walker != '\\')\r
-               Walker--;\r
-\r
-       lstrcpy(Walker + 1, "Default.olsr");\r
-\r
-       if (OpenConfigFile(PathName) < 0)\r
-               return;\r
-\r
-       m_Ipv6Check.SetCheck(FALSE);\r
-\r
-       if (Conf->interfaces == NULL)\r
-       {\r
-               for (i = 0; i < Interfaces->GetSize(); i++)\r
-               {\r
-                       if ((*IsWlan)[i] == "-")\r
-                               m_InterfaceList.SetCheck(i, FALSE);\r
-\r
-                       else\r
-                               m_InterfaceList.SetCheck(i, TRUE);\r
-               }\r
-       }\r
-}\r
-\r
-BOOL MyDialog2::OnInitDialog() \r
-{\r
-       int i;\r
-\r
-       CDialog::OnInitDialog();\r
-       \r
-       m_DebugLevel.SetRange(0, 9, TRUE);\r
-\r
-       m_InterfaceList.SetExtendedStyle(m_InterfaceList.GetExtendedStyle() |\r
-                       LVS_EX_CHECKBOXES);\r
-\r
-       for (i = 0; i < Interfaces->GetSize(); i++)\r
-       {\r
-               m_InterfaceList.InsertItem(i,\r
-               (*Interfaces)[i] + " - " + (*Addresses)[i]);\r
-       }\r
-\r
-       MIB_IPFORWARDROW IpFwdRow;\r
-\r
-       if (::GetBestRoute(0, 0, &IpFwdRow) != NO_ERROR)\r
-               m_InternetCheck.EnableWindow(FALSE);\r
-\r
-       m_MprCov.LimitText(1);\r
-\r
-       Reset();\r
-\r
-       return TRUE;\r
-}\r
-\r
-void MyDialog2::OnHystCheck() \r
-{\r
-       BOOL EnaDis = m_HystCheck.GetCheck();\r
-\r
-       m_HystThresholdLow.EnableWindow(EnaDis);\r
-       m_HystThresholdHigh.EnableWindow(EnaDis);\r
-       m_HystScaling.EnableWindow(EnaDis);\r
-}\r
-\r
-void MyDialog2::OnEtxCheckWorker() \r
-{\r
-       BOOL EnaDis = m_EtxCheck.GetCheck();\r
-\r
-       m_EtxWindowSize.EnableWindow(EnaDis);\r
-       m_EtxRadio1.EnableWindow(EnaDis);\r
-       m_EtxRadio2.EnableWindow(EnaDis);\r
-}\r
-\r
-void MyDialog2::OnEtxCheck()\r
-{\r
-       OnEtxCheckWorker();\r
-\r
-       AfxMessageBox("WARNING - This parameter breaks compliance with the OLSR standard.\n\n"\r
-               "Make sure that either all nodes in your network use ETX or all nodes in your network don't use ETX.\n\n"\r
-               "DO NOT MIX NODES WITH DIFFERENT ETX SETTINGS!");\r
-}\r
-\r
-int MyDialog2::OpenConfigFile(CString PathName)\r
-{\r
-       struct hna4_entry *Hna4;\r
-       struct olsr_if *Int, *PrevInt;\r
-       struct olsr_msg_params *MsgPar;\r
-       int NumInt = m_InterfaceList.GetItemCount();\r
-       int i;\r
-       CString IntName;\r
-       CString Conv;\r
-\r
-       if (Conf != NULL)\r
-               olsrd_free_cnf(Conf);\r
-\r
-       Conf = olsrd_parse_cnf(PathName);\r
-\r
-       if (Conf == NULL)\r
-               return -1;\r
-\r
-       for (i = 0; i < NumInt; i++)\r
-               m_InterfaceList.SetCheck(i, FALSE);\r
-\r
-       for (Int = Conf->interfaces; Int != NULL; Int = Int->next)\r
-       {\r
-               IntName = Int->name;\r
-               IntName.MakeUpper();\r
-\r
-               for (i = 0; i < NumInt; i++)\r
-               {\r
-                       if (m_InterfaceList.GetItemText(i, 0).Mid(0, 4) == IntName)\r
-                               m_InterfaceList.SetCheck(i, TRUE);\r
-               }\r
-       }\r
-\r
-       Int = Conf->interfaces;\r
-\r
-       MsgPar = &Int->cnf->hello_params;\r
-\r
-       Conv.Format("%.2f", MsgPar->emission_interval);\r
-       m_HelloInt.SetWindowText(Conv);\r
-\r
-       Conv.Format("%.2f", MsgPar->validity_time);\r
-       m_HelloHold.SetWindowText(Conv);\r
-\r
-       MsgPar = &Int->cnf->tc_params;\r
-       \r
-       Conv.Format("%.2f", MsgPar->emission_interval);\r
-       m_TcInt.SetWindowText(Conv);\r
-\r
-       Conv.Format("%.2f", MsgPar->validity_time);\r
-       m_TcHold.SetWindowText(Conv);\r
-\r
-       MsgPar = &Int->cnf->mid_params;\r
-       \r
-       Conv.Format("%.2f", MsgPar->emission_interval);\r
-       m_MidInt.SetWindowText(Conv);\r
-\r
-       Conv.Format("%.2f", MsgPar->validity_time);\r
-       m_MidHold.SetWindowText(Conv);\r
-\r
-       MsgPar = &Int->cnf->hna_params;\r
-       \r
-       Conv.Format("%.2f", MsgPar->emission_interval);\r
-       m_HnaInt.SetWindowText(Conv);\r
-\r
-       Conv.Format("%.2f", MsgPar->validity_time);\r
-       m_HnaHold.SetWindowText(Conv);\r
-\r
-       SetDebugLevel(Conf->debug_level);\r
-\r
-       Conv.Format("%.2f", Conf->pollrate);\r
-       m_PollInt.SetWindowText(Conv);\r
-\r
-       Conv.Format("%d", Conf->mpr_coverage);\r
-       m_MprCov.SetWindowText(Conv);\r
-\r
-       m_TcRed.SetCurSel(Conf->tc_redundancy);\r
-\r
-       m_HystCheck.SetCheck(Conf->use_hysteresis);\r
-\r
-       Conv.Format("%.2f", Conf->hysteresis_param.scaling);\r
-       m_HystScaling.SetWindowText(Conv);\r
-\r
-       Conv.Format("%.2f", Conf->hysteresis_param.thr_high);\r
-       m_HystThresholdHigh.SetWindowText(Conv);\r
-\r
-       Conv.Format("%.2f", Conf->hysteresis_param.thr_low);\r
-       m_HystThresholdLow.SetWindowText(Conv);\r
-\r
-       OnHystCheck();\r
-\r
-       m_EtxCheck.SetCheck(Conf->lq_level > 0);\r
-\r
-       Conv.Format("%d", Conf->lq_wsize);\r
-       m_EtxWindowSize.SetWindowText(Conv);\r
-\r
-       m_EtxRadio1.SetCheck(Conf->lq_level == 1);\r
-       m_EtxRadio2.SetCheck(Conf->lq_level == 0 || Conf->lq_level == 2);\r
-\r
-       OnEtxCheckWorker();\r
-\r
-       m_InternetCheck.SetCheck(FALSE);\r
-\r
-       for (Hna4 = Conf->hna4_entries; Hna4 != NULL; Hna4 = Hna4->next)\r
-               if (Hna4->net.v4 == 0 && Hna4->netmask.v4 == 0 &&\r
-                       m_InternetCheck.IsWindowEnabled())\r
-               m_InternetCheck.SetCheck(TRUE);\r
-\r
-       PrevInt = NULL;\r
-\r
-       for (Int = Conf->interfaces; Int != NULL; Int = Int->next)\r
-       {\r
-               IntName = Int->name;\r
-\r
-               if (IntName.CompareNoCase("GUI") == 0)\r
-                       break;\r
-\r
-               PrevInt = Int;\r
-       }\r
-\r
-       if (Int != NULL)\r
-       {\r
-               if (PrevInt == NULL)\r
-                       Conf->interfaces = Int->next;\r
-\r
-               else\r
-                       PrevInt->next = Int->next;\r
-\r
-               olsrd_cnf_free(Int);\r
-       }\r
-\r
-       return 0;\r
-}\r
-\r
-static struct olsr_if *AddInterface(struct olsrd_config **Conf, CString Name)\r
-{\r
-       struct olsr_if *Int;\r
-\r
-       Int = (struct olsr_if *)olsrd_cnf_malloc(sizeof (struct olsr_if));\r
-\r
-       if (Int == NULL)\r
-       {\r
-               AfxMessageBox("Cannot allocate memory.");\r
-               return NULL;\r
-       }\r
-\r
-       Int->name = (char *)olsrd_cnf_malloc(Name.GetLength() + 1);\r
-\r
-       if (Int->name == NULL)\r
-       {\r
-               olsrd_cnf_free(Int);\r
-\r
-               AfxMessageBox("Cannot allocate memory.");\r
-               return NULL;\r
-       }\r
-\r
-       ::lstrcpy(Int->name, Name);\r
-\r
-       Int->config = NULL;\r
-       Int->index = 0;\r
-       Int->configured = OLSR_FALSE;\r
-       Int->interf = NULL;\r
-\r
-       Int->cnf = get_default_if_config();\r
-\r
-       Int->next = (*Conf)->interfaces;\r
-       (*Conf)->interfaces = Int;\r
-\r
-       return Int;\r
-}\r
-\r
-int MyDialog2::SaveConfigFile(CString PathName, int Real)\r
-{\r
-       struct olsr_if *Int, *PrevInt;\r
-       struct olsr_msg_params *MsgPar;\r
-       CString Conv;\r
-       struct hna4_entry *Hna4, *NewHna4, *PrevHna4;\r
-       int NumInt = m_InterfaceList.GetItemCount();\r
-       int i;\r
-       CString IntName, IntName2;\r
-       struct ipc_host *IpcHost;\r
-       unsigned int Local;\r
-\r
-       PrevInt = NULL;\r
-\r
-       // remove interfaces that we do not want\r
-       \r
-       for (Int = Conf->interfaces; Int != NULL; Int = Int->next)\r
-       {\r
-               IntName = Int->name;\r
-               IntName.MakeUpper();\r
-\r
-               for (i = 0; i < NumInt; i++)\r
-                       if (m_InterfaceList.GetItemText(i, 0).Mid(0, 4) == IntName)\r
-                               break;\r
-\r
-               if (i == NumInt || !m_InterfaceList.GetCheck(i))\r
-               {\r
-                       if (PrevInt != NULL)\r
-                               PrevInt->next = Int->next;\r
-\r
-                       else\r
-                               Conf->interfaces = Int->next;\r
-               }\r
-       }\r
-       \r
-       // add missing interfaces\r
-       \r
-       for (i = 0; i < NumInt; i++)\r
-       {\r
-               if (!m_InterfaceList.GetCheck(i))\r
-                       continue;\r
-\r
-               IntName2 = m_InterfaceList.GetItemText(i, 0).Mid(0, 4);\r
-\r
-               for (Int = Conf->interfaces; Int != NULL; Int = Int->next)\r
-               {\r
-                       IntName = Int->name;\r
-                       IntName.MakeUpper();\r
-\r
-                       if (IntName2 == IntName)\r
-                               break;\r
-               }\r
-\r
-               if (Int == NULL)\r
-                       AddInterface(&Conf, m_InterfaceList.GetItemText(i, 0).Mid(0, 4));\r
-       }\r
-\r
-       // add dummy interface, if there aren't any real interfaces\r
-\r
-       if (Conf->interfaces == NULL && Real != 0)\r
-               AddInterface(&Conf, "GUI");\r
-\r
-       // per-interface settings\r
-\r
-       for (Int = Conf->interfaces; Int != NULL; Int = Int->next)\r
-       {\r
-               MsgPar = &Int->cnf->hello_params;\r
-\r
-               m_HelloInt.GetWindowText(Conv);\r
-               MsgPar->emission_interval = (float)atof(Conv);\r
-\r
-               m_HelloHold.GetWindowText(Conv);\r
-               MsgPar->validity_time = (float)atof(Conv);\r
-\r
-               MsgPar = &Int->cnf->tc_params;\r
-\r
-               m_TcInt.GetWindowText(Conv);\r
-               MsgPar->emission_interval = (float)atof(Conv);\r
-\r
-               m_TcHold.GetWindowText(Conv);\r
-               MsgPar->validity_time = (float)atof(Conv);\r
-\r
-               MsgPar = &Int->cnf->mid_params;\r
-\r
-               m_MidInt.GetWindowText(Conv);\r
-               MsgPar->emission_interval = (float)atof(Conv);\r
-\r
-               m_MidHold.GetWindowText(Conv);\r
-               MsgPar->validity_time = (float)atof(Conv);\r
-\r
-               MsgPar = &Int->cnf->hna_params;\r
-\r
-               m_HnaInt.GetWindowText(Conv);\r
-               MsgPar->emission_interval = (float)atof(Conv);\r
-\r
-               m_HnaHold.GetWindowText(Conv);\r
-               MsgPar->validity_time = (float)atof(Conv);\r
-       }\r
-\r
-       // global settings\r
-\r
-       Conf->debug_level = DebugLevel;\r
-\r
-       m_PollInt.GetWindowText(Conv);\r
-       Conf->pollrate = (float)atof(Conv);\r
-\r
-       Conf->tc_redundancy = (unsigned char)m_TcRed.GetCurSel();\r
-\r
-       m_MprCov.GetWindowText(Conv);\r
-       Conf->mpr_coverage = (unsigned char)atoi(Conv);\r
-\r
-       Conf->use_hysteresis = m_HystCheck.GetCheck() ? OLSR_TRUE : OLSR_FALSE;\r
-\r
-       m_HystScaling.GetWindowText(Conv);\r
-       Conf->hysteresis_param.scaling = (float)atof(Conv);\r
-\r
-       m_HystThresholdHigh.GetWindowText(Conv);\r
-       Conf->hysteresis_param.thr_high = (float)atof(Conv);\r
-\r
-       m_HystThresholdLow.GetWindowText(Conv);\r
-       Conf->hysteresis_param.thr_low = (float)atof(Conv);\r
-\r
-       if (!m_EtxCheck.GetCheck())\r
-               Conf->lq_level = 0;\r
-\r
-       else if (m_EtxRadio1.GetCheck())\r
-               Conf->lq_level = 1;\r
-\r
-       else\r
-               Conf->lq_level = 2;\r
-\r
-       m_EtxWindowSize.GetWindowText(Conv);\r
-       Conf->lq_wsize = atoi(Conv);\r
-\r
-       PrevHna4 = NULL;\r
-\r
-       // check for a default gateway HNA4 entry\r
-\r
-       for (Hna4 = Conf->hna4_entries; Hna4 != NULL; Hna4 = Hna4->next)\r
-       {\r
-               if (Hna4->net.v4 == 0 && Hna4->netmask.v4 == 0)\r
-                       break;\r
-\r
-               PrevHna4 = Hna4;\r
-       }\r
-\r
-       // add default gateway HNA4 entry\r
-\r
-       if (m_InternetCheck.GetCheck() && Hna4 == NULL)\r
-       {\r
-               NewHna4 = (struct hna4_entry * )\r
-                       olsrd_cnf_malloc(sizeof (struct hna4_entry));\r
-\r
-               if (NewHna4 == NULL)\r
-               {\r
-                       AfxMessageBox("Cannot allocate memory.");\r
-                       return -1;\r
-               }\r
-\r
-               NewHna4->net.v4 = 0;\r
-               NewHna4->netmask.v4 = 0;\r
-\r
-               NewHna4->next = Conf->hna4_entries;\r
-               Conf->hna4_entries = NewHna4;\r
-       }\r
-\r
-       // remove default gateway HNA4 entry\r
-\r
-       if (!m_InternetCheck.GetCheck() && Hna4 != NULL)\r
-       {\r
-               if (PrevHna4 == NULL)\r
-                       Conf->hna4_entries = Hna4->next;\r
-\r
-               else\r
-                       PrevHna4->next = Hna4->next;\r
-\r
-               olsrd_cnf_free(Hna4);\r
-       }\r
-\r
-       Local = inet_addr("127.0.0.1");\r
-\r
-       for (IpcHost = Conf->ipc_hosts; IpcHost != NULL; IpcHost = IpcHost->next)\r
-               if (IpcHost->host.v4 == Local)\r
-                       break;\r
-\r
-       if (IpcHost == NULL && Real == 0)\r
-       {\r
-               IpcHost = (struct ipc_host *)\r
-                       olsrd_cnf_malloc(sizeof (struct ipc_host));\r
-\r
-               if (IpcHost == NULL)\r
-               {\r
-                       AfxMessageBox("Cannot allocate memory.");\r
-                       return -1;\r
-               }\r
-\r
-               IpcHost->host.v4 = Local;\r
-\r
-               IpcHost->next = Conf->ipc_hosts;\r
-               Conf->ipc_hosts = IpcHost;\r
-\r
-               Conf->ipc_connections++;\r
-               Conf->open_ipc = OLSR_TRUE;\r
-       }\r
-\r
-       // write configuration file\r
-\r
-       if (olsrd_write_cnf(Conf, PathName) < 0)\r
-               return -1;\r
-\r
-       return 0;\r
-}\r
-\r
-void MyDialog2::OnSaveButton()\r
-{\r
-       CFileDialog FileDialog(FALSE);\r
-       CString FileName = "Default.olsr";\r
-       CString PathName;\r
-\r
-       FileDialog.m_ofn.lpstrFilter = "Configuration file (*.olsr)\0*.olsr\0";\r
-       FileDialog.m_ofn.nFilterIndex = 1;\r
-\r
-       FileDialog.m_ofn.lpstrFile = FileName.GetBuffer(500);\r
-       FileDialog.m_ofn.nMaxFile = 500;\r
-\r
-       if (FileDialog.DoModal() == IDOK)\r
-       {\r
-               PathName = FileDialog.GetPathName();\r
-\r
-               if (SaveConfigFile(PathName, 1) < 0)\r
-                       AfxMessageBox("Cannot save configuration file '" + PathName + "'.");\r
-       }\r
-\r
-       FileName.ReleaseBuffer();\r
-}\r
-\r
-void MyDialog2::OnOpenButton()\r
-{\r
-       CFileDialog FileDialog(TRUE);\r
-       CString FileName = "Default.olsr";\r
-       CString PathName;\r
-\r
-       FileDialog.m_ofn.lpstrFilter = "Configuration file (*.olsr)\0*.olsr\0";\r
-       FileDialog.m_ofn.nFilterIndex = 1;\r
-\r
-       FileDialog.m_ofn.lpstrFile = FileName.GetBuffer(500);\r
-       FileDialog.m_ofn.nMaxFile = 500;\r
-\r
-       if (FileDialog.DoModal() == IDOK)\r
-       {\r
-               PathName = FileDialog.GetPathName();\r
-\r
-               if (OpenConfigFile(PathName) < 0)\r
-                       AfxMessageBox("Cannot open configuration file '" + PathName + "'.");\r
-       }\r
-\r
-       FileName.ReleaseBuffer();\r
-}\r
-\r
-void MyDialog2::OnResetButton() \r
-{\r
-       Reset();\r
-}\r
-\r
-void MyDialog2::OnEtxRadio1() \r
-{\r
-       m_EtxRadio2.SetCheck(FALSE);\r
-}\r
-\r
-void MyDialog2::OnEtxRadio2() \r
-{\r
-       m_EtxRadio1.SetCheck(FALSE);\r
-}\r
-\r
-void MyDialog2::OnKillfocusEtxWinSize() \r
-{\r
-       CString Conv;\r
-       int WinSize;\r
-\r
-       m_EtxWindowSize.GetWindowText(Conv);\r
-       WinSize = atoi(Conv);\r
-\r
-       if (WinSize < 3)\r
-               WinSize = 3;\r
-\r
-       else if (WinSize > 128)\r
-               WinSize = 128;\r
-\r
-       Conv.Format("%d", WinSize);\r
-       m_EtxWindowSize.SetWindowText(Conv);\r
-}\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: MyDialog2.cpp,v 1.9 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#include "stdafx.h"
+#include "Frontend.h"
+#include "MyDialog2.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+#define MAXIF 100
+
+MyDialog2::MyDialog2(CWnd* pParent)
+       : CDialog(MyDialog2::IDD, pParent)
+{
+       Conf = NULL;
+
+       //{{AFX_DATA_INIT(MyDialog2)
+       //}}AFX_DATA_INIT
+}
+
+void MyDialog2::SetDebugLevel(int Level)
+{
+       char LevelText[2];
+
+       LevelText[0] = (char)(Level + '0');
+       LevelText[1] = 0;
+
+       DebugLevel = Level;
+       m_DebugLevel.SetPos(Level);
+       m_DebugLevelText.SetWindowText(LevelText);
+}
+
+BOOL MyDialog2::Create(CWnd *Parent)
+{
+       return CDialog::Create(MyDialog2::IDD, Parent);
+}
+
+void MyDialog2::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(MyDialog2)
+       DDX_Control(pDX, IDC_COMBO1, m_TcRed);
+       DDX_Control(pDX, IDC_EDIT15, m_MprCov);
+       DDX_Control(pDX, IDC_RADIO2, m_EtxRadio2);
+       DDX_Control(pDX, IDC_RADIO1, m_EtxRadio1);
+       DDX_Control(pDX, IDC_EDIT14, m_EtxWindowSize);
+       DDX_Control(pDX, IDC_CHECK5, m_FishEyeCheck);
+       DDX_Control(pDX, IDC_CHECK4, m_EtxCheck);
+       DDX_Control(pDX, IDC_CHECK3, m_Ipv6Check);
+       DDX_Control(pDX, IDC_CHECK2, m_InternetCheck);
+       DDX_Control(pDX, IDC_CHECK1, m_HystCheck);
+       DDX_Control(pDX, IDC_EDIT13, m_HystThresholdHigh);
+       DDX_Control(pDX, IDC_EDIT12, m_HystThresholdLow);
+       DDX_Control(pDX, IDC_EDIT11, m_HystScaling);
+       DDX_Control(pDX, IDC_EDIT10, m_HnaHold);
+       DDX_Control(pDX, IDC_EDIT9, m_MidHold);
+       DDX_Control(pDX, IDC_EDIT7, m_PollInt);
+       DDX_Control(pDX, IDC_EDIT6, m_TcHold);
+       DDX_Control(pDX, IDC_EDIT5, m_TcInt);
+       DDX_Control(pDX, IDC_EDIT4, m_HnaInt);
+       DDX_Control(pDX, IDC_EDIT3, m_MidInt);
+       DDX_Control(pDX, IDC_EDIT2, m_HelloHold);
+       DDX_Control(pDX, IDC_EDIT1, m_HelloInt);
+       DDX_Control(pDX, IDC_LIST1, m_InterfaceList);
+       DDX_Control(pDX, IDC_TEXT1, m_DebugLevelText);
+       DDX_Control(pDX, IDC_SLIDER2, m_DebugLevel);
+       //}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(MyDialog2, CDialog)
+       //{{AFX_MSG_MAP(MyDialog2)
+       ON_WM_HSCROLL()
+       ON_BN_CLICKED(IDC_CHECK1, OnHystCheck)
+       ON_BN_CLICKED(IDC_BUTTON4, OnOpenButton)
+       ON_BN_CLICKED(IDC_BUTTON5, OnSaveButton)
+       ON_BN_CLICKED(IDC_BUTTON1, OnResetButton)
+       ON_BN_CLICKED(IDC_CHECK4, OnEtxCheck)
+       ON_BN_CLICKED(IDC_RADIO1, OnEtxRadio1)
+       ON_BN_CLICKED(IDC_RADIO2, OnEtxRadio2)
+       ON_BN_CLICKED(IDOK, OnOK)
+       ON_BN_CLICKED(IDCANCEL, OnCancel)
+       ON_EN_KILLFOCUS(IDC_EDIT14, OnKillfocusEtxWinSize)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+void MyDialog2::OnOK()
+{
+}
+
+void MyDialog2::OnCancel()
+{
+}
+
+void MyDialog2::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
+{
+       if (pScrollBar == (CScrollBar *)&m_DebugLevel)
+               SetDebugLevel(m_DebugLevel.GetPos());
+       
+       CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
+}
+
+void MyDialog2::Reset(void)
+{
+       char PathName[MAX_PATH + 50];
+       char *Walker;
+       int i;
+
+       ::GetModuleFileName(NULL, PathName, MAX_PATH);
+
+       for (Walker = PathName; *Walker != 0; Walker++);
+       
+       while (*Walker != '\\')
+               Walker--;
+
+       lstrcpy(Walker + 1, "Default.olsr");
+
+       if (OpenConfigFile(PathName) < 0)
+               return;
+
+       m_Ipv6Check.SetCheck(FALSE);
+
+       if (Conf->interfaces == NULL)
+       {
+               for (i = 0; i < Interfaces->GetSize(); i++)
+               {
+                       if ((*IsWlan)[i] == "-")
+                               m_InterfaceList.SetCheck(i, FALSE);
+
+                       else
+                               m_InterfaceList.SetCheck(i, TRUE);
+               }
+       }
+}
+
+BOOL MyDialog2::OnInitDialog() 
+{
+       int i;
+
+       CDialog::OnInitDialog();
+       
+       m_DebugLevel.SetRange(0, 9, TRUE);
+
+       m_InterfaceList.SetExtendedStyle(m_InterfaceList.GetExtendedStyle() |
+                       LVS_EX_CHECKBOXES);
+
+       for (i = 0; i < Interfaces->GetSize(); i++)
+       {
+               m_InterfaceList.InsertItem(i,
+               (*Interfaces)[i] + " - " + (*Addresses)[i]);
+       }
+
+       MIB_IPFORWARDROW IpFwdRow;
+
+       if (::GetBestRoute(0, 0, &IpFwdRow) != NO_ERROR)
+               m_InternetCheck.EnableWindow(FALSE);
+
+       m_MprCov.LimitText(1);
+
+       Reset();
+
+       return TRUE;
+}
+
+void MyDialog2::OnHystCheck() 
+{
+       BOOL EnaDis = m_HystCheck.GetCheck();
+
+       m_HystThresholdLow.EnableWindow(EnaDis);
+       m_HystThresholdHigh.EnableWindow(EnaDis);
+       m_HystScaling.EnableWindow(EnaDis);
+}
+
+void MyDialog2::OnEtxCheckWorker() 
+{
+       BOOL EnaDis = m_EtxCheck.GetCheck();
+
+       m_EtxWindowSize.EnableWindow(EnaDis);
+       m_EtxRadio1.EnableWindow(EnaDis);
+       m_EtxRadio2.EnableWindow(EnaDis);
+       m_FishEyeCheck.EnableWindow(EnaDis);
+}
+
+void MyDialog2::OnEtxCheck()
+{
+       OnEtxCheckWorker();
+
+       AfxMessageBox("WARNING - This parameter breaks compliance with the OLSR standard.\n\n"
+               "Make sure that either all nodes in your network use ETX or all nodes in your network don't use ETX.\n\n"
+               "DO NOT MIX NODES WITH DIFFERENT ETX SETTINGS!");
+}
+
+int MyDialog2::OpenConfigFile(CString PathName)
+{
+       struct hna4_entry *Hna4;
+       struct olsr_if *Int, *PrevInt;
+       struct olsr_msg_params *MsgPar;
+       int NumInt = m_InterfaceList.GetItemCount();
+       int i;
+       CString IntName;
+       CString Conv;
+
+       if (Conf != NULL)
+               olsrd_free_cnf(Conf);
+
+       Conf = olsrd_parse_cnf(PathName);
+
+       if (Conf == NULL)
+               return -1;
+
+       for (i = 0; i < NumInt; i++)
+               m_InterfaceList.SetCheck(i, FALSE);
+
+       for (Int = Conf->interfaces; Int != NULL; Int = Int->next)
+       {
+               IntName = Int->name;
+               IntName.MakeUpper();
+
+               for (i = 0; i < NumInt; i++)
+               {
+                       if (m_InterfaceList.GetItemText(i, 0).Mid(0, 4) == IntName)
+                               m_InterfaceList.SetCheck(i, TRUE);
+               }
+       }
+
+       Int = Conf->interfaces;
+
+       MsgPar = &Int->cnf->hello_params;
+
+       Conv.Format("%.2f", MsgPar->emission_interval);
+       m_HelloInt.SetWindowText(Conv);
+
+       Conv.Format("%.2f", MsgPar->validity_time);
+       m_HelloHold.SetWindowText(Conv);
+
+       MsgPar = &Int->cnf->tc_params;
+       
+       Conv.Format("%.2f", MsgPar->emission_interval);
+       m_TcInt.SetWindowText(Conv);
+
+       Conv.Format("%.2f", MsgPar->validity_time);
+       m_TcHold.SetWindowText(Conv);
+
+       MsgPar = &Int->cnf->mid_params;
+       
+       Conv.Format("%.2f", MsgPar->emission_interval);
+       m_MidInt.SetWindowText(Conv);
+
+       Conv.Format("%.2f", MsgPar->validity_time);
+       m_MidHold.SetWindowText(Conv);
+
+       MsgPar = &Int->cnf->hna_params;
+       
+       Conv.Format("%.2f", MsgPar->emission_interval);
+       m_HnaInt.SetWindowText(Conv);
+
+       Conv.Format("%.2f", MsgPar->validity_time);
+       m_HnaHold.SetWindowText(Conv);
+
+       SetDebugLevel(Conf->debug_level);
+
+       Conv.Format("%.2f", Conf->pollrate);
+       m_PollInt.SetWindowText(Conv);
+
+       Conv.Format("%d", Conf->mpr_coverage);
+       m_MprCov.SetWindowText(Conv);
+
+       m_TcRed.SetCurSel(Conf->tc_redundancy);
+
+       m_HystCheck.SetCheck(Conf->use_hysteresis);
+
+       Conv.Format("%.2f", Conf->hysteresis_param.scaling);
+       m_HystScaling.SetWindowText(Conv);
+
+       Conv.Format("%.2f", Conf->hysteresis_param.thr_high);
+       m_HystThresholdHigh.SetWindowText(Conv);
+
+       Conv.Format("%.2f", Conf->hysteresis_param.thr_low);
+       m_HystThresholdLow.SetWindowText(Conv);
+
+       OnHystCheck();
+
+       m_FishEyeCheck.SetCheck(Conf->lq_fish > 0);
+
+       m_EtxCheck.SetCheck(Conf->lq_level > 0);
+
+       Conv.Format("%d", Conf->lq_wsize);
+       m_EtxWindowSize.SetWindowText(Conv);
+
+       m_EtxRadio1.SetCheck(Conf->lq_level == 1);
+       m_EtxRadio2.SetCheck(Conf->lq_level == 0 || Conf->lq_level == 2);
+
+       OnEtxCheckWorker();
+
+       m_InternetCheck.SetCheck(FALSE);
+
+       for (Hna4 = Conf->hna4_entries; Hna4 != NULL; Hna4 = Hna4->next)
+               if (Hna4->net.v4 == 0 && Hna4->netmask.v4 == 0 &&
+                       m_InternetCheck.IsWindowEnabled())
+               m_InternetCheck.SetCheck(TRUE);
+
+       PrevInt = NULL;
+
+       for (Int = Conf->interfaces; Int != NULL; Int = Int->next)
+       {
+               IntName = Int->name;
+
+               if (IntName.CompareNoCase("GUI") == 0)
+                       break;
+
+               PrevInt = Int;
+       }
+
+       if (Int != NULL)
+       {
+               if (PrevInt == NULL)
+                       Conf->interfaces = Int->next;
+
+               else
+                       PrevInt->next = Int->next;
+
+               olsrd_cnf_free(Int);
+       }
+
+       return 0;
+}
+
+static struct olsr_if *AddInterface(struct olsrd_config **Conf, CString Name)
+{
+       struct olsr_if *Int;
+
+       Int = (struct olsr_if *)olsrd_cnf_malloc(sizeof (struct olsr_if));
+
+       if (Int == NULL)
+       {
+               AfxMessageBox("Cannot allocate memory.");
+               return NULL;
+       }
+
+       Int->name = (char *)olsrd_cnf_malloc(Name.GetLength() + 1);
+
+       if (Int->name == NULL)
+       {
+               olsrd_cnf_free(Int);
+
+               AfxMessageBox("Cannot allocate memory.");
+               return NULL;
+       }
+
+       ::lstrcpy(Int->name, Name);
+
+       Int->config = NULL;
+       Int->index = 0;
+       Int->configured = OLSR_FALSE;
+       Int->interf = NULL;
+
+       Int->cnf = get_default_if_config();
+
+       Int->next = (*Conf)->interfaces;
+       (*Conf)->interfaces = Int;
+
+       return Int;
+}
+
+int MyDialog2::SaveConfigFile(CString PathName, int Real)
+{
+       struct olsr_if *Int, *PrevInt;
+       struct olsr_msg_params *MsgPar;
+       CString Conv;
+       struct hna4_entry *Hna4, *NewHna4, *PrevHna4;
+       int NumInt = m_InterfaceList.GetItemCount();
+       int i;
+       CString IntName, IntName2;
+       struct ipc_host *IpcHost;
+       unsigned int Local;
+
+       PrevInt = NULL;
+
+       // remove interfaces that we do not want
+       
+       for (Int = Conf->interfaces; Int != NULL; Int = Int->next)
+       {
+               IntName = Int->name;
+               IntName.MakeUpper();
+
+               for (i = 0; i < NumInt; i++)
+                       if (m_InterfaceList.GetItemText(i, 0).Mid(0, 4) == IntName)
+                               break;
+
+               if (i == NumInt || !m_InterfaceList.GetCheck(i))
+               {
+                       if (PrevInt != NULL)
+                               PrevInt->next = Int->next;
+
+                       else
+                               Conf->interfaces = Int->next;
+               }
+       }
+       
+       // add missing interfaces
+       
+       for (i = 0; i < NumInt; i++)
+       {
+               if (!m_InterfaceList.GetCheck(i))
+                       continue;
+
+               IntName2 = m_InterfaceList.GetItemText(i, 0).Mid(0, 4);
+
+               for (Int = Conf->interfaces; Int != NULL; Int = Int->next)
+               {
+                       IntName = Int->name;
+                       IntName.MakeUpper();
+
+                       if (IntName2 == IntName)
+                               break;
+               }
+
+               if (Int == NULL)
+                       AddInterface(&Conf, m_InterfaceList.GetItemText(i, 0).Mid(0, 4));
+       }
+
+       // add dummy interface, if there aren't any real interfaces
+
+       if (Conf->interfaces == NULL && Real != 0)
+               AddInterface(&Conf, "GUI");
+
+       // per-interface settings
+
+       for (Int = Conf->interfaces; Int != NULL; Int = Int->next)
+       {
+               MsgPar = &Int->cnf->hello_params;
+
+               m_HelloInt.GetWindowText(Conv);
+               MsgPar->emission_interval = (float)atof(Conv);
+
+               m_HelloHold.GetWindowText(Conv);
+               MsgPar->validity_time = (float)atof(Conv);
+
+               MsgPar = &Int->cnf->tc_params;
+
+               m_TcInt.GetWindowText(Conv);
+               MsgPar->emission_interval = (float)atof(Conv);
+
+               m_TcHold.GetWindowText(Conv);
+               MsgPar->validity_time = (float)atof(Conv);
+
+               MsgPar = &Int->cnf->mid_params;
+
+               m_MidInt.GetWindowText(Conv);
+               MsgPar->emission_interval = (float)atof(Conv);
+
+               m_MidHold.GetWindowText(Conv);
+               MsgPar->validity_time = (float)atof(Conv);
+
+               MsgPar = &Int->cnf->hna_params;
+
+               m_HnaInt.GetWindowText(Conv);
+               MsgPar->emission_interval = (float)atof(Conv);
+
+               m_HnaHold.GetWindowText(Conv);
+               MsgPar->validity_time = (float)atof(Conv);
+       }
+
+       // global settings
+
+       Conf->debug_level = DebugLevel;
+
+       m_PollInt.GetWindowText(Conv);
+       Conf->pollrate = (float)atof(Conv);
+
+       Conf->tc_redundancy = (unsigned char)m_TcRed.GetCurSel();
+
+       m_MprCov.GetWindowText(Conv);
+       Conf->mpr_coverage = (unsigned char)atoi(Conv);
+
+       Conf->use_hysteresis = m_HystCheck.GetCheck() ? OLSR_TRUE : OLSR_FALSE;
+
+       m_HystScaling.GetWindowText(Conv);
+       Conf->hysteresis_param.scaling = (float)atof(Conv);
+
+       m_HystThresholdHigh.GetWindowText(Conv);
+       Conf->hysteresis_param.thr_high = (float)atof(Conv);
+
+       m_HystThresholdLow.GetWindowText(Conv);
+       Conf->hysteresis_param.thr_low = (float)atof(Conv);
+
+       if (!m_EtxCheck.GetCheck())
+               Conf->lq_level = 0;
+
+       else if (m_EtxRadio1.GetCheck())
+               Conf->lq_level = 1;
+
+       else
+               Conf->lq_level = 2;
+
+       if (!m_FishEyeCheck.GetCheck())
+               Conf->lq_fish = 0;
+
+       else
+               Conf->lq_fish = 1;
+
+       m_EtxWindowSize.GetWindowText(Conv);
+       Conf->lq_wsize = atoi(Conv);
+
+       PrevHna4 = NULL;
+
+       // check for a default gateway HNA4 entry
+
+       for (Hna4 = Conf->hna4_entries; Hna4 != NULL; Hna4 = Hna4->next)
+       {
+               if (Hna4->net.v4 == 0 && Hna4->netmask.v4 == 0)
+                       break;
+
+               PrevHna4 = Hna4;
+       }
+
+       // add default gateway HNA4 entry
+
+       if (m_InternetCheck.GetCheck() && Hna4 == NULL)
+       {
+               NewHna4 = (struct hna4_entry * )
+                       olsrd_cnf_malloc(sizeof (struct hna4_entry));
+
+               if (NewHna4 == NULL)
+               {
+                       AfxMessageBox("Cannot allocate memory.");
+                       return -1;
+               }
+
+               NewHna4->net.v4 = 0;
+               NewHna4->netmask.v4 = 0;
+
+               NewHna4->next = Conf->hna4_entries;
+               Conf->hna4_entries = NewHna4;
+       }
+
+       // remove default gateway HNA4 entry
+
+       if (!m_InternetCheck.GetCheck() && Hna4 != NULL)
+       {
+               if (PrevHna4 == NULL)
+                       Conf->hna4_entries = Hna4->next;
+
+               else
+                       PrevHna4->next = Hna4->next;
+
+               olsrd_cnf_free(Hna4);
+       }
+
+       Local = inet_addr("127.0.0.1");
+
+       for (IpcHost = Conf->ipc_hosts; IpcHost != NULL; IpcHost = IpcHost->next)
+               if (IpcHost->host.v4 == Local)
+                       break;
+
+       if (IpcHost == NULL && Real == 0)
+       {
+               IpcHost = (struct ipc_host *)
+                       olsrd_cnf_malloc(sizeof (struct ipc_host));
+
+               if (IpcHost == NULL)
+               {
+                       AfxMessageBox("Cannot allocate memory.");
+                       return -1;
+               }
+
+               IpcHost->host.v4 = Local;
+
+               IpcHost->next = Conf->ipc_hosts;
+               Conf->ipc_hosts = IpcHost;
+
+               Conf->ipc_connections++;
+               Conf->open_ipc = OLSR_TRUE;
+       }
+
+       // write configuration file
+
+       if (olsrd_write_cnf(Conf, PathName) < 0)
+               return -1;
+
+       return 0;
+}
+
+void MyDialog2::OnSaveButton()
+{
+       CFileDialog FileDialog(FALSE);
+       CString FileName = "Default.olsr";
+       CString PathName;
+
+       FileDialog.m_ofn.lpstrFilter = "Configuration file (*.olsr)\0*.olsr\0";
+       FileDialog.m_ofn.nFilterIndex = 1;
+
+       FileDialog.m_ofn.lpstrFile = FileName.GetBuffer(500);
+       FileDialog.m_ofn.nMaxFile = 500;
+
+       if (FileDialog.DoModal() == IDOK)
+       {
+               PathName = FileDialog.GetPathName();
+
+               if (SaveConfigFile(PathName, 1) < 0)
+                       AfxMessageBox("Cannot save configuration file '" + PathName + "'.");
+       }
+
+       FileName.ReleaseBuffer();
+}
+
+void MyDialog2::OnOpenButton()
+{
+       CFileDialog FileDialog(TRUE);
+       CString FileName = "Default.olsr";
+       CString PathName;
+
+       FileDialog.m_ofn.lpstrFilter = "Configuration file (*.olsr)\0*.olsr\0";
+       FileDialog.m_ofn.nFilterIndex = 1;
+
+       FileDialog.m_ofn.lpstrFile = FileName.GetBuffer(500);
+       FileDialog.m_ofn.nMaxFile = 500;
+
+       if (FileDialog.DoModal() == IDOK)
+       {
+               PathName = FileDialog.GetPathName();
+
+               if (OpenConfigFile(PathName) < 0)
+                       AfxMessageBox("Cannot open configuration file '" + PathName + "'.");
+       }
+
+       FileName.ReleaseBuffer();
+}
+
+void MyDialog2::OnResetButton() 
+{
+       Reset();
+}
+
+void MyDialog2::OnEtxRadio1() 
+{
+       m_EtxRadio2.SetCheck(FALSE);
+}
+
+void MyDialog2::OnEtxRadio2() 
+{
+       m_EtxRadio1.SetCheck(FALSE);
+}
+
+void MyDialog2::OnKillfocusEtxWinSize() 
+{
+       CString Conv;
+       int WinSize;
+
+       m_EtxWindowSize.GetWindowText(Conv);
+       WinSize = atoi(Conv);
+
+       if (WinSize < 3)
+               WinSize = 3;
+
+       else if (WinSize > 128)
+               WinSize = 128;
+
+       Conv.Format("%d", WinSize);
+       m_EtxWindowSize.SetWindowText(Conv);
+}
index 0c196b0..3275086 100644 (file)
-/*\r
- * The olsr.org Optimized Link-State Routing daemon (olsrd)\r
- * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * * Redistributions of source code must retain the above copyright \r
- *   notice, this list of conditions and the following disclaimer.\r
- * * Redistributions in binary form must reproduce the above copyright \r
- *   notice, this list of conditions and the following disclaimer in \r
- *   the documentation and/or other materials provided with the \r
- *   distribution.\r
- * * Neither the name of olsr.org, olsrd nor the names of its \r
- *   contributors may be used to endorse or promote products derived \r
- *   from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \r
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \r
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \r
- * POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Visit http://www.olsr.org for more information.\r
- *\r
- * If you find this software useful feel free to make a donation\r
- * to the project. For more information see the website or contact\r
- * the copyright holders.\r
- *\r
- * $Id: MyDialog2.h,v 1.8 2005/03/02 00:13:23 tlopatic Exp $\r
- */\r
-\r
-#if !defined(AFX_MYDIALOG2_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_)\r
-#define AFX_MYDIALOG2_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_\r
-\r
-#if _MSC_VER > 1000\r
-#pragma once\r
-#endif\r
-\r
-#include "MyEdit.h"\r
-\r
-#define MAKELIB\r
-#define OLSR_PLUGIN\r
-#include <olsr_cfg.h>\r
-\r
-class MyDialog2 : public CDialog\r
-{\r
-public:\r
-       MyDialog2(CWnd* pParent = NULL);\r
-\r
-       BOOL Create(CWnd *Parent);\r
-\r
-       int OpenConfigFile(CString);\r
-       int SaveConfigFile(CString, int);\r
-\r
-       CStringArray *Interfaces;\r
-       CStringArray *Addresses;\r
-       CStringArray *IsWlan;\r
-\r
-       struct olsrd_config *Conf;\r
-\r
-       //{{AFX_DATA(MyDialog2)\r
-       enum { IDD = IDD_DIALOG2 };\r
-       CComboBox       m_TcRed;\r
-       CEdit   m_MprCov;\r
-       CButton m_EtxRadio2;\r
-       CButton m_EtxRadio1;\r
-       CEdit   m_EtxWindowSize;\r
-       CButton m_EtxCheck;\r
-       CButton m_Ipv6Check;\r
-       CButton m_InternetCheck;\r
-       CButton m_HystCheck;\r
-       MyEdit  m_HystThresholdHigh;\r
-       MyEdit  m_HystThresholdLow;\r
-       MyEdit  m_HystScaling;\r
-       MyEdit  m_HnaHold;\r
-       MyEdit  m_MidHold;\r
-       MyEdit  m_PollInt;\r
-       MyEdit  m_TcHold;\r
-       MyEdit  m_TcInt;\r
-       MyEdit  m_HnaInt;\r
-       MyEdit  m_MidInt;\r
-       MyEdit  m_HelloHold;\r
-       MyEdit  m_HelloInt;\r
-       CListCtrl       m_InterfaceList;\r
-       CStatic m_DebugLevelText;\r
-       CSliderCtrl     m_DebugLevel;\r
-       //}}AFX_DATA\r
-\r
-       //{{AFX_VIRTUAL(MyDialog2)\r
-       protected:\r
-       virtual void DoDataExchange(CDataExchange* pDX);\r
-       //}}AFX_VIRTUAL\r
-\r
-protected:\r
-\r
-       //{{AFX_MSG(MyDialog2)\r
-       afx_msg void OnOK();\r
-       afx_msg void OnCancel();\r
-       afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);\r
-       virtual BOOL OnInitDialog();\r
-       afx_msg void OnHystCheck();\r
-       afx_msg void OnOpenButton();\r
-       afx_msg void OnSaveButton();\r
-       afx_msg void OnResetButton();\r
-       afx_msg void OnEtxCheck();\r
-       afx_msg void OnEtxRadio1();\r
-       afx_msg void OnEtxRadio2();\r
-       afx_msg void OnKillfocusEtxWinSize();\r
-       //}}AFX_MSG\r
-       DECLARE_MESSAGE_MAP()\r
-\r
-       CFont EditFont;\r
-\r
-       int DebugLevel;\r
-       void SetDebugLevel(int);\r
-\r
-       void Reset(void);\r
-\r
-       void OnEtxCheckWorker(void);\r
-};\r
-\r
-//{{AFX_INSERT_LOCATION}}\r
-\r
-#endif\r
+/*
+ * The olsr.org Optimized Link-State Routing daemon (olsrd)
+ * Copyright (c) 2004, Thomas Lopatic (thomas@lopatic.de)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright 
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in 
+ *   the documentation and/or other materials provided with the 
+ *   distribution.
+ * * Neither the name of olsr.org, olsrd nor the names of its 
+ *   contributors may be used to endorse or promote products derived 
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+ * CAUSED AND ON 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 ADVISED OF THE 
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Visit http://www.olsr.org for more information.
+ *
+ * If you find this software useful feel free to make a donation
+ * to the project. For more information see the website or contact
+ * the copyright holders.
+ *
+ * $Id: MyDialog2.h,v 1.9 2007/03/27 03:01:06 tlopatic Exp $
+ */
+
+#if !defined(AFX_MYDIALOG2_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_)
+#define AFX_MYDIALOG2_H__1A381668_A36B_4C51_9B79_643BC2A59D88__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#include "MyEdit.h"
+
+#define MAKELIB
+#define OLSR_PLUGIN
+#include <olsr_cfg.h>
+#include "afxwin.h"
+
+class MyDialog2 : public CDialog
+{
+public: