Skip to content

Commit

Permalink
Network chamoc & chamos
Browse files Browse the repository at this point in the history
  • Loading branch information
eduazocar committed May 16, 2022
1 parent 769cb6a commit a1bc188
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion dist/tools/chamoc/autoconfigure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ find_interface() {
find_interface
fi
INTERFACE=${INTERFACE%/}
echo ${INTERFACE}
}

echo "Waiting for network interface."
Expand Down Expand Up @@ -76,7 +77,7 @@ close_connection(){
IPV6_GLOBAL=$1

if [ -z "${IPV6_GLOBAL}" ]; then
IPV6_GLOBAL="2001:db8::1"
IPV6_GLOBAL="2001:db8:1::1"
fi

find_interface
Expand Down
3 changes: 3 additions & 0 deletions dist/tools/chamoc/chamoc_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ int serialize(chamoc_message_t msg, char *buffer, uint8_t len) {
strbuff[3 + i] = msg.addr.in_8[i];
}
memcpy(buffer, strbuff, len);

return 1;
}

int connect_chamos(chamos_client_t client, char *buffer, uint8_t len) {
Expand Down Expand Up @@ -68,6 +70,7 @@ int connect_chamos(chamos_client_t client, char *buffer, uint8_t len) {

uint8_t craft_seqno(chamos_client_t *client) {
client->seqno += 1;
return client->seqno;
}

int8_t send_message(chamos_client_t *client, uint8_t *msg, uint8_t len) {
Expand Down
4 changes: 2 additions & 2 deletions dist/tools/chamoc/include/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
#ifndef CLIENT_H
#define CLIENT_H

#include<stdio.h>
#include<stdint.h>
#include <stdio.h>
#include <stdint.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
Expand Down
4 changes: 3 additions & 1 deletion dist/tools/chamoc/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int main(int argc, char **argv) {
if (argc < 2 || argc > 6) {
printf("Usage <nib> [add, del] [iface] [ipv6_address] [prefix]\n");
}
if (strcmp(argv[1], "nib") == 0) {
else if (strcmp(argv[1], "nib") == 0) {
if (argc < 6) {
printf("Wrong Passed\n");
} else if (strcmp(argv[2], "add") == 0) {
Expand All @@ -39,4 +39,6 @@ int main(int argc, char **argv) {
nib_req(argv[3], argv[4], (uint8_t)atoi(argv[5]), MSG_NIB_DEL);
}
}

return 1;
}
3 changes: 3 additions & 0 deletions dist/tools/chamoc/nib.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <unistd.h>
#include "client.h"
#include "chamoc_msg.h"
#include "nib.h"

int nib_req(char *iface, char *ip, uint8_t prefix, uint8_t msg_type) {
if (msg_type == MSG_NIB_ADD || msg_type == MSG_NIB_DEL) {
Expand All @@ -51,4 +52,6 @@ int nib_req(char *iface, char *ip, uint8_t prefix, uint8_t msg_type) {
__FILE__, __LINE__);
return -1;
}

return 1;
}
2 changes: 1 addition & 1 deletion dist/tools/chamoc/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if [ -z "${INTERFACE}" ] || [ -z "${IPV6_ADD}" ] || [ -z "${IPV6_PREFIX}" ]; the
else
compile
run
echo "Run again ./runsh in server test, then Press any key to send a nib del request"
echo "Run again ./run.sh in server test, then Press any key to send a nib del request"
read -r -n 1
closing
fi
2 changes: 1 addition & 1 deletion firmware/network/chamos/chamos.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "xtimer.h"

#define CHAMOS_MSG_QUEUE_SIZE (8)
#define SERVER_BUFFER_SIZE (19)
#define SERVER_BUFFER_SIZE (20)

/**
* @brief GNRC netif
Expand Down
4 changes: 2 additions & 2 deletions firmware/network/chamos/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ The module CHAMOS (Communication Handler for Addressing Management | Origin Serv
- First number is the ```type``` which is given by:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MSG_NIB_ADD = 1, /**< Add entry to NIB */
MSG_NIB_DEL = 2, /**< Delete entry from NIB */
MSG_NIB_ADD = 2, /**< Add entry to NIB */
MSG_NIB_DEL = 3, /**< Delete entry from NIB */
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- The second value is the sequence number ``` seqno ```.
Expand Down

0 comments on commit a1bc188

Please sign in to comment.