You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Honey Potion gives to the user access to libraries to help writing eBPF programs, such as Honey.Ethhdr and Honey.Bpf_helpers. These libraries contain methods that translate directly to C code instead of going through the translation, allowing more power and customizability.
However, as it stands, the implementation of these libraries is located inside lib/honey/translator.ex in the to_c method. This can be hard to find, customize and improve. Ideally we should move the implementation of these libraries and their methods outside the Translator.ex and into the lib/honey/c_libraries so that contribution becomes easier and so that advanced users may customize the implementations of the C counterpart to their own use cases.
As an example the implementation of the Honey.Ethhdr can be found in lib/honey/translator.ex in the format:
def to_c({{:., _, [Honey.Ethhdr, function]}, _, params}, _context) do
case function do
:init -> ...
:const_udp -> ...
:ip_protocol -> ...
...
end
end
and it should be moved to lib/honey/c_libraries into a module that defines the functions themselves, such as:
defmodule Honey.Ethhdr do
def init() do
...
end
def const_udp() do
...
end
def ip_protocol() do
...
end
...
end
Elixir has interesting ways to delegate function calls dynamically during execution, and a solution that leverages that to use the atom passed as a variable into the to_c function as the function name called in the library would be ideal, as it wouldn't require further changes into the translator.ex file for each new library.
The text was updated successfully, but these errors were encountered:
Honey Potion gives to the user access to libraries to help writing eBPF programs, such as
Honey.Ethhdr
andHoney.Bpf_helpers
. These libraries contain methods that translate directly to C code instead of going through the translation, allowing more power and customizability.However, as it stands, the implementation of these libraries is located inside
lib/honey/translator.ex
in theto_c
method. This can be hard to find, customize and improve. Ideally we should move the implementation of these libraries and their methods outside the Translator.ex and into thelib/honey/c_libraries
so that contribution becomes easier and so that advanced users may customize the implementations of the C counterpart to their own use cases.As an example the implementation of the
Honey.Ethhdr
can be found inlib/honey/translator.ex
in the format:and it should be moved to
lib/honey/c_libraries
into a module that defines the functions themselves, such as:Elixir has interesting ways to delegate function calls dynamically during execution, and a solution that leverages that to use the atom passed as a variable into the to_c function as the function name called in the library would be ideal, as it wouldn't require further changes into the
translator.ex
file for each new library.The text was updated successfully, but these errors were encountered: