-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add OC_API annotations to oc_buffer_settings.h #647
Draft
Danielius1922
wants to merge
10
commits into
master
Choose a base branch
from
adam/feature/182-export-public-api
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e4b351b
Add OC_API annotations to oc_buffer_settings.h
Danielius1922 be6eb62
Add OC_API annotations to oc_enums.h
Danielius1922 ad35db6
Add OC_API annotations to port/oc_storage.h
Danielius1922 e8bf175
Add OC_API annotations to oc_network_monitor.h
Danielius1922 6c3d785
Add OC_API annotations to port/oc_poll_loop.h
Danielius1922 97a24ff
fixup! Add OC_API annotations to oc_buffer_settings.h
Danielius1922 fae64b4
Update public API
Danielius1922 65d0f64
Add OC_API annotations to oc_helpers.h
Danielius1922 b28a73a
Add OC_API annotations to oc_rep.h
Danielius1922 66ff75f
Update oc_ri API
Danielius1922 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,172 @@ | ||
/**************************************************************************** | ||
* | ||
* Copyright (c) 2017 Intel Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"), | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific | ||
* language governing permissions and limitations under the License. | ||
* | ||
****************************************************************************/ | ||
|
||
#include "oc_buffer_settings.h" | ||
#include "port/oc_log_internal.h" | ||
#include "util/oc_features.h" | ||
|
||
#include <stddef.h> | ||
|
||
#ifdef OC_DYNAMIC_ALLOCATION | ||
|
||
#include "messaging/coap/conf.h" | ||
|
||
#ifdef OC_INOUT_BUFFER_SIZE | ||
static size_t _OC_MTU_SIZE = OC_INOUT_BUFFER_SIZE; | ||
#else /* OC_INOUT_BUFFER_SIZE */ | ||
static size_t _OC_MTU_SIZE = 2048 + COAP_MAX_HEADER_SIZE; | ||
#endif /* !OC_INOUT_BUFFER_SIZE */ | ||
|
||
static size_t _OC_MAX_APP_DATA_SIZE = 7168; | ||
#if defined(OC_APP_DATA_BUFFER_SIZE) || !defined(OC_REP_ENCODING_REALLOC) | ||
static size_t _OC_MIN_APP_DATA_SIZE = 7168; | ||
#else /* OC_APP_DATA_BUFFER_SIZE || !OC_REP_ENCODING_REALLOC */ | ||
static size_t _OC_MIN_APP_DATA_SIZE = 256; | ||
#endif /* !OC_APP_DATA_BUFFER_SIZE && OC_REP_ENCODING_REALLOC */ | ||
static size_t _OC_BLOCK_SIZE = 1024; // FIX | ||
|
||
int | ||
oc_set_mtu_size(size_t mtu_size) | ||
{ | ||
(void)mtu_size; | ||
#ifdef OC_INOUT_BUFFER_SIZE | ||
return -1; | ||
#else /* !OC_INOUT_BUFFER_SIZE */ | ||
#ifdef OC_BLOCK_WISE | ||
if (mtu_size < (COAP_MAX_HEADER_SIZE + 16)) { | ||
return -1; | ||
} | ||
#ifdef OC_OSCORE | ||
_OC_MTU_SIZE = mtu_size + COAP_MAX_HEADER_SIZE; | ||
#else /* OC_OSCORE */ | ||
_OC_MTU_SIZE = mtu_size; | ||
#endif /* !OC_OSCORE */ | ||
mtu_size -= COAP_MAX_HEADER_SIZE; | ||
size_t i; | ||
for (i = 10; i >= 4 && (mtu_size >> i) == 0; i--) | ||
; | ||
_OC_BLOCK_SIZE = ((size_t)1) << i; | ||
#endif /* OC_BLOCK_WISE */ | ||
return 0; | ||
#endif /* OC_INOUT_BUFFER_SIZE */ | ||
} | ||
|
||
long | ||
oc_get_mtu_size(void) | ||
{ | ||
return (long)_OC_MTU_SIZE; | ||
} | ||
|
||
void | ||
oc_set_max_app_data_size(size_t size) | ||
{ | ||
#ifdef OC_APP_DATA_BUFFER_SIZE | ||
(void)size; | ||
#else /* !OC_APP_DATA_BUFFER_SIZE */ | ||
_OC_MAX_APP_DATA_SIZE = size; | ||
#ifndef OC_REP_ENCODING_REALLOC | ||
_OC_MIN_APP_DATA_SIZE = size; | ||
#endif /* !OC_REP_ENCODING_REALLOC */ | ||
#ifndef OC_BLOCK_WISE | ||
_OC_BLOCK_SIZE = size; | ||
_OC_MTU_SIZE = size + COAP_MAX_HEADER_SIZE; | ||
#endif /* !OC_BLOCK_WISE */ | ||
#endif /* OC_APP_DATA_BUFFER_SIZE */ | ||
} | ||
|
||
long | ||
oc_get_max_app_data_size(void) | ||
{ | ||
return (long)_OC_MAX_APP_DATA_SIZE; | ||
} | ||
Danielius1922 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
void | ||
oc_set_min_app_data_size(size_t size) | ||
{ | ||
#if defined(OC_APP_DATA_BUFFER_SIZE) || !defined(OC_REP_ENCODING_REALLOC) | ||
(void)size; | ||
#else /* !OC_APP_DATA_BUFFER_SIZE && !OC_REP_ENCODING_REALLOC */ | ||
_OC_MIN_APP_DATA_SIZE = size; | ||
#endif /* OC_APP_DATA_BUFFER_SIZE || !OC_REP_ENCODING_REALLOC */ | ||
} | ||
|
||
long | ||
oc_get_min_app_data_size(void) | ||
{ | ||
return (long)_OC_MIN_APP_DATA_SIZE; | ||
} | ||
|
||
long | ||
oc_get_block_size(void) | ||
{ | ||
return (long)_OC_BLOCK_SIZE; | ||
} | ||
|
||
#else /* !OC_DYNAMIC_ALLOCATION */ | ||
|
||
int | ||
oc_set_mtu_size(size_t mtu_size) | ||
{ | ||
(void)mtu_size; | ||
OC_WRN("Dynamic memory not available"); | ||
return -1; | ||
} | ||
|
||
long | ||
oc_get_mtu_size(void) | ||
{ | ||
OC_WRN("Dynamic memory not available"); | ||
return -1; | ||
} | ||
|
||
void | ||
oc_set_max_app_data_size(size_t size) | ||
{ | ||
(void)size; | ||
OC_WRN("Dynamic memory not available"); | ||
} | ||
|
||
long | ||
oc_get_max_app_data_size(void) | ||
{ | ||
OC_WRN("Dynamic memory not available"); | ||
return -1; | ||
} | ||
|
||
void | ||
oc_set_min_app_data_size(size_t size) | ||
{ | ||
(void)size; | ||
OC_WRN("Dynamic memory not available"); | ||
} | ||
|
||
long | ||
oc_get_min_app_data_size(void) | ||
{ | ||
OC_WRN("Dynamic memory not available"); | ||
return -1; | ||
} | ||
|
||
long | ||
oc_get_block_size(void) | ||
{ | ||
OC_WRN("Dynamic memory not available"); | ||
return -1; | ||
} | ||
Danielius1922 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#endif /* OC_DYNAMIC_ALLOCATION */ |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address the
FIX
comment for_OC_BLOCK_SIZE
.The line:
includes a
// FIX
comment. This suggests that this value or implementation needs attention. Ensure that the block size is correctly calculated or defined, and remove the temporary comment once resolved.