Merge branch 'dev_add_application' into 'master'

Add application sources

See merge request prpl-foundation/prplmesh/wifieye!1
This commit is contained in:
Frederik Van Bogaert
2023-09-21 13:10:15 +00:00
5 changed files with 213 additions and 79 deletions

1
LICENSE Symbolic link
View File

@@ -0,0 +1 @@
LICENSES/BSD-2-Clause-Patent.txt

View File

@@ -0,0 +1,47 @@
Copyright (c) <YEAR> <COPYRIGHT HOLDERS>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Subject to the terms and conditions of this license, each copyright holder
and contributor hereby grants to those receiving rights under this license
a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except for failure to satisfy the conditions of this license) patent license
to make, have made, use, offer to sell, sell, import, and otherwise transfer
this software, where such license applies only to those patent claims, already
acquired or hereafter acquired, licensable by such copyright holder or contributor
that are necessarily infringed by:
(a) their Contribution(s) (the licensed copyrights of copyright holders and
non-copyrightable additions of contributors, in source or binary form) alone;
or
(b) combination of their Contribution(s) with the work of authorship to which
such Contribution(s) was added by such copyright holder or contributor, if,
at the time the Contribution is added, such addition causes such combination
to be necessarily infringed. The patent license shall not apply to any other
combinations which include the Contribution.
Except as expressly stated above, no rights or licenses from any copyright
holder or contributor is granted under this license, whether expressly, by
implication, estoppel or otherwise.
DISCLAIMER
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

109
README.md
View File

@@ -1,92 +1,43 @@
# wifiEye
wifiEye allows to read CSI data from unix socket opened by whm vendor modules and display those data in the console output.
The output format is the same format used by hexdump.
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
## Build
```
cd existing_repo
git remote add origin https://gitlab.com/prpl-foundation/prplmesh/wifieye.git
git branch -M master
git push -uf origin master
Make App :
git clone https://gitlab.com/prpl-foundation/prplmesh/wifieye.git wifieye
cd wifieye
make all
Clean App :
make clean
```
## Integrate with your tools
## Run
- [ ] [Set up project integrations](https://gitlab.com/prpl-foundation/prplmesh/wifieye/-/settings/integrations)
```
Usage :
## Collaborate with your team
wifiEye <csi unix socket path>
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
Example of output format against Maxlinear whm vendor module :
## Test and Deploy
# wifiEye /var/run/whm-csi.sock
Use the built-in continuous integration in GitLab.
00000310 00 00 9A C7 12 1B 9B 41 00 00 00 00 05 01 6C FF |.......A......l.|
00000320 91 FF 8C FF 63 FF 42 FF 26 16 00 00 01 00 28 00 |....c.B.&.....(.|
00000330 14 00 30 00 00 00 01 96 FF 00 00 00 00 00 00 00 |..0.............|
00000340 00 00 02 00 00 0A 30 00 00 0B 31 03 00 0C 07 0D |......0...1.....|
00000350 D8 0D 75 4F FD 00 A5 80 F3 01 01 3F 0B 02 00 00 |..uO.......?....|
00000360 00 03 00 00 00 04 60 BF FC 00 C7 D0 F1 01 FE 2E |......`.........|
00000370 0C 02 00 00 00 03 00 00 00 04 3A FF FC 00 EE 30 |..........:....0|
00000380 F0 01 07 2F 0D 02 00 00 00 03 00 00 00 04 20 BF |.../.......... .|
00000390 FC 00 21 81 EE 01 15 CF 0E 02 00 00 00 03 00 00 |..!.............|
000003A0 00 04 03 0F FC 00 5D 31 ED 01 35 CF 10 02 00 00 |......]1..5.....|
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
```

26
makefile Normal file
View File

@@ -0,0 +1,26 @@
LDLIBS := $(if $(STAGINGDIR), -L$(STAGINGDIR)/lib) $(if $(STAGINGDIR), -L$(STAGINGDIR)/usr/lib)
CFLAGS := -Wall -I./include -I$(STAGINGDIR)/include/ -I$(STAGINGDIR)/usr/include/
SRC_DIR := src
APP_DIR := $(SRC_DIR)/App
APP_SRCS := $(wildcard $(APP_DIR)/*.c)
APP_OBJS := $(patsubst $(APP_DIR)/%.c, $(APP_DIR)/%.o, $(APP_SRCS))
OUTPUT := wifiEye
all: $(OUTPUT)
$(APP_DIR)/%.o: $(APP_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
$(OUTPUT): $(APP_OBJS)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(LDLIBS)
clean:
rm -f $(APP_OBJS) $(OUTPUT)
.PHONY: all clean

109
src/App/main.c Normal file
View File

@@ -0,0 +1,109 @@
/* This code is subject to the terms of the BSD+Patent license.
* See LICENSE file for more details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <stdbool.h>
#include <ctype.h>
#include <sys/socket.h>
#include <sys/un.h>
bool running = true;
void sig_handler(int signum) {
if((signum == SIGINT) || (signum == SIGTERM)) {
running = false;
}
}
static void s_printHexDump(char* data, size_t dataSize) {
size_t i, j;
for(i = 0; i < dataSize; i += 16) {
printf("%08lX ", i);
for(j = 0; j < 16; j++) {
if(i + j < dataSize) {
printf("%02X ", (unsigned char) data[i + j]);
} else {
printf(" "); // Padding for the last line if needed
}
}
printf(" |");
for(j = 0; j < 16; j++) {
if(i + j < dataSize) {
if(isprint((unsigned char) data[i + j])) {
printf("%c", (unsigned char) data[i + j]);
} else {
printf(".");
}
}
}
printf("|\n");
}
}
int main(int argc, char* argv[]) {
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);
if(argc < 2) {
printf("Usage: %s <csi unix socket path> \n", argv[0]);
exit(EXIT_FAILURE);
}
int sockfd;
struct sockaddr_un serverAddr;
// Create a new socket
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
if(sockfd == -1) {
perror("socket");
exit(EXIT_FAILURE);
}
// Set up the server address
memset(&serverAddr, 0, sizeof(serverAddr));
serverAddr.sun_family = AF_UNIX;
strncpy(serverAddr.sun_path, argv[1], sizeof(serverAddr.sun_path) - 1);
// Connect to server
if(connect(sockfd, (struct sockaddr*) &serverAddr, sizeof(serverAddr)) < 0) {
perror("connect");
close(sockfd);
exit(EXIT_FAILURE);
}
// Receive data from server
int bufferSize = 1024;
char buffer[bufferSize];
printf("%s starting !\n", argv[0]);
while(running) {
int recvBytes = recv(sockfd, buffer, bufferSize - 1, 0);
if(recvBytes <= 0) {
if(recvBytes == 0) {
printf("server disconnected \n");
} else {
perror("recv");
}
break;
} else {
buffer[recvBytes] = '\0';
s_printHexDump(buffer, recvBytes);
}
}
// Close the socket when done
printf("%s exiting !\n", argv[0]);
close(sockfd);
return EXIT_SUCCESS;
}