-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
get version number through generic netlink (#46)
* get version number through generic netlink * update format * update version number 0.6.4 Co-authored-by: ycchen <chen042531.cs03@nctu.edu.tw>
- Loading branch information
1 parent
908b5aa
commit d24405a
Showing
6 changed files
with
71 additions
and
3 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
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,47 @@ | ||
#include "genl_version.h" | ||
|
||
static int gtp5g_genl_fill_ver(struct sk_buff *skb, u32 snd_portid, u32 snd_seq, | ||
u32 type) | ||
{ | ||
void *genlh; | ||
|
||
genlh = genlmsg_put(skb, snd_portid, snd_seq, >p5g_genl_family, 0, type); | ||
if (!genlh) | ||
goto genlmsg_fail; | ||
|
||
if (nla_put_string(skb, GTP5G_VERSION, DRV_VERSION)) | ||
goto genlmsg_fail; | ||
|
||
genlmsg_end(skb, genlh); | ||
return 0; | ||
|
||
genlmsg_fail: | ||
genlmsg_cancel(skb, genlh); | ||
return -EMSGSIZE; | ||
} | ||
|
||
int gtp5g_genl_get_version(struct sk_buff *skb, struct genl_info *info) | ||
{ | ||
struct sk_buff *skb_ack; | ||
int err; | ||
|
||
skb_ack = genlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); | ||
if (!skb_ack) { | ||
rcu_read_unlock(); | ||
return -ENOMEM; | ||
} | ||
|
||
err = gtp5g_genl_fill_ver(skb_ack, | ||
NETLINK_CB(skb).portid, | ||
info->snd_seq, | ||
info->nlhdr->nlmsg_type); | ||
if (err) { | ||
kfree_skb(skb_ack); | ||
rcu_read_unlock(); | ||
return err; | ||
} | ||
|
||
rcu_read_unlock(); | ||
|
||
return genlmsg_unicast(genl_info_net(info), skb_ack, info->snd_portid); | ||
} |
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,14 @@ | ||
#ifndef __GENL_VERSION_H__ | ||
#define __GENL_VERSION_H__ | ||
|
||
#include "genl.h" | ||
|
||
#define DRV_VERSION "0.6.4" | ||
|
||
enum gtp5g_version { | ||
GTP5G_VERSION | ||
}; | ||
|
||
extern int gtp5g_genl_get_version(struct sk_buff *, struct genl_info *); | ||
|
||
#endif // __GENL_VERSION_H__ |
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