Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gateway-info
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
BBF
gateway-info
Commits
b77871a8
Commit
b77871a8
authored
2 months ago
by
Suvendhu Hansa
Browse files
Options
Downloads
Patches
Plain Diff
Added gateway discovery events
parent
26e407a2
No related branches found
No related tags found
1 merge request
!2
Added gateway discovery events
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/gatewayinfo.c
+106
-12
106 additions, 12 deletions
src/gatewayinfo.c
with
106 additions
and
12 deletions
src/gatewayinfo.c
+
106
−
12
View file @
b77871a8
...
@@ -13,36 +13,28 @@
...
@@ -13,36 +13,28 @@
static
int
get_manufacturer_oui
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
static
int
get_manufacturer_oui
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
{
{
dmuci_get_option_value_string_varstate
(
"gwinfo"
,
"gatewayinfo"
,
"oui"
,
value
);
dmuci_get_option_value_string_varstate
(
"gwinfo"
,
"gatewayinfo"
,
"oui"
,
value
);
if
(
*
value
[
0
]
==
'\0'
)
{
db_get_value_string
(
"device"
,
"deviceinfo"
,
"ManufacturerOUI"
,
value
);
}
return
0
;
return
0
;
}
}
static
int
get_product_class
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
static
int
get_product_class
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
{
{
dmuci_get_option_value_string_varstate
(
"gwinfo"
,
"gatewayinfo"
,
"class"
,
value
);
dmuci_get_option_value_string_varstate
(
"gwinfo"
,
"gatewayinfo"
,
"class"
,
value
);
if
(
*
value
[
0
]
==
'\0'
)
{
db_get_value_string
(
"device"
,
"deviceinfo"
,
"ProductClass"
,
value
);
}
return
0
;
return
0
;
}
}
static
int
get_serial_number
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
static
int
get_serial_number
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
{
{
dmuci_get_option_value_string_varstate
(
"gwinfo"
,
"gatewayinfo"
,
"serial"
,
value
);
dmuci_get_option_value_string_varstate
(
"gwinfo"
,
"gatewayinfo"
,
"serial"
,
value
);
if
(
*
value
[
0
]
==
'\0'
)
{
db_get_value_string
(
"device"
,
"deviceinfo"
,
"SerialNumber"
,
value
);
}
return
0
;
return
0
;
}
}
static
int
get_gateway_proto
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
static
int
get_gateway_proto
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
{
{
dmuci_get_option_value_string_varstate
(
"gwinfo"
,
"gatewayinfo"
,
"proto"
,
value
);
dmuci_get_option_value_string_varstate
(
"gwinfo"
,
"gatewayinfo"
,
"proto"
,
value
);
if
(
*
value
[
0
]
==
'\0'
)
{
*
value
=
dmstrdup
(
"Unknown"
);
}
return
0
;
return
0
;
}
}
...
@@ -58,6 +50,105 @@ static int get_mac_address(char *refparam, struct dmctx *ctx, void *data, char *
...
@@ -58,6 +50,105 @@ static int get_mac_address(char *refparam, struct dmctx *ctx, void *data, char *
return
0
;
return
0
;
}
}
static
event_args
unknown_gw_args
=
{
.
name
=
"gateway-info.gateway.unknown"
,
.
param
=
(
const
char
*
[])
{
"MACAddress"
,
NULL
}
};
static
int
get_event_unknown_gw
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
{
*
value
=
(
char
*
)
&
unknown_gw_args
;
return
0
;
}
static
int
event_unknown_gw
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
*
value
,
int
action
)
{
switch
(
action
)
{
case
EVENT_CHECK
:
break
;
case
EVENT_RUN
:
{
char
*
hwaddr
=
dmjson_get_value
((
json_object
*
)
value
,
1
,
"hwaddr"
);
fill_blob_param
(
&
ctx
->
bb
,
"MACAddress"
,
hwaddr
,
DMT_TYPE
[
DMT_STRING
],
0
);
break
;
}
}
return
0
;
}
static
event_args
usp_gw_args
=
{
.
name
=
"gateway-info.gateway.usp"
,
.
param
=
(
const
char
*
[])
{
"EndpointID"
,
NULL
}
};
static
int
get_event_usp_gw
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
{
*
value
=
(
char
*
)
&
usp_gw_args
;
return
0
;
}
static
int
event_usp_gw
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
*
value
,
int
action
)
{
switch
(
action
)
{
case
EVENT_CHECK
:
break
;
case
EVENT_RUN
:
{
char
*
endpoint_id
=
dmjson_get_value
((
json_object
*
)
value
,
1
,
"endpoint"
);
fill_blob_param
(
&
ctx
->
bb
,
"EndpointID"
,
endpoint_id
,
DMT_TYPE
[
DMT_STRING
],
0
);
break
;
}
}
return
0
;
}
static
event_args
cwmp_gw_args
=
{
.
name
=
"gateway-info.gateway.cwmp"
,
.
param
=
(
const
char
*
[])
{
"ManufacturerOUI"
,
"ProductClass"
,
"SerialNumber"
,
NULL
}
};
static
int
get_event_cwmp_gw
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
**
value
)
{
*
value
=
(
char
*
)
&
cwmp_gw_args
;
return
0
;
}
static
int
event_cwmp_gw
(
char
*
refparam
,
struct
dmctx
*
ctx
,
void
*
data
,
char
*
instance
,
char
*
value
,
int
action
)
{
switch
(
action
)
{
case
EVENT_CHECK
:
break
;
case
EVENT_RUN
:
{
char
*
oui
=
dmjson_get_value
((
json_object
*
)
value
,
1
,
"oui"
);
char
*
class
=
dmjson_get_value
((
json_object
*
)
value
,
1
,
"class"
);
char
*
serial
=
dmjson_get_value
((
json_object
*
)
value
,
1
,
"serial"
);
fill_blob_param
(
&
ctx
->
bb
,
"ManufacturerOUI"
,
oui
,
DMT_TYPE
[
DMT_STRING
],
0
);
fill_blob_param
(
&
ctx
->
bb
,
"ProductClass"
,
class
,
DMT_TYPE
[
DMT_STRING
],
0
);
fill_blob_param
(
&
ctx
->
bb
,
"SerialNumber"
,
serial
,
DMT_TYPE
[
DMT_STRING
],
0
);
break
;
}
}
return
0
;
}
/**********************************************************************************************************************************
/**********************************************************************************************************************************
* OBJ & PARAM DEFINITION
* OBJ & PARAM DEFINITION
***********************************************************************************************************************************/
***********************************************************************************************************************************/
...
@@ -70,6 +161,9 @@ DMLEAF tGatewayInfoParams[] = {
...
@@ -70,6 +161,9 @@ DMLEAF tGatewayInfoParams[] = {
{
"ManagementProtocol"
,
&
DMREAD
,
DMT_STRING
,
get_gateway_proto
,
NULL
,
BBFDM_USP
},
{
"ManagementProtocol"
,
&
DMREAD
,
DMT_STRING
,
get_gateway_proto
,
NULL
,
BBFDM_USP
},
{
"EndpointID"
,
&
DMREAD
,
DMT_STRING
,
get_endpoint_id
,
NULL
,
BBFDM_USP
},
{
"EndpointID"
,
&
DMREAD
,
DMT_STRING
,
get_endpoint_id
,
NULL
,
BBFDM_USP
},
{
"MACAddress"
,
&
DMREAD
,
DMT_STRING
,
get_mac_address
,
NULL
,
BBFDM_USP
},
{
"MACAddress"
,
&
DMREAD
,
DMT_STRING
,
get_mac_address
,
NULL
,
BBFDM_USP
},
{
"UnknownGatewayDiscovered!"
,
&
DMREAD
,
DMT_EVENT
,
get_event_unknown_gw
,
event_unknown_gw
,
BBFDM_USP
},
{
"USPGatewayDiscovered!"
,
&
DMREAD
,
DMT_EVENT
,
get_event_usp_gw
,
event_usp_gw
,
BBFDM_USP
},
{
"CWMPGatewayDiscovered!"
,
&
DMREAD
,
DMT_EVENT
,
get_event_cwmp_gw
,
event_cwmp_gw
,
BBFDM_USP
},
{
0
}
{
0
}
};
};
...
...
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