Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
map-agent
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
map-agent
Commits
102d5a93
Commit
102d5a93
authored
2 months ago
by
Filip Matusiak
Browse files
Options
Downloads
Patches
Plain Diff
wsc: Add function to read WSC M2 md5sum from file
parent
ced27ba4
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/autoconfig.c
+77
-2
77 additions, 2 deletions
src/autoconfig.c
src/autoconfig.h
+1
-0
1 addition, 0 deletions
src/autoconfig.h
with
78 additions
and
2 deletions
src/autoconfig.c
+
77
−
2
View file @
102d5a93
...
@@ -283,11 +283,12 @@ int autoconfig_write_hash_to_file(uint8_t *macaddr, uint8_t *sha256)
...
@@ -283,11 +283,12 @@ int autoconfig_write_hash_to_file(uint8_t *macaddr, uint8_t *sha256)
}
}
/* Create sha256 string */
/* Create sha256 string */
sha256_str
=
calloc
(
sizeof
(
sha256
)
*
2
+
1
,
sizeof
(
char
));
sha256_str
=
calloc
(
SHA256_LENGTH
*
2
+
1
,
sizeof
(
char
));
if
(
!
sha256_str
)
if
(
!
sha256_str
)
goto
out_radio
;
goto
out_radio
;
btostr
(
sha256
,
sizeof
(
sha256
),
sha256_str
);
btostr
(
sha256
,
SHA256_LENGTH
,
sha256_str
);
sha256_obj
=
json_object_new_string
(
sha256_str
);
sha256_obj
=
json_object_new_string
(
sha256_str
);
if
(
!
sha256_obj
)
{
if
(
!
sha256_obj
)
{
json_object_put
(
radio_obj
);
json_object_put
(
radio_obj
);
...
@@ -312,3 +313,77 @@ out_radio:
...
@@ -312,3 +313,77 @@ out_radio:
return
0
;
return
0
;
}
}
int
autoconfig_read_hash_from_file
(
uint8_t
*
macaddr
,
uint8_t
*
sha256_out
)
{
struct
blob_buf
radios
=
{
0
};
struct
blob_attr
*
b
;
static
const
struct
blobmsg_policy
attr
[]
=
{
[
0
]
=
{
.
name
=
"radios"
,
.
type
=
BLOBMSG_TYPE_ARRAY
},
};
struct
blob_attr
*
tb
[
ARRAY_SIZE
(
attr
)];
int
rem
;
int
ret
=
0
;
blob_buf_init
(
&
radios
,
0
);
if
(
!
blobmsg_add_json_from_file
(
&
radios
,
AUTOCFG_FILE
))
{
agnt_dbg
(
LOG_APCFG
,
"Failed to parse %s
\n
"
,
AUTOCFG_FILE
);
ret
=
-
1
;
goto
out
;
}
blobmsg_parse
(
attr
,
ARRAY_SIZE
(
attr
),
tb
,
blob_data
(
radios
.
head
),
blob_len
(
radios
.
head
));
if
(
!
tb
[
0
])
{
ret
=
-
1
;
goto
out
;
}
blobmsg_for_each_attr
(
b
,
tb
[
0
],
rem
)
{
static
const
struct
blobmsg_policy
radio_attr
[
2
]
=
{
[
0
]
=
{
.
name
=
"macaddr"
,
.
type
=
BLOBMSG_TYPE_STRING
},
[
1
]
=
{
.
name
=
"sha256"
,
.
type
=
BLOBMSG_TYPE_STRING
},
};
struct
blob_attr
*
tb1
[
ARRAY_SIZE
(
radio_attr
)];
char
radio_str
[
18
]
=
{
0
};
uint8_t
radio_mac
[
6
]
=
{
0
};
char
*
sh256_str
;
int
blen
;
//char * data;
blobmsg_parse
(
radio_attr
,
ARRAY_SIZE
(
radio_attr
),
tb1
,
blobmsg_data
(
b
),
blob_len
(
b
));
if
(
!
tb1
[
0
]
||
!
tb1
[
1
])
continue
;
strncpy
(
radio_str
,
blobmsg_data
(
tb1
[
0
]),
sizeof
(
radio_str
)
-
1
);
if
(
!
hwaddr_aton
(
radio_str
,
radio_mac
))
{
agnt_dbg
(
LOG_APCFG
,
"Failed to convert macaddr %s
\n
"
,
radio_str
);
continue
;
}
if
(
memcmp
(
macaddr
,
radio_mac
,
6
))
continue
;
sh256_str
=
blobmsg_get_string
(
tb1
[
1
]);
if
(
!
sh256_str
)
{
agnt_err
(
LOG_APCFG
,
"%s: No valid sha256
\n
"
,
__func__
);
ret
=
-
1
;
break
;
}
blen
=
strlen
(
sh256_str
)
/
2
;
if
(
blen
>
SHA256_LENGTH
)
{
agnt_err
(
LOG_APCFG
,
"%s: SHA256 string too long
\n
"
,
__func__
);
ret
=
-
1
;
break
;
}
strtob
(
sh256_str
,
blen
,
sha256_out
);
}
out:
blob_buf_free
(
&
radios
);
return
ret
;
}
This diff is collapsed.
Click to expand it.
src/autoconfig.h
+
1
−
0
View file @
102d5a93
...
@@ -29,4 +29,5 @@ bool autoconfig_has_wsc_changed(struct wsc_data *wsc,
...
@@ -29,4 +29,5 @@ bool autoconfig_has_wsc_changed(struct wsc_data *wsc,
size_t
tlvs_size
,
size_t
tlvs_size
,
uint8_t
*
sha256_out
);
uint8_t
*
sha256_out
);
int
autoconfig_write_hash_to_file
(
uint8_t
*
macaddr
,
uint8_t
*
sha256
);
int
autoconfig_write_hash_to_file
(
uint8_t
*
macaddr
,
uint8_t
*
sha256
);
int
autoconfig_read_hash_from_file
(
uint8_t
*
macaddr
,
uint8_t
*
sha256_out
);
#endif
#endif
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