static void Main(string[] args) { Console.WriteLine("LinkSAP For Windows - 802.11"); Console.WriteLine("______________________________________________"); using (StreamReader sr = new StreamReader(configPath)) { String var, val, line; Dictionary<string, string> vars = new Dictionary<string,string>(); do { line = sr.ReadLine(); if(!line.StartsWith("#") && line!="") { var = line.Split("=".ToCharArray())[0].TrimEnd(" ".ToCharArray()).ToLower(); val = line.Split("=".ToCharArray())[1].TrimStart(" ".ToCharArray()).TrimEnd(" \n".ToCharArray()).ToLower(); vars.Add(var, val); } }while(!sr.EndOfStream); sr.Close(); bool sub_LinkDet, sub_LinkUp, sub_LinkDown, sub_LinkParamRpt, sub_LinkGoingDown, sub_HandoverIm, sub_HandoverCm, sub_PDU_TransmitSt; String holder; vars.TryGetValue("sub_linkdet", out holder); sub_LinkDet = Boolean.Parse(holder); vars.TryGetValue("sub_linkup", out holder); sub_LinkUp = Boolean.Parse(holder); vars.TryGetValue("sub_linkdown", out holder); sub_LinkDown = Boolean.Parse(holder); vars.TryGetValue("sub_linkparamrpt", out holder); sub_LinkParamRpt = Boolean.Parse(holder); vars.TryGetValue("sub_linkgoingdown", out holder); sub_LinkGoingDown = Boolean.Parse(holder); vars.TryGetValue("sub_handoverim", out holder); sub_HandoverIm = Boolean.Parse(holder); vars.TryGetValue("sub_handovercm", out holder); sub_HandoverCm = Boolean.Parse(holder); vars.TryGetValue("sub_pdu_transmitst", out holder); sub_PDU_TransmitSt = Boolean.Parse(holder); vars.TryGetValue("interface_mac", out MAC); vars.TryGetValue("send_port", out holder); ushort port = UInt16.Parse(holder); vars.TryGetValue("mihf_ip", out holder); System.Net.IPAddress addr = System.Net.IPAddress.Parse(holder); toMihf = new ConnectionHelper(port, addr); vars.TryGetValue("rcv_port", out holder); ushort fromMIHFPort = UInt16.Parse(holder); vars.TryGetValue("myid", out holder); LINK_SAP_CS_80211.Information.GenericInfo.myID = holder; vars.TryGetValue("mihfid", out holder); LINK_SAP_CS_80211.Information.GenericInfo.mihfID = holder; Common.Events.Subscriptions.Subscribe(new Link_Event_List(sub_LinkDet, sub_LinkUp, sub_LinkDown, sub_LinkParamRpt, sub_LinkGoingDown, sub_HandoverIm, sub_HandoverCm, sub_PDU_TransmitSt)); Startup.BootUp s = new Startup.BootUp(MAC, fromMIHFPort, addr); } //WlanClient.WlanInterface interf = Common.Utilities.WlanHelper.getInterfaceByGuid(Startup.BootUp.getGuidForMac("00:22:FA:12:35:16")); Console.ReadLine(); }
private void Init(ushort rcvPort, System.Net.IPAddress mihAddr) { Link_Register_Indication lri = new Link_Register_Indication( Link_Type.Wireless_IEEE80211, //LinkType Link_Addr.Address_Type.MAC_ADDR, //LinkAdrressType Information.GenericInfo.Interface.GetPhysicalAddress().ToString()); //LinkAddressValue //Console.WriteLine(lri); connHelper = new ConnectionHelper(rcvPort, mihAddr); //connHelper.Send(lri.GetMessage()); ID myLinkID = new ID(new OctetString(Information.GenericInfo.myID)); ID mihfID = new ID(new OctetString(Information.GenericInfo.mihfID)); while (true) { //TODO colocar a recepção das mensagens aqui. //messageHandler.HandleMessage(m); byte[] messageAsBytes = connHelper.Receive(); //Console.WriteLine("!Received: " + messageAsBytes.Length + " bytes from local MIHF."); Message m = new Message(messageAsBytes); if (Program.MESSAGE_DETAILS) { Console.WriteLine("Received message: ("+m.MIHHeader.MID.AID+")"); Connection.MIHProtocol.PacketReader.PrintMessage(m); } //Console.WriteLine("AID: "+m.MIHHeader.MID.AID); //Console.WriteLine("Opcode: " + m.MIHHeader.MID.OpCode); //Console.WriteLine("SID: " + m.MIHHeader.MID.SID); MessageHandler.HandleMessage(m); } }