⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mydialog2.cpp

📁 wifi 无线网络路由协议OLSR linux下C代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* * 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_FILEstatic char THIS_FILE[] = __FILE__;#endif#define MAXIF 100MyDialog2::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_MAPEND_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;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -