This commit is contained in:
kudzu_cp 2012-07-02 22:21:35 +00:00
parent b627090276
commit 8a802201e0
14 changed files with 614 additions and 118 deletions

View file

@ -161,8 +161,7 @@ Source: ".\Build\VSIP\Cosmos.Deploy.USB.exe"; DestDir: "{app}\Build\Tools"; Flag
Source: ".\Build\VSIP\Cosmos.Build.Common.dll"; DestDir: "{app}\Build\Tools"; Flags: ignoreversion uninsremovereadonly
Source: ".\Build\VSIP\Mosa.Utility.IsoImage.dll"; DestDir: "{app}\Build\Tools"; Flags: ignoreversion uninsremovereadonly
;
Source: ".\Build\VSIP\Cosmos.Deploy.Pixie.GUI.exe"; DestDir: "{app}\Build\Tools"; Flags: ignoreversion uninsremovereadonly
Source: ".\Build\VSIP\Cosmos.Deploy.Pixie.dll"; DestDir: "{app}\Build\Tools"; Flags: ignoreversion uninsremovereadonly
Source: ".\Build\VSIP\Cosmos.Deploy.Pixie.exe"; DestDir: "{app}\Build\Tools"; Flags: ignoreversion uninsremovereadonly
; Kernel assemblies
Source: ".\Build\VSIP\Cosmos.Debug.Kernel.*"; DestDir: "{app}\Kernel"; Flags: ignoreversion uninsremovereadonly

View file

@ -216,11 +216,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VMWareLib", "..\source2\VMW
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Deploy", "Deploy", "{FD42844B-2767-4DF4-B0AF-EA5F7CB11528}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.Deploy.Pixie", "..\source2\Cosmos.Deploy.Pixie\Cosmos.Deploy.Pixie.csproj", "{287A4DA7-9A8B-4F64-913F-1828DA67F16A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.Deploy.USB", "..\source2\Cosmos.Deploy.USB\Cosmos.Deploy.USB.csproj", "{3D84CF8B-C6DF-4D78-8DE1-708582B43711}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.Deploy.Pixie.GUI", "..\source2\Cosmos.Deploy.Pixie.GUI\Cosmos.Deploy.Pixie.GUI.csproj", "{D4BA64B3-D7F6-4A3A-AF1D-74E41B49D865}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.Deploy.Pixie", "..\source2\Cosmos.Deploy.Pixie.GUI\Cosmos.Deploy.Pixie.csproj", "{D4BA64B3-D7F6-4A3A-AF1D-74E41B49D865}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Launch", "Launch", "{37C932A7-5958-4262-8A47-73042CC7B503}"
EndProject
@ -234,7 +232,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.VS.Launch", "..\sour
EndProject
Global
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 66
SccNumberOfProjects = 65
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs04
SccLocalPath0 = .
@ -468,38 +466,34 @@ Global
SccProjectTopLevelParentUniqueName57 = Cosmos.sln
SccProjectName57 = ../source2/VMWareLib
SccLocalPath57 = ..\\source2\\VMWareLib
SccProjectUniqueName58 = ..\\source2\\Cosmos.Deploy.Pixie\\Cosmos.Deploy.Pixie.csproj
SccProjectUniqueName58 = ..\\source2\\Cosmos.Deploy.USB\\Cosmos.Deploy.USB.csproj
SccProjectTopLevelParentUniqueName58 = Cosmos.sln
SccProjectName58 = ../source2/Cosmos.Deploy.Pixie
SccLocalPath58 = ..\\source2\\Cosmos.Deploy.Pixie
SccProjectUniqueName59 = ..\\source2\\Cosmos.Deploy.USB\\Cosmos.Deploy.USB.csproj
SccProjectName58 = ../source2/Cosmos.Deploy.USB
SccLocalPath58 = ..\\source2\\Cosmos.Deploy.USB
SccProjectUniqueName59 = ..\\source2\\Debug\\Cosmos.Debug.HostProcess\\Cosmos.Launch.VMware.csproj
SccProjectTopLevelParentUniqueName59 = Cosmos.sln
SccProjectName59 = ../source2/Cosmos.Deploy.USB
SccLocalPath59 = ..\\source2\\Cosmos.Deploy.USB
SccProjectUniqueName60 = ..\\source2\\Cosmos.Deploy.Pixie.GUI\\Cosmos.Deploy.Pixie.GUI.csproj
SccProjectName59 = ../source2/Debug/Cosmos.Debug.HostProcess
SccLocalPath59 = ..\\source2\\Debug\\Cosmos.Debug.HostProcess
SccProjectUniqueName60 = Cosmos.Launch.Common\\Cosmos.Launch.Common.csproj
SccProjectTopLevelParentUniqueName60 = Cosmos.sln
SccProjectName60 = ../source2/Cosmos.Deploy.Pixie.GUI
SccLocalPath60 = ..\\source2\\Cosmos.Deploy.Pixie.GUI
SccProjectUniqueName61 = ..\\source2\\Debug\\Cosmos.Debug.HostProcess\\Cosmos.Launch.VMware.csproj
SccProjectName60 = Cosmos.Launch.Common
SccLocalPath60 = Cosmos.Launch.Common
SccProjectUniqueName61 = ..\\source2\\Cosmos.Launch.Manual\\Cosmos.Launch.Manual.csproj
SccProjectTopLevelParentUniqueName61 = Cosmos.sln
SccProjectName61 = ../source2/Debug/Cosmos.Debug.HostProcess
SccLocalPath61 = ..\\source2\\Debug\\Cosmos.Debug.HostProcess
SccProjectUniqueName62 = Cosmos.Launch.Common\\Cosmos.Launch.Common.csproj
SccProjectName61 = ../source2/Cosmos.Launch.Manual
SccLocalPath61 = ..\\source2\\Cosmos.Launch.Manual
SccProjectUniqueName62 = ..\\source2\\Cosmos.Launch.Slave\\Cosmos.Launch.Slave.csproj
SccProjectTopLevelParentUniqueName62 = Cosmos.sln
SccProjectName62 = Cosmos.Launch.Common
SccLocalPath62 = Cosmos.Launch.Common
SccProjectUniqueName63 = ..\\source2\\Cosmos.Launch.Manual\\Cosmos.Launch.Manual.csproj
SccProjectName62 = ../source2/Cosmos.Launch.Slave
SccLocalPath62 = ..\\source2\\Cosmos.Launch.Slave
SccProjectUniqueName63 = ..\\source2\\Cosmos.VS.Launch\\Cosmos.VS.Launch.csproj
SccProjectTopLevelParentUniqueName63 = Cosmos.sln
SccProjectName63 = ../source2/Cosmos.Launch.Manual
SccLocalPath63 = ..\\source2\\Cosmos.Launch.Manual
SccProjectUniqueName64 = ..\\source2\\Cosmos.Launch.Slave\\Cosmos.Launch.Slave.csproj
SccProjectName63 = ../source2/Cosmos.VS.Launch
SccLocalPath63 = ..\\source2\\Cosmos.VS.Launch
SccProjectUniqueName64 = ..\\source2\\Cosmos.Deploy.Pixie.GUI\\Cosmos.Deploy.Pixie.csproj
SccProjectTopLevelParentUniqueName64 = Cosmos.sln
SccProjectName64 = ../source2/Cosmos.Launch.Slave
SccLocalPath64 = ..\\source2\\Cosmos.Launch.Slave
SccProjectUniqueName65 = ..\\source2\\Cosmos.VS.Launch\\Cosmos.VS.Launch.csproj
SccProjectTopLevelParentUniqueName65 = Cosmos.sln
SccProjectName65 = ../source2/Cosmos.VS.Launch
SccLocalPath65 = ..\\source2\\Cosmos.VS.Launch
SccProjectName64 = ../source2/Cosmos.Deploy.Pixie.GUI
SccLocalPath64 = ..\\source2\\Cosmos.Deploy.Pixie.GUI
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Builder|Any CPU = Builder|Any CPU
@ -1451,23 +1445,6 @@ Global
{76CDB55D-55E3-4B53-AE33-12EC31430826}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{76CDB55D-55E3-4B53-AE33-12EC31430826}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{76CDB55D-55E3-4B53-AE33-12EC31430826}.Release|x86.ActiveCfg = Release|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Builder|Any CPU.ActiveCfg = Release|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Builder|Any CPU.Build.0 = Release|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Builder|Mixed Platforms.ActiveCfg = Release|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Builder|Mixed Platforms.Build.0 = Release|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Builder|x86.ActiveCfg = Release|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Builder|x86.Build.0 = Release|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Debug|x86.ActiveCfg = Debug|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Debug|x86.Build.0 = Debug|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Release|Any CPU.Build.0 = Release|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{287A4DA7-9A8B-4F64-913F-1828DA67F16A}.Release|x86.ActiveCfg = Release|Any CPU
{3D84CF8B-C6DF-4D78-8DE1-708582B43711}.Builder|Any CPU.ActiveCfg = Release|x86
{3D84CF8B-C6DF-4D78-8DE1-708582B43711}.Builder|Mixed Platforms.ActiveCfg = Release|x86
{3D84CF8B-C6DF-4D78-8DE1-708582B43711}.Builder|Mixed Platforms.Build.0 = Release|x86
@ -1638,7 +1615,6 @@ Global
{D048E0B1-8B2B-4A99-8376-7FC8A0656A05} = {9588D51E-243F-4ABA-AED2-A77DA0634209}
{6C14B7D1-CACB-4049-A0BD-9CAC5CFCF2C2} = {CD291145-6AD0-41CD-9986-2044F41660DE}
{86F88A09-6801-4474-BFC8-EF09F3A9B89D} = {CD291145-6AD0-41CD-9986-2044F41660DE}
{287A4DA7-9A8B-4F64-913F-1828DA67F16A} = {FD42844B-2767-4DF4-B0AF-EA5F7CB11528}
{3D84CF8B-C6DF-4D78-8DE1-708582B43711} = {FD42844B-2767-4DF4-B0AF-EA5F7CB11528}
{D4BA64B3-D7F6-4A3A-AF1D-74E41B49D865} = {FD42844B-2767-4DF4-B0AF-EA5F7CB11528}
EndGlobalSection

View file

@ -8,8 +8,8 @@
<ProjectGuid>{D4BA64B3-D7F6-4A3A-AF1D-74E41B49D865}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Cosmos.Deploy.Pixie.GUI</RootNamespace>
<AssemblyName>Cosmos.Deploy.Pixie.GUI</AssemblyName>
<RootNamespace>Cosmos.Deploy.Pixie</RootNamespace>
<AssemblyName>Cosmos.Deploy.Pixie</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
@ -62,6 +62,9 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="DHCP\DHCP.cs" />
<Compile Include="DHCP\DhcpPacket.cs" />
<Compile Include="TFTP\TrivialFTP.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -103,10 +106,7 @@
<Resource Include="Cosmos.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Cosmos.Deploy.Pixie\Cosmos.Deploy.Pixie.csproj">
<Project>{287A4DA7-9A8B-4F64-913F-1828DA67F16A}</Project>
<Name>Cosmos.Deploy.Pixie</Name>
</ProjectReference>
<Content Include="Resources.html" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
namespace Cosmos.Deploy.Pixie {
public class DHCP {
protected const int ServerPort = 67;
protected const int ClientPort = 68;
protected UdpClient mUDP;
protected string mBootFile;
protected byte[] mServerIP;
protected byte[] mClientIP;
protected IPEndPoint mRecvEndPoint;
public void Stop() {
mUDP.Close();
}
// Need full path to boot file because it needs to get the size
public DHCP(byte[] aServerIP, string aBootFile) {
mServerIP = aServerIP;
mBootFile = aBootFile;
mClientIP = (byte[])mServerIP.Clone();
mClientIP[3] = 2;
mUDP = new UdpClient(new IPEndPoint(new IPAddress(mServerIP), ServerPort));
mRecvEndPoint = new IPEndPoint(IPAddress.Any, ServerPort);
}
protected DhcpPacket Receive(DhcpPacket.MsgType aWaitFor) {
while (true) {
var xData = mUDP.Receive(ref mRecvEndPoint);
var xPacket = new DhcpPacket(xData);
if (xPacket.Msg == aWaitFor) {
return xPacket;
}
}
}
protected void Send(DhcpPacket aPacket) {
var xBytes = aPacket.GetBytes();
mUDP.Send(xBytes, xBytes.Length, new IPEndPoint(IPAddress.Broadcast, 68));
}
protected DhcpPacket SendOffer(DhcpPacket aDiscover) {
var xOut = new DhcpPacket();
xOut.Op = DhcpPacket.OpType.Reply;
xOut.TxID = aDiscover.TxID;
xOut.YourAddr = BitConverter.ToUInt32(mClientIP, 0);
xOut.ServerAddr = BitConverter.ToUInt32(mServerIP, 0);
xOut.HwAddr = aDiscover.HwAddr;
xOut.Flags = aDiscover.Flags;
xOut.Msg = DhcpPacket.MsgType.Offer;
xOut.Options.Add(1, new byte[] { 255, 255, 255, 0 });
xOut.Options.Add(54, mServerIP);
xOut.AddTextOption(60, "PXEClient");
xOut.BootFile = Path.GetFileName(mBootFile);
var xFileInfo = new FileInfo(mBootFile);
byte xBlockCount = (byte)(xFileInfo.Length / 512);
xOut.Options.Add(13, new byte[] { 0, xBlockCount });
Send(xOut);
return xOut;
}
protected DhcpPacket SendAck(DhcpPacket aDiscover, DhcpPacket aRequest) {
aDiscover.Msg = DhcpPacket.MsgType.Ack;
Send(aDiscover);
return aDiscover;
}
public event Action<DHCP, string> OnLog;
protected void DoLog(string aText) {
if (OnLog != null) {
OnLog(this, aText);
}
}
public void Execute() {
DhcpPacket xRequest;
DhcpPacket xReply;
xRequest = Receive(DhcpPacket.MsgType.Discover);
DoLog("Discover received.");
xReply = SendOffer(xRequest);
string xClientIP = mClientIP[0] + "." + mClientIP[1] + "." + mClientIP[2] + "." + mClientIP[3];
DoLog("Offer sent: " + xClientIP);
// Wait for REQUEST. We need to filter out other DISCOVER that may have been sent
xRequest = Receive(DhcpPacket.MsgType.Request);
DoLog("Request received.");
xReply = SendAck(xReply, xRequest);
DoLog("Acknowledgement sent.");
}
}
}

View file

@ -0,0 +1,145 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Cosmos.Deploy.Pixie {
public class DhcpPacket {
public DhcpPacket() {
}
public DhcpPacket(byte[] aData) {
var xReader = new BinaryReader(new MemoryStream(aData));
Op = (OpType)xReader.ReadByte();
if (Op != OpType.Request) {
throw new Exception("Invalid Op");
}
HwType = xReader.ReadByte();
HwLength = xReader.ReadByte();
Hops = xReader.ReadByte();
// Dont worry about byte order, its an atomic number
TxID = xReader.ReadUInt32();
//secs 2 filled in by client, seconds elapsed since client started trying to boot.
xReader.ReadUInt16();
Flags = xReader.ReadUInt16();
// Dont reverse IP Addresses, byte arrays end up big endian as we write them back
ClientAddr = xReader.ReadUInt32();
// Your Addr
xReader.ReadUInt32();
// Server Addr
xReader.ReadUInt32();
// Gateway Addr
xReader.ReadUInt32();
HwAddr = xReader.ReadBytes(16);
//sname 64 optional server host name, null terminated string.
xReader.ReadBytes(64);
//file 128 boot file name, null terminated string;
// 'generic' name or null in bootrequest,
// fully qualified directory-path
// name in bootreply.
xReader.ReadBytes(128);
if (xReader.ReadUInt32() != mMagicCookie) {
throw new Exception("[DHCP] Magic cookie doesn't match.");
}
//options var Optional parameters field. See the options
// documents for a list of defined options.
while (true) {
byte xOption = xReader.ReadByte();
if (xOption == 255) {
break;
} else if (xOption == 0) {
continue;
}
byte xLength = xReader.ReadByte();
Options.Add(xOption, xReader.ReadBytes(xLength));
}
Msg = (MsgType)Options[53][0];
}
public byte[] GetBytes() {
// See comments in ctor why we dont convert to network byte order
var xStream = new MemoryStream();
var xWriter = new BinaryWriter(xStream);
xWriter.Write((byte)Op);
xWriter.Write((byte)1);
xWriter.Write((byte)6);
xWriter.Write((byte)0);
xWriter.Write(TxID);
xWriter.Write((UInt16)0);
xWriter.Write(Flags);
xWriter.Write(0);
xWriter.Write(YourAddr);
xWriter.Write(ServerAddr);
xWriter.Write(0);
xWriter.Write(HwAddr);
var xBytes1 = ASCIIEncoding.ASCII.GetBytes("none");
xWriter.Write(xBytes1);
xWriter.Write(new byte[64 - xBytes1.Length]);
var xBytes = ASCIIEncoding.ASCII.GetBytes(BootFile);
xWriter.Write(xBytes);
xWriter.Write(new byte[128 - xBytes.Length]);
xWriter.Write(mMagicCookie);
xWriter.Write((byte)53);
xWriter.Write((byte)1);
xWriter.Write((byte)Msg);
foreach (var xOption in Options) {
xWriter.Write(xOption.Key);
xWriter.Write((byte)xOption.Value.Length);
xWriter.Write(xOption.Value);
}
xWriter.Write((byte)255);
var xResult = xStream.ToArray();
return xResult;
}
public void AddTextOption(byte aID, string aText) {
var xBytes = Encoding.ASCII.GetBytes(aText);
var xBytes2 = new byte[xBytes.Length + 1];
xBytes2[0] = (byte)xBytes.Length;
xBytes.CopyTo(xBytes2, 1);
Options.Add(aID, xBytes2);
}
protected UInt32 mMagicCookie = 0x63538263;
public Dictionary<byte, byte[]> Options = new Dictionary<byte, byte[]>();
public enum MsgType { Discover = 1, Offer, Request, Decline, Ack, Nak, Release };
public MsgType Msg;
public enum OpType { Request = 1, Reply }
public OpType Op;
public byte HwType;
public byte HwLength;
public byte Hops;
public UInt32 TxID;
public UInt16 Flags;
public UInt32 ClientAddr;
public UInt32 YourAddr;
public UInt32 ServerAddr;
public byte[] HwAddr;
public string BootFile;
}
}

View file

@ -8,55 +8,56 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace Cosmos.Deploy.Pixie.GUI.Properties {
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
namespace Cosmos.Deploy.Pixie.Properties {
using System;
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if ((resourceMan == null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Cosmos.Deploy.Pixie.GUI.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Cosmos.Deploy.Pixie.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View file

@ -8,19 +8,19 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace Cosmos.Deploy.Pixie.GUI.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
namespace Cosmos.Deploy.Pixie.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
}

View file

@ -0,0 +1,45 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<h3>
TFTP</h3>
<ul>
<li><a href="http://tools.ietf.org/html/rfc906">http://tools.ietf.org/html/rfc906</a></li>
<li>The TFTP Protocol (Revision 2) - <a href="http://tools.ietf.org/html/rfc1350">http://tools.ietf.org/html/rfc1350</a></li>
<li>TFTP Option Extension - <a href="http://tools.ietf.org/html/rfc2347">http://tools.ietf.org/html/rfc2347</a></li>
<li>TFTP Blocksize Option - <a href="http://tools.ietf.org/html/rfc2348">http://tools.ietf.org/html/rfc2348</a></li>
<li>TFTP Timeout Interval and Transfer Size Options -
<a href="http://tools.ietf.org/html/rfc2349">http://tools.ietf.org/html/rfc2349</a></li>
</ul>
<h3>
PXE</h3>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Preboot_Execution_Environment">http://en.wikipedia.org/wiki/Preboot_Execution_Environment</a></li>
<li><a href="http://www.altirigos.com/forums/threads/multiple-pxe-servers-not-working.625/">http://www.altirigos.com/forums/threads/multiple-pxe-servers-not-working.625/</a></li>
<li><a href="http://www.pix.net/software/pxeboot/archive/pxespec.pdf">
http://www.pix.net/software/pxeboot/archive/pxespec.pdf</a></li>
</ul>
<h3>
DHCP</h3>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol</a></li>
<li>Dynamic Host Configuration Protocol -
<a href="http://tools.ietf.org/html/rfc2131">http://tools.ietf.org/html/rfc2131</a></li>
<li>DHCP Options and BOOTP Vendor Extensions -
<a href="http://tools.ietf.org/html/rfc1533">http://tools.ietf.org/html/rfc1533</a></li>
</ul>
<h3>
BOOTP</h3>
<ul>
<li><a href="http://en.wikipedia.org/wiki/BOOTP">http://en.wikipedia.org/wiki/BOOTP</a></li>
<li><a href="http://tools.ietf.org/html/rfc951">http://tools.ietf.org/html/rfc951</a></li>
<li><a href="http://pxe.dev.aboveaverageurl.com/index.php/PXE_Booting">http://pxe.dev.aboveaverageurl.com/index.php/PXE_Booting</a></li>
<li>Vendor Area - <a href="http://tools.ietf.org/html/rfc1048">http://tools.ietf.org/html/rfc1048</a></li>
</ul>
</body>
</html>

View file

@ -0,0 +1,223 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace Cosmos.Deploy.Pixie {
public class TrivialFTP {
public enum OpType { Read = 1, Write, Data, Ack, Error, OptionAck };
protected byte[] mServerIP;
protected string mPath;
protected int Port = 69;
protected UdpClient mUDP;
protected IPEndPoint mRecvEP;
protected IPEndPoint mDataEP;
protected string mFilename;
protected string mPathname;
protected int mBlockSize = 512;
public void Stop() {
mUDP.Close();
}
public TrivialFTP(byte[] aServerIP, string aPath) {
mServerIP = aServerIP;
mPath = aPath;
mUDP = new UdpClient(new IPEndPoint(new IPAddress(mServerIP), Port));
mRecvEP = new IPEndPoint(IPAddress.Any, Port);
}
public event Action<TrivialFTP, string, long> OnFileStart;
protected void DoFileStart(string aFilename, long aSize) {
if (OnFileStart != null) {
OnFileStart(this, aFilename, aSize);
}
}
protected bool Connect() {
OpType xOp;
var xReader = Receive(OpType.Read);
mDataEP = new IPEndPoint(mRecvEP.Address, mRecvEP.Port);
mFilename = ReadString(xReader).Replace('/', '\\');
// Possible path security issues, but this is currently only designed for Cosmos, not for other.
mPathname = Path.Combine(mPath, mFilename);
string xMode = ReadString(xReader).ToLower();
if (xMode != "octet") {
throw new Exception("[TFTP] Expected octet.");
}
// Read Option Extension
bool xTSize = false;
if (xReader.BaseStream.Position < xReader.BaseStream.Length) {
string xName = ReadString(xReader).ToLower();
string xValue = ReadString(xReader);
if (xName == "tsize") {
xTSize = true;
} else if (xName == "blksize") {
mBlockSize = int.Parse(xValue);
}
}
if (!File.Exists(mPathname)) {
SendErrFileNotFound();
return false;
}
// OptionAck
var xMS = new MemoryStream();
var xWriter = new BinaryWriter(xMS);
WriteOp(xWriter, OpType.OptionAck);
var xFileInfo = new FileInfo(mPathname);
if (xTSize) {
WriteString(xWriter, "tsize");
WriteString(xWriter, xFileInfo.Length.ToString());
}
if (mBlockSize != 512) {
WriteString(xWriter, "blksize");
WriteString(xWriter, mBlockSize.ToString());
}
// Did we write any options?
if (xWriter.BaseStream.Length > 4) {
Send(xMS.ToArray());
WaitAck(0);
}
DoFileStart(mFilename, xFileInfo.Length);
return true;
}
protected void WriteOp(BinaryWriter aWriter, OpType aOp) {
aWriter.Write((byte)0);
aWriter.Write((byte)aOp);
}
protected void WriteString(BinaryWriter aWriter, string aValue) {
aWriter.Write(Encoding.ASCII.GetBytes(aValue));
aWriter.Write((byte)0);
}
protected BinaryReader Receive(OpType aOp) {
var xData = mUDP.Receive(ref mRecvEP);
var xReader = new BinaryReader(new MemoryStream(xData));
// Op MSB which is always 0
xReader.ReadByte();
var xOp = (OpType)xReader.ReadByte();
if (xOp != aOp) {
throw new Exception("[TFTP] Expected " + aOp + ", got " + xOp + ".");
}
return xReader;
}
protected void WaitAck(int aBlockID) {
// TFTP session is port based, but since we are only supporting one client we can reuse 69 for local port.
//
// We should watch out for retry read requests, but we are pretty quick and on a LAN usage like we have
// will beat it so this works "in practice" for our scenario.
var xReader = Receive(OpType.Ack);
// Separate lines to guarantee calling order
int xBlockID = xReader.ReadByte() * 256;
xBlockID = xBlockID + xReader.ReadByte();
// Currently we dont support retries, timeouts etc
if (aBlockID != xBlockID) {
throw new Exception("[TFTP] Block ID mismatch.");
}
}
public void Execute() {
while (true) {
if (Connect()) {
DoTransfer();
}
}
}
protected void Send(byte[] aBytes) {
mUDP.Send(aBytes, aBytes.Length, mDataEP);
}
public event Action<TrivialFTP, string, long> OnFileTransfer;
protected void DoFileTransfer(string aFilename, long aPosition) {
if (OnFileTransfer != null) {
OnFileTransfer(this, aFilename, aPosition);
}
}
public event Action<TrivialFTP, string> OnFileCompleted;
protected void DoFileCompleted(string aFilename) {
if (OnFileCompleted != null) {
OnFileCompleted(this, aFilename);
}
}
protected void DoTransfer() {
using (var xFilestream = new FileStream(mPathname, FileMode.Open, FileAccess.Read)) {
int xBlockID = 1;
var xReader = new BinaryReader(xFilestream);
var xPacket = new byte[mBlockSize + 4];
// xPacket[0] MSB and is always 0
xPacket[1] = (byte)OpType.Data;
while (true) {
xPacket[2] = (byte)(xBlockID / 256);
xPacket[3] = (byte)(xBlockID % 256);
int xCount = xReader.Read(xPacket, 4, mBlockSize);
if (xCount < mBlockSize) {
xPacket = xPacket.Take(xCount + 4).ToArray();
}
Send(xPacket);
WaitAck(xBlockID);
DoFileTransfer(mFilename, xReader.BaseStream.Position);
if (xCount < mBlockSize) {
break;
}
xBlockID++;
}
}
DoFileCompleted(mFilename);
}
protected void SendErrFileNotFound() {
var xMS = new MemoryStream();
var xWriter = new BinaryWriter(xMS);
WriteOp(xWriter, OpType.Error);
// File not found
xWriter.Write((byte)0);
xWriter.Write((byte)1);
WriteString(xWriter, "File not found.");
Send(xMS.ToArray());
}
public string ReadString(BinaryReader aReader) {
var xResult = new List<byte>();
while (true) {
byte xByte = aReader.ReadByte();
if (xByte == 0) {
break;
}
xResult.Add(xByte);
}
return Encoding.ASCII.GetString(xResult.ToArray());
}
}
}

View file

@ -4,7 +4,6 @@
<h3>Public - Easy</h3>
<ul>
<li>Move selected project profile to .user file.</li>
<li>Proj props - Disable pre boot logging</li>
<li>.iso has a users dir in it</li>
</ul>
<h3>

View file

@ -46,7 +46,7 @@ namespace Cosmos.VS.Package {
string xPxePath = Path.Combine(CosmosPaths.Build, "PXE");
string xPxeIntf = GetConfigurationProperty(BuildProperties.PxeInterfaceString, false);
File.Copy(xBinFile, Path.Combine(xPxePath, "Cosmos.bin"), true);
Process.Start(Path.Combine(CosmosPaths.Tools, "Cosmos.Deploy.Pixie.GUI.exe"), xPxeIntf + " \"" + xPxePath + "\"");
Process.Start(Path.Combine(CosmosPaths.Tools, "Cosmos.Deploy.Pixie.exe"), xPxeIntf + " \"" + xPxePath + "\"");
} else {
throw new Exception("Unknown deployment type.");