Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ieee1905
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Multi-AP
ieee1905
Commits
1a662da8
Commit
1a662da8
authored
4 years ago
by
Anjan Chanda
Browse files
Options
Downloads
Patches
Plain Diff
clone unfragmented cmdu with cmdu_clone()
parent
d4dc61f4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cmdu.c
+33
-30
33 additions, 30 deletions
src/cmdu.c
src/cmdu.h
+1
-0
1 addition, 0 deletions
src/cmdu.h
with
34 additions
and
30 deletions
src/cmdu.c
+
33
−
30
View file @
1a662da8
...
...
@@ -195,8 +195,8 @@ struct cmdu_buff *cmdu_alloc_simple(uint16_t type, uint16_t *mid)
}
f
->
cdata
=
(
struct
cmdu_linear
*
)(
f
->
head
+
18
);
if
(
type
<=
CMDU_TYPE_MAX
)
cmdu_set_type
(
f
,
type
);
//
if (type <= CMDU_TYPE_MAX)
cmdu_set_type
(
f
,
type
);
if
(
*
mid
==
0
)
*
mid
=
cmdu_get_next_mid
();
...
...
@@ -241,34 +241,6 @@ int cmdu_reserve(struct cmdu_buff *c, size_t s)
int
cmdu_copy_tlvs_linear
(
struct
cmdu_buff
*
c
,
uint8_t
*
tlvs
,
uint32_t
tlvslen
)
{
#if 0
struct cmdu *n;
if (!is_cmdu_type_valid(type))
return NULL;
//if (!is_tlv_stream_valid(type, tlvs, tlvslen))
// return NULL;
n = calloc(1, sizeof(*n) + tlvslen * sizeof(uint8_t));
if (!n)
return NULL;
n->hdr.version = 0;
n->hdr.type = type;
if (*mid == 0)
*mid = cmdu_get_next_mid();
n->hdr.mid = *mid;
if (cmdu_should_relay(type))
CMDU_SET_RELAY_MCAST(n);
#endif
if
(
c
->
end
-
c
->
tail
<
tlvslen
)
return
-
1
;
...
...
@@ -307,6 +279,37 @@ struct cmdu_buff *cmdu_alloc_custom(uint16_t type, uint16_t *mid, char *ifname,
return
f
;
}
struct
cmdu_buff
*
cmdu_clone
(
struct
cmdu_buff
*
frm
)
{
struct
cmdu_buff
*
f
;
int
len
;
if
(
!
frm
||
!
frm
->
cdata
)
{
fprintf
(
stderr
,
"%s: cmdu for cloning is invalid!
\n
"
,
__func__
);
return
NULL
;
}
len
=
cmdu_size
(
frm
);
f
=
cmdu_alloc
(
len
);
if
(
!
f
)
{
fprintf
(
stderr
,
"%s: -ENOMEM
\n
"
,
__func__
);
return
NULL
;
}
f
->
cdata
=
(
struct
cmdu_linear
*
)(
f
->
head
+
18
);
f
->
data
=
(
uint8_t
*
)(
f
->
cdata
+
1
);
f
->
datalen
=
frm
->
datalen
;
f
->
tail
=
f
->
data
+
f
->
datalen
;
memcpy
(
f
->
cdata
,
frm
->
cdata
,
len
);
memcpy
(
f
->
dev_macaddr
,
frm
->
dev_macaddr
,
6
);
strncpy
(
f
->
dev_ifname
,
frm
->
dev_ifname
,
15
);
memcpy
(
f
->
origin
,
frm
->
origin
,
6
);
return
f
;
}
int
cmdu_copy_tlvs
(
struct
cmdu_buff
*
c
,
struct
tlv
*
tv
[],
int
tv_arrsize
)
{
uint16_t
tlvslen
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/cmdu.h
+
1
−
0
View file @
1a662da8
...
...
@@ -174,6 +174,7 @@ int cmdu_parse_tlvs(struct cmdu_buff *c, struct tlv *tv[][16],
int
cmdu_copy_tlvs_linear
(
struct
cmdu_buff
*
c
,
uint8_t
*
tlvs
,
uint32_t
tlvslen
);
int
cmdu_copy_tlvs
(
struct
cmdu_buff
*
c
,
struct
tlv
*
tv
[],
int
tv_arrsize
);
struct
cmdu_buff
*
cmdu_clone
(
struct
cmdu_buff
*
frm
);
struct
tlv
*
cmdu_reserve_tlv
(
struct
cmdu_buff
*
c
,
uint16_t
tlv_datalen
);
int
cmdu_put_tlv
(
struct
cmdu_buff
*
c
,
struct
tlv
*
t
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment