Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find an implementation of DHCP that could be used in Renode #2

Open
PiotrZierhoffer opened this issue Mar 10, 2021 · 3 comments
Open
Labels

Comments

@PiotrZierhoffer
Copy link

To implement the DHCP support, we need the to have the DHCP server.

We can

a) implement it ourselves
b) find an implementation and use it

Both options are fine. Our own implementation has to be simple though, and I'm not very familiar with the protocol itself to judge how much work it would be.

External library has to have a permissive license (Apache, MIT etc).

It needs to compile well on Mono and .NET Framework and should not rely on external software.
It should also be configurable from code, not config files.

Please note all candidates you're investigating in this issue (along with the decision and its justification).

@Lukkai
Copy link

Lukkai commented May 5, 2021

@PiotrZierhoffer
We've found and started working with this implementation of DHCP - https://github.com/dotnetprojects/sharp-dhcp-server-lib.
It is licenced under MIT licence and is still being developed (latest lib update 25 Nov 2020).

@John15321
Copy link
Member

We have encountered difficulties with the sharp-dhcp-server-lib library, it seems that it is either incomplete or lacks a feature. We cannot find how this server is supposed to react to given packets.
In SharpDHCPServerLib/DHCPServer.cs there is a delegate which is supposed to be connected to a server but there is no implementation of mentioned OnDataReceived, OnDiscover, OnRequest, OnDecline, OnReleased, and OnInform. That would basically make us implement core mechanisms of the protocol ourselves which makes using this (not very well written) semi-library pointless as we might as well write it ourselves.

But because the mechanisms of the DHCP protocol are complicated and would take a while we are looking for other libraries that could replace this one. We found one that looks promising accept the fact we haven't managed to compile it on Linux:
DHCPSharp

It builds without a problem on Windows, the error when building on Linux:

$ dotnet build
Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

/home/john/Documents/Universitas/Semestris6/Projekt/DHCPServer/DHCPServer/Setup/Setup.vdproj(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.

Build FAILED.

/home/john/Documents/Universitas/Semestris6/Projekt/DHCPServer/DHCPServer/Setup/Setup.vdproj(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.95

It seems like the issue is with how the project files are set up. Given that the project is on the MIT license it shouldn't be that big of a deal (assuming a build change would suffice, and no further changes to the project are needed).

Given that DHCP is not a very popular protocol to implement, and also it is not easy to implement we are thinking of giving it less focus and directing our efforts in the direction of more popular protocols like HTTP. @PiotrZierhoffer please voice your opinion 😁

@PiotrZierhoffer
Copy link
Author

Regarding the first lib - there's a sample showing exactly how to use it https://github.com/dotnetprojects/sharp-dhcp-server-lib/blob/master/SharpDHCPServer_Sample/Program.cs

DHCPSharp is not to be built by dotnet, but by mono. You can call xbuild in the directory with the .sln file, but you have to fetch the dependencies first, by running nuget restore.

DHCPSharp relies on SQLite - this is not something that I'd like to have. Having a data store in memory would be way better.

So the first one is more compelling in that it does not use SQLite. It looks kinda shabby, though (e.g. the nonexistent readme). I'd it a try.

P.S. Once again, ping me over email to get my attention, these notifications sometimes get lost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants