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

Consistent naming of functions and parameters and byte order fix #613

Merged

Conversation

ArnoStiefvater
Copy link
Member

@ArnoStiefvater ArnoStiefvater commented Oct 23, 2020

What:

  • Make naming of functions consistent. E.g. forge_ipv6_packet -> forge_ip_v6_packet
  • Rename func parameter from ipv6 to ip6
  • Fix byte order when retrieving ip6 elements in get_ipv6_element

Why:

  • Easier use of nasl functions.
  • Correct value of ip6 elements.

How:

Check backwards compatibility

# create some ip6 packet and store it in ip6_packet
# All of the following calls should work and output the same
version = get_ipv6_element(ipv6:ip6_packet, element: "ip6_v");
display ("ipv6 " + version);
version = get_ipv6_element(ip6:ip6_packet, element: "ip6_v");
display ("ip6 " + version);
version = get_ip_v6_element(ipv6:ip6_packet, element: "ip6_v");
display ("ipv6 " + version);
version = get_ip_v6_element(ip6:ip6_packet, element: "ip6_v");
display ("ip6 " + version);

Check output of retrieved elements

# Create ip6 packet with some  (maybe nonsensical) data
IP6_v = 6;
IP6_P = 42;
IP6_HLIM = 42;
IP6_PLEN = 42;
IP6_TC = 42;
IP6_FL = 42;
ip6_packet = forge_ipv6_packet( ip6_v:IP6_v,
                                ip6_p:IP6_P,
                                ip6_plen:IP6_PLEN,
                                ip6_tc:IP6_TC,
                                ip6_fl:IP6_FL,
                                ip6_hlim:IP6_HLIM,
                                ip6_src:myhost,
                                ip6_dst:get_host_ip());

# Get and display the elements
version = get_ip_v6_element(ipv6:ip6_packet, element: "ip6_tc");
display ("ip6_tc " + version);
version = get_ip_v6_element(ipv6:ip6_packet, element: "ip6_fl");
display ("ip6_fl " + version);
version = get_ip_v6_element(ipv6:ip6_packet, element: "ip6_plen");
display ("ip6_plen " + version); # payload len is inserted automatically and is probably 0 even though we specified it above.

Checklist:

@ArnoStiefvater ArnoStiefvater marked this pull request as ready for review October 23, 2020 09:44
@ArnoStiefvater ArnoStiefvater changed the title Consistent naming of fucntions and parameters and byte order fix Consistent naming of functions and parameters and byte order fix Oct 23, 2020
nasl/nasl_init.c Outdated Show resolved Hide resolved
nasl/nasl_init.c Outdated Show resolved Hide resolved
For consistency the "ipv6" part becomes "ip_v6"
now. The old name still needs to be included
for backwards compatibility of nasl script.
Both function names call the same function
internally.
Renamed for consistency reasons.
For backwards compatibility 'ipv6' still gets
evaluated.
Also rename the internl function names.
These functions are not used inernally by other
nasl functions and therefore no backwards
compatibility problems exist.
Entries of old function names
can only be deleted once versions older
than 20.08 are no longer in use.

Func parameter 'ipv6' can be renamed to 'ip6'
after version older than 20.08 are no longer in
use.
@ArnoStiefvater ArnoStiefvater changed the base branch from master to openvas-20.08 October 27, 2020 09:12
Copy link
Member

@cfi-gb cfi-gb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base branch might be "master" again to avoid introducing new symbols into a stable branch.

@ArnoStiefvater
Copy link
Member Author

Base branch might be "master" again to avoid introducing new symbols into a stable branch.

This should not be a problem. According the @jjnicola this was only an issue in the past because of binary incompatibility. Now nasl/misc libs are build together with openvas.

Copy link
Member

@cfi-gb cfi-gb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarification. I'm currently not able to do any tests on this but changes looks good from a short look.

@cfi-gb cfi-gb self-requested a review October 29, 2020 08:56
@cfi-gb cfi-gb self-requested a review October 29, 2020 08:57
@ArnoStiefvater ArnoStiefvater merged commit ddf60ee into greenbone:openvas-20.08 Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants