Kevin Day [Sun, 31 Dec 2023 02:33:20 +0000 (20:33 -0600)]
Update: Explicitly cast UTF conversion to/from and simple packet bit operations to a uint32_t.
If the type is changed or the defines are used with different types, then the shift operators may become problematic.
Prevent this potential problem from happening through explicit casts to uint32_t.
Kevin Day [Sat, 16 Dec 2023 01:37:50 +0000 (19:37 -0600)]
Bugfix: Fix incorrect wording regarding negative times and add some clarification regarding defaults.
The time specification is mistakenly using the word "after" when it should be the word "before" for the example "2022:-5".
I decided that I needed to better clarify what I meant by default and not make it sound so strict.
Add additional language to better communicate that when the year is not specified, it is not specified.
There is no required interpretation and a default is simply a recommendation.
I am going to start trying to establish a habit of using UTC for my timestamps.
My local time zone, the date of the specification is still the 15 of December, 2023.
However, to stick with UTC for records purpose I need to the start doing this now.
There may be occasional inconsistencies for a while until I establish the habit of using UTC.
Kevin Day [Thu, 14 Dec 2023 02:27:54 +0000 (20:27 -0600)]
Refactor: The fss extract functions to be fss decode functions.
The commit 4713c80244fe1bc00da097eb27987e77c98601f0 introduced f_fss_simple_packet_encode().
Rename the f_fss_simple_packet_extract() and similar functions to f_fss_simple_packet_decode().
This makes the language more consistent between the two different functions.
Kevin Day [Tue, 12 Dec 2023 02:18:03 +0000 (20:18 -0600)]
Update: Strip NULLs from the payload number converters.
Add logic to strip the NULLs from the numbers.
The FSS functions use NULLs to reduce reallocations but the payload sends everything.
Don't introduce unexpected NULLs when writing the numbers.
I need to review the logic for any mistakes which I find is often best after sleeping on it.
Even better, I should write some unit tests to expose any potential logic flaws more easily.
Kevin Day [Mon, 11 Dec 2023 06:26:27 +0000 (00:26 -0600)]
Update: Socket size_read/size_write checks, result == -1, and explicit passing .generic.
Make sure size_read and size_write are not 0.
If either is 0, then return F_data_not.
Make sure the result checks are "== -1" rather than "< 0".
Explicitly pass .generic for the address union.
This probably isn't necessary but being explicit seems safer.
The memory address of the address union, regardless of the union type being used, is cast to 'struct sockaddr' in most cases.
This makes the use of ".generic" very practical.
Add documentation comment about F_pipe being returned.
Problems with the address unions ".sin_family" must be set or unclear F_pipe errors are returned.
I may in a future commit perform this assignment during setup because the "form" parameter makes this practical and reasonable to do.
Kevin Day [Fri, 8 Dec 2023 04:46:53 +0000 (22:46 -0600)]
Update: Re-design f_socket to better support handling of different struct sockaddr types.
The networking types are already in use, such as address family (AF_*) and protocol family (PF_*).
The known and supported socket address structures (struct sockaddr) do not directly relate to either.
Create a new enumeration that directly maps to these socket address structures (struct sockaddr), called an address form.
A 16-bit integer is hopefully more than is ever needed for this.
Rewrite f_socket_bind() and f_socket_connect() to use the socket.form enumeration.
The custom *_inet4(), *_inet6(), and *_local() functions are removed.
Add a generic, or fallback aka failsafe, type for handling the most basic socket address tructure (struct sockaddr).
Kevin Day [Fri, 8 Dec 2023 02:28:02 +0000 (20:28 -0600)]
Update: The fss-000e (Payload) specification should allow for the "payload" Section to be optional.
In cases where packets that are being sent only need to send the "header", then it makes sense to not have a "payload" Section.
This should help reduce network traffic by avoiding the extra "payload:\n" characters when the payload Section is to be ignored.
Add additional tests.
Fix bad test data, such as where the string lengths are incorrect.
Perform tests when "where" parameter both is NULL or is a valid pointer.
The tests now handle validating the "where" parameter, when specified.
Add additional comments to better communicate the logic in f_network_is_ip_address().
Properly handle the "where" parameter assignment.
Kevin Day [Mon, 4 Dec 2023 04:13:06 +0000 (22:13 -0600)]
Update: Unit tests for f_network().
The commit 309f2625e983ef164c52543b492365fe92eed6d5 did not update the unit tests.
The tests currently do not pass due to a regression that will be addressed in a follow up commit.
The referenced commit was rushed so that I could get to the f_string_range_t and related migration.
I didn't bother to review the code or run the unit tests.
I will now have to follow up with a more extensive review and fix any problems.
The unit tests need to also be updated to handle all of the new behavior of the changed function.
Kevin Day [Mon, 4 Dec 2023 01:50:55 +0000 (19:50 -0600)]
Update: The f_network_is_ip_address() to use f_string_range_double_t (soon to be f_range_double_t).
This allows for getting both the address and port range positions.
The POSIX/libc functions do not support the bracket notation in an IPV6 address.
The string detected by this must then have the brackets filtered out.
This new structure allows for saving the range.
I did a quick run-through write-up of the logic for these changes but I have not spent any time reviewing or testing the logic.
Hopefully there are not logic bugs or mistakes.
Kevin Day [Mon, 4 Dec 2023 01:43:11 +0000 (19:43 -0600)]
Feature: Add f_string_range_double_t, updating build settings and unit tests appropriately.
I need a string range structure that has two ranges for some given string for the network related code.
The unit tests are updated or added as appropriate.
Any bugs discovered in the related unit tests are fixed.
The build data is rebuilt.
I originally wrote f_string_range_t to be specific to strings.
I now think that this needs to be conceptually more generalized.
The purpose of such a generalization is to simplify the code logic and design.
Renaming f_string_range_t to f_range_t and now renaming f_string_range_double_t into f_range_double_t is the intended change.
This would then be moved out of the f_string project and into the f_type project.
This is too much to do in the scope of this commit.
Instead, the f_string_range_double_t is being added under f_string_range_double_t.
I will then follow up this commit with a refactor of the f_string_range_t and f_string_range_double_t.
Kevin Day [Thu, 30 Nov 2023 03:01:02 +0000 (21:01 -0600)]
Bugfix: f_network_from_ip_string() and f_network_to_ip_string() design problems.
Change the inet_pton() and inet_ntop() function calls to use the explicit .v4 and .v6 union members.
Being explicit is much safer.
The inet_pton() function also returns zero without the errno set when the address is invalid.
Handle this case, returning F_address_not (with error bit) when zero is returned by inet_pton().
The unit tests for these functions are incorrect and are not all called (which is why their incorrectness was not previously discovered).
Make sure to use h_errno where appropriate.
Make sure the mock function for inet_pton() allows for returning zero or non-zero.
Make sure the family type is set so that the expected return codes are returned.
Make sure the ip string is set so that the expected return codes are returned.
Handle the newly added F_address_not case.
Add the missing unit test function calls:
- test__f_network_from_ip_address__fails
- test__f_network_from_ip_name__fails
- test__f_network_from_ip_string__fails
- test__f_network_to_ip_string__fails
This could use more review and testing.
Such extra review will be performed while I continue to write TacocaT.
Kevin Day [Thu, 30 Nov 2023 02:57:43 +0000 (20:57 -0600)]
Bugfix: f_socket_connect() should require non-negative socket.id.
I seem to have this one backwards.
The socket.id must be something other than -1.
If the socket.id is -1, then just return F_file_descriptor without error bit to designate that no descriptor is available to connect with.
Kevin Day [Tue, 14 Nov 2023 23:56:43 +0000 (17:56 -0600)]
Update: Specifications for Payload and Simple Packet.
Add "type" as a recommended Object in the header section for the Payload.
Change the size units being used in Simple Packet.
The numbers used in some areas are completely wrong 2^4 is not 32-bits.
Instead use the word "bytes" or "bits" and update the units.
The Payload Block Structure uses "bytes" rather than bits as that is the general focus of that section.
All others use "bits".
Kevin Day [Wed, 1 Nov 2023 02:58:58 +0000 (21:58 -0500)]
Progress: Resume working on custom payload functions.
I'm getting more back into things and this is a small step towards pickup up where I left off.
There are several todos that I will consider and either implement or not.
This performs the work that I mentioned in the previous commit in regards to redesigning the approach in fl_fss_payload_header_write() (now called fl_fss_payload_header_map()).
I started doing some re-designing to improve the approach and prepare for signatures/checksums.
I realized somewhere during that process that I wanted to eventually control or even randomize the header order for integrity, organization, or security reasons.
The current approach makes that impractical.
I decided to save the current state so that I can then pivot to a better approach that will accommodate the above needs.
Appropriate todo notes are added to this end.
A lot of the existing payload code will be re-designed, again, as a result of this.
I decided to use two caches.
One for the main cache.
The other for a smaller, multi-purpose cache.
The second cache should be smaller and so re-allocations should be cheaper.
Use re-allocations on this as much as possible.
There are some code changes that I was indecisive around and jumped around on implementation.
I think I cleaned that all up but I may have missed something.
Kevin Day [Thu, 5 Oct 2023 04:19:44 +0000 (23:19 -0500)]
Progress: Begin adding FSS Payload processing code.
This will use the f_abstruse project.
This is very incomplete and is mostly drafted out.
Update the Featureless Make stand alone build with the latest changes.
Apply the related cleanups from 4ced1b0ba41334ce94d0a9b511b363a6031da136 (Cleanup: Have enumeration types support "none" and have the "// enum" comment at the end.).
Kevin Day [Thu, 5 Oct 2023 03:11:38 +0000 (22:11 -0500)]
Update: Simplify the f_abstruse types a little.
Being a union, the single valued integer types provide very little gain and introduce a cost in complexity.
Remove the integer types that overlap and just stick with the f_number_signed_t and f_number_unsigned_t for single value number types.
Multiple valued number types remain because there is potential for design differences due to the memory allocation and size differences.
The f_char_t type is removed.
Just stick with f_string_t.
Provide an optional "signature" Object and associated Content rules to the specification.
This better separates defining how the "header" and "payload" can be signed or have checksums applied.
The actual rules are left rather vague and flexible for implementation specific decisions.
A suggested strategy for using the "signature" is provided within the example.
Kevin Day [Wed, 4 Oct 2023 02:00:19 +0000 (21:00 -0500)]
Feature: Add f_abstruse project.
This is the initial design and may be subject to significant change as I begin to use it more.
The idea here is to provide a type that can act as a catch all for any sort of header of any specific type.
I use standard types and provide void pointer types for everything else.
I have some concerns about supporting void pointer types due to the special case of how to handle this allocation actions.
I have decided to withhold the "append" and similar standard functions for now until I get a better grasp on how this should be used.
A union is used to use the same memory space at the cost of the largest size.
A dynamic string is likely the most common case.
The resize and similar functions provide warnings that the caller needs to be careful about allocation and de-allocation.
This poses extra security concerns for when callers of these functions do not properly or safely handle the data.
I intend to use this in the FSS Simple Packet processing code, such as writing (building) the Simple Packet string.
Kevin Day [Tue, 19 Sep 2023 22:20:42 +0000 (17:20 -0500)]
Update: Restructure f_type files and add missing f_number_signed_t.
Break apart the f_type headers into multiple header files by major type groups.
This should make navigating the files a little easier.
Some of the header files are order sensitive.
The f_number_signed_t is now implemented.
Added appropriate unit tests.
I manually added the disable defines in the fake stand alone configuration file.
Kevin Day [Mon, 4 Sep 2023 20:04:37 +0000 (15:04 -0500)]
Update: Replace f_fss_simple_packet_identify() with f_fss_simple_packet_extract() and f_fss_simple_packet_extract_range().
The implementation of f_fss_simple_packet_identify() appears to be some sort of hybrid between actual code and brainstorming.
This appears to be by accident and the resulting logic of the function is nonsense.
Fix the logic in f_fss_simple_packet_identify().
I also see no reason to perform an identify call.
The FSS Packet design is so simple that I could just add 1, 4, or 5 to determine any of the parts.
Therefore, instead implement f_fss_simple_packet_extract() and f_fss_simple_packet_extract_range() to extract the Control bits and the Size integer.
The Payload part is not extracted but for the f_fss_simple_packet_extract_range(), the range for the Payload is determined.
This allows for the caller to determine how they want to manage the memory allocation.
This is a case where object-oriented would shine had I used C++ or some other object-oriented language.
I don't have this option available and so I am going to only have f_fss_simple_packet_t and f_fss_simple_packet_range_t with their respective f_fss_simple_packet_extract() and f_fss_simple_packet_extract_range() functions.
Unit tests are now provided for these two new functions.
Several unit checks did as little as necessary to perform the tests when it comes to mocking.
The additional sanity checks impose additional restrictions.
Kevin Day [Thu, 31 Aug 2023 04:19:28 +0000 (23:19 -0500)]
Update: Take advantage of lucky convenience where F_okay could be bumped from 197 to 200 thereby matching HTTP 200 status code.
I recently noticed that the F_okay is very close to being a 200 code after swapping F_none with F_okay.
This was never planned but it is incredibly convenient.
HTTP Status 200 code now matches FLL Status Code 200.
What luck!
Kevin Day [Thu, 31 Aug 2023 03:21:50 +0000 (22:21 -0500)]
Update: Relocate some of the more common or expected to be common format strings to global statics.
This is a minor resource optimization.
There will hopefully be more optimizations in the future where several of the commonly used strings (within individual projects) are moved into a single location for that given project.
Kevin Day [Mon, 28 Aug 2023 02:59:03 +0000 (21:59 -0500)]
Feature: Add -U/--under parameter to Featureless Make.
I discovered that the data build directory customization is incomplete while working on the Kevux Tools TacocaT program.
A new parameter to specify a sub-directory within the data directory, called "under", represented by -U and --under is now added.
This provides the ability to change the "build" part of the "data/build" directory.
This can even be an empty string.
The fakefile documentation and specification is updated because this parameter must now be reserved and exposed to IKI expansion.
I have not yet done a thorough test of this feature and I will hopefully do this before the next release.
I have performed a basic test and I can now compile the TacocaT program easily using this parameter.
Kevin Day [Sun, 27 Aug 2023 21:52:26 +0000 (16:52 -0500)]
Update: Wrap up re-designing the memory logic.
Update the unit tests and stand alone builds as needed.
Also clear out the stand alone builds that are out of date and require being rebuilt from the ground up.
Kevin Day [Sat, 19 Aug 2023 04:19:37 +0000 (23:19 -0500)]
Progress: Continue re-designing of the memory logic.
I would note that I am leaving the append() and append_all() for the IKI structures because they are complex.
In the long term I may end up adding back the append() and append_all() functions for each type.
At this time it is more advantageous for me to not have that consistency for easier maintainability while the project is evolving and refactoring.
I still need to look over the string and UTF string memory related functionality.
This will be more delicate and given the size of these two projects will be a bit time consuming.
Kevin Day [Thu, 17 Aug 2023 23:44:27 +0000 (18:44 -0500)]
Update: Use F_okay instead of F_none as the first status code.
This change is in two parts.
This part is just changing the status codes.
The next part will be changing all code using the status code F_none as the standard return to instead use F_okay.
I believe that F_okay makes more semantic sense than F_none when providing a standard code.
The original idea of F_none is that there are no errors.
I think "okay" is even more accurate.
Furthermore, the F_okay better matches the return code of the HTTP standard "HTTP 200 Okay".
Kevin Day [Thu, 17 Aug 2023 23:24:14 +0000 (18:24 -0500)]
Update: Simplify disable defines for status codes.
I like the idea of having the pre-created disable defines for each group.
The problem is that this is extra maintenance and I do not see significant use for this functionality.
Remove these to make my life slightly easier.
Kevin Day [Thu, 17 Aug 2023 03:48:37 +0000 (22:48 -0500)]
Progress: Continue re-designing of the memory logic, mostly getting tests back in synchronization.
Get the tests working.
Some of the tests I am not mocking the allocation and performing the real allocation actions.
This allows for the unit test to also test memory if run with valgrind.
I did this after getting much of the work done and so I ended up not consistently doing this on all of the "works" tests.
Generally, the tests for functions with the double 's' have the actual memory allocations.
Kevin Day [Sun, 13 Aug 2023 22:11:13 +0000 (17:11 -0500)]
Progress: Continue re-designing of the memory logic also removing *_append() and *_append_all().
In some cases *_append() and *_append_all() functions are removed.
This is a lot to manage at this time so remove it.
At some future point in time I need to implement a good generic append and append all design.
This is likely to use some sort of callback that performs the individual copy calls.
Many of the existing *_append() and *_append_all() are left alone but may eventually be removed.
The dynamic string based ones, however, will remain as an exception case.
The names I originally chose for the callbacks are misleading.
Rename them to be "delete" and "destroy" rather than "resize" and "adjust", respectively.
Half way through changing this I came across the more complex cases for resizing.
These I need callbacks both both array of arrays and arrays of arrays.
I did not finish the process of converting this.
The f_type_array needs more work.
In particular, the arrays of arrays in f_type_array can be moved into a common f_memory function, such as f_memory_arrayss_resize().
The unit tests have not been updated but I did manage to get the unit test for the f_account done.
The stand alone build config.h files are not update to date either.
These changes have shown a significant improvement in the resulting binary size.
The current size is actually just barely smaller than the 0.6.7 equivalent build (when compiled using the same compiler for both).
The changes are not complete and so I anticipate the 0.7.0 branch to be smaller than the 0.6.7 branch as of this change set despite the 0.7.0 development branch having more functionality.
Kevin Day [Sat, 12 Aug 2023 03:28:09 +0000 (22:28 -0500)]
Update: Ensure pointers passed to the function are constant.
The function should never be allowed to change the pointer itself.
A double pointer is used so that the value of the pointer can be another pointer which can then be changed.
After trying to figure out why the tests were failing, I finally discovered that the wrong file is being used.
The settings-mocks needs to be used to pull in the mocked data.
I felt this fix deserved its own distinct commit rather than being part of another Progress commit.
Kevin Day [Tue, 8 Aug 2023 01:21:26 +0000 (20:21 -0500)]
Cleanup: Add explicit casts in the f_memory memset() calls.
The pointer is cast to uint8_t to perform the arithmetic.
The pointer is not cast back but the cast happens in the function call.
Be explicit and designate that the cast back to a void pointer is intentional.
Kevin Day [Sun, 6 Aug 2023 21:44:56 +0000 (16:44 -0500)]
Progress: Continue re-designing of the memory logic.
This wraps up the simple memory append all functions with added unit tests.
I anticipate that I need to do the more complex ones as well.
This adds the adjust and resize callbacks for use in more complex memory functions.
The more complex memory functions for adjust and resize are implemented with unit tests.
The unit tests for the type array callbacks are incomplete because I did not get time to finish writing them.
Those unit tests are written but are incomplete and do not yet work.
Kevin Day [Sun, 6 Aug 2023 00:43:19 +0000 (19:43 -0500)]
Progress: Begin simplifying memory design, starting with f_number_unsigned_t array structures.
I find that the use of custom per-type functions to simplify the usability of the library.
I also find that this increases the complexity and size of the code base.
I believe that over time this will become more complex and even harder to maintain.
I have decided to start changing the design to go back to simple allocation methods that just require more variables.
This simplifies the code and in theory will make it faster by having fewer function calls on the stack.
This may even reduce the resulting binary size (and I hope it does).
The down side is that the users of the library will once more have longer function call lines.
This commit is the beginning of the redesign process.
I also added the "append" and "append all" methods for f_memory_array calls.
Kevin Day [Sun, 6 Aug 2023 00:38:12 +0000 (19:38 -0500)]
Regression: Invalid type used when allocating string, f_string_t should instead be f_char_t.
I noticed odd differences between the 0.6.x and the 0.7.x in terms of memory usage.
I discovered this to be due to a bug where the f_string_t is being used when the type should be instead f_char_t.
This is likely a bug introduced in some past refactor.
Kevin Day [Sat, 5 Aug 2023 15:40:14 +0000 (10:40 -0500)]
Bugfix: The socket id is not the same descriptor for reading.
When binding and listening on some socket id, the accept call on that socket creates a new descriptor.
That descriptor is not the same as the original socket id.
Add a new id_data to the socket structure to represent the data transfer file descriptor that is created via the accept() call.
Add a new f_file_close_id() to close the file by the id in case the f_file_t is not available or in use.
This adds f_time_spec_millisecond() and f_time_spec_nanosecond() for safely handling overflow and underflow when using standard FLL f_number_unsigned_t numbers.
Unit tests are added.
A comment in the controller prrogram is added to designate that the controller-specific functions should be updated to call these functions.
Kevin Day [Sat, 5 Aug 2023 00:36:26 +0000 (19:36 -0500)]
Update: Wrap the static inline functions private_inline_f_print_to_error in custom disable macros.
As an exception case, wrap the private_inline_f_print_to_error() in _di_private_inline_private_f_print_to_error_ and _di_private_inline_f_print_to_error_ as appropriate.
Using a define condition on all of the possible cases would be difficult to manage.
An explicit define is simpler and easier in this exceptional case.