-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d84cf6
commit 10c40de
Showing
23 changed files
with
863 additions
and
1,415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include<stdint.h> | ||
#include<chunk_attributes.h> | ||
#include<stdlib.h> | ||
|
||
struct chunk_attributes { | ||
uint16_t hopcount; | ||
} __attribute__((packed)); | ||
|
||
int8_t chunk_attributes_init(struct chunk *c) | ||
{ | ||
int8_t res = -1; | ||
struct chunk_attributes * attr; | ||
|
||
if (c) | ||
{ | ||
c->attributes_size = sizeof(struct chunk_attributes); | ||
c->attributes = attr = malloc(c->attributes_size); | ||
attr->hopcount = 0; | ||
} | ||
return res; | ||
} | ||
|
||
uint16_t chunk_attributes_get_hopcount(const struct chunk * c) | ||
{ | ||
struct chunk_attributes * attr; | ||
|
||
attr = c->attributes; | ||
return attr->hopcount; | ||
} | ||
|
||
int8_t chunk_attributes_deinit(struct chunk * c) | ||
{ | ||
if (c && c->attributes) | ||
{ | ||
free(c->attributes); | ||
c->attributes_size = 0; | ||
return 0; | ||
} | ||
return -1; | ||
} | ||
|
||
int8_t chunk_attributes_update_upon_reception(struct chunk *c) | ||
{ | ||
struct chunk_attributes * attr; | ||
|
||
if (c && c->attributes) | ||
{ | ||
attr = c->attributes; | ||
attr->hopcount++; | ||
} | ||
return -1; | ||
} | ||
|
||
int8_t chunk_attributes_update_upon_sending(struct chunk *c) | ||
{ | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef __CHUNK_ATTRIBUTES_H__ | ||
#define __CHUNK_ATTRIBUTES_H__ | ||
|
||
#include<stdint.h> | ||
|
||
#include<chunk.h> | ||
|
||
|
||
struct chunk_attributes; | ||
|
||
int8_t chunk_attributes_init(struct chunk *c); | ||
|
||
int8_t chunk_attributes_deinit(struct chunk * c); | ||
|
||
uint16_t chunk_attributes_get_hopcount(const struct chunk * c); | ||
|
||
int8_t chunk_attributes_update_upon_sending(struct chunk *c); | ||
|
||
int8_t chunk_attributes_update_upon_reception(struct chunk *c); | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.