From c376a9bd40700ede19ddfc9abdc457c72bb024b1 Mon Sep 17 00:00:00 2001 From: shaozhimin Date: Tue, 1 Aug 2023 10:35:15 +0800 Subject: [PATCH] =?UTF-8?q?fix=20bug=20184351=20184469=EF=BC=9Bupdate=20ch?= =?UTF-8?q?angelog=EF=BC=9B=E5=88=A0=E9=99=A4=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/changelog | 8 + src/disk/libkydiskinfo.c | 10 +- src/hardware/libkybluetooth.c | 34 +- src/hardware/libkydisplay.c | 2 +- src/hardware/libkyedid.c | 226 +++++---- src/hardware/test/kyedid-test.c | 14 +- .../kysdk接口封装规范.md | 435 ------------------ src/net/libkynetinfo.c | 2 + 8 files changed, 181 insertions(+), 550 deletions(-) delete mode 100644 src/libkysdk-system-javascript-websocket/kysdk接口封装规范.md diff --git a/debian/changelog b/debian/changelog index 394258f..c474f72 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +libkysdk-system (2.2.3.5-0k0.8) yangtze; urgency=medium + + *Bug号:184351 184469 + *需求号: + *其他修改: + + -- szm-min Tue, 01 Aug 2023 10:29:00 +0800 + libkysdk-system (2.2.3.5-0k0.7) yangtze; urgency=medium *Bug号:181529 184238 180502 184351 diff --git a/src/disk/libkydiskinfo.c b/src/disk/libkydiskinfo.c index 8289bdc..5ac429a 100644 --- a/src/disk/libkydiskinfo.c +++ b/src/disk/libkydiskinfo.c @@ -590,6 +590,7 @@ char* kdk_get_hard_disk_size(const char *hardname) { return NULL; } + memset(hard_size, 0, 128); kdk_diskinfo *sdainfo = kdk_get_diskinfo(hardname); if (!sdainfo) { @@ -598,6 +599,11 @@ char* kdk_get_hard_disk_size(const char *hardname) } sprintf(hard_size,"%f",sdainfo->total_size_MiB); kdk_free_diskinfo(sdainfo); + if(strlen(hard_size) == 0) + { + free(hard_size); + return NULL; + } return hard_size; } @@ -615,6 +621,7 @@ char* kdk_get_hard_fwrev(const char *hardname) { return NULL; } + memset(hard_fwrev, 0, 128); kdk_diskinfo *sdainfo = kdk_get_diskinfo(hardname); if (!sdainfo) @@ -642,7 +649,7 @@ char* kdk_get_hard_fwrev(const char *hardname) } } pclose(fp); - if(fwrev) + if(fwrev[0] != '\0') { strcpy(hard_fwrev, fwrev); } @@ -752,6 +759,7 @@ char* kdk_get_hard_serial(const char *hardname) { return NULL; } + memset(hard_serial, 0, 128); char line[256] = "\0"; char path[128] = "\0"; char tmp[1024] = "\0"; diff --git a/src/hardware/libkybluetooth.c b/src/hardware/libkybluetooth.c index ffc0d6f..015e154 100644 --- a/src/hardware/libkybluetooth.c +++ b/src/hardware/libkybluetooth.c @@ -186,6 +186,10 @@ char* kdk_bluetooth_get_name(int id) char name[249]; int i; char *version = (char *)malloc(sizeof(char) * 64); + if(!version) + { + return NULL; + } if ((ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) { @@ -226,7 +230,7 @@ char* kdk_bluetooth_get_address(int id) { int ctl; static struct hci_dev_info di; - char addr[18]; + char addr[18] = "\0"; char *address = (char *)malloc(sizeof(char) * 64); if ((ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) @@ -244,7 +248,7 @@ char* kdk_bluetooth_get_address(int id) } ba2str(&di.bdaddr, addr); - if(addr) + if(addr[0] != '\0') { strcpy(address, addr); return address; @@ -257,10 +261,14 @@ char* kdk_bluetooth_get_address(int id) char* kdk_bluetooth_get_link_mode(int id) { - char *str; + char *str = NULL; int ctl; static struct hci_dev_info di; char *link_mode = (char *)malloc(sizeof(char) * 64); + if(!link_mode) + { + return NULL; + } if ((ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) { @@ -293,6 +301,10 @@ char* kdk_bluetooth_get_link_policy(int id) int ctl; static struct hci_dev_info di; char *link_policy = (char *)malloc(sizeof(char) * 64); + if(!link_policy) + { + return NULL; + } if ((ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) { @@ -317,6 +329,10 @@ char* kdk_bluetooth_get_bus(int id) int ctl; static struct hci_dev_info di; char *bus = (char *)malloc(sizeof(char) * 64); + if(!bus) + { + return NULL; + } if ((ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) { @@ -343,6 +359,10 @@ char* kdk_bluetooth_get_scomtu(int id) char addr[18]; char tmp[20] = "\0"; char *scomtu = (char *)malloc(sizeof(char) * 64); + if(!scomtu) + { + return NULL; + } if ((ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) { @@ -370,6 +390,10 @@ char* kdk_bluetooth_get_alcmtu(int id) static struct hci_dev_info di; char tmp[20] = "\0"; char *alcmtu = (char *)malloc(sizeof(char) * 64); + if(!alcmtu) + { + return NULL; + } if ((ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) { @@ -397,6 +421,8 @@ char* kdk_bluetooth_get_packettype(int id) static struct hci_dev_info di; char *packettype = (char *)malloc(sizeof(char) * 64); + if(!packettype) + return NULL; if ((ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) { @@ -423,6 +449,8 @@ char* kdk_bluetooth_get_features(int id) static struct hci_dev_info di; char tmp[50] = "\0"; char *features = (char *)malloc(sizeof(char) * 64); + if(!features) + return NULL; if ((ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) { diff --git a/src/hardware/libkydisplay.c b/src/hardware/libkydisplay.c index 901611f..e0301e1 100644 --- a/src/hardware/libkydisplay.c +++ b/src/hardware/libkydisplay.c @@ -14,7 +14,7 @@ char *display_get_info(char *str) klog_err("内存申请失败:%s\n", strerror(errno)); return NULL; } - memset(display, 0, sizeof(display)); + memset(display, 0, 512); char buf[1024] = {0}; memset(buf, 0, sizeof(buf)); int i = 0; diff --git a/src/hardware/libkyedid.c b/src/hardware/libkyedid.c index 90b9cc9..529b841 100644 --- a/src/hardware/libkyedid.c +++ b/src/hardware/libkyedid.c @@ -15,7 +15,7 @@ static int edid_lines = 0; -static int claims_one_point_oh = 0; +// static int claims_one_point_oh = 0; static int claims_one_point_two = 0; static int claims_one_point_three = 0; static int claims_one_point_four = 0; @@ -25,8 +25,8 @@ static char* get_val_from_file(FILE *fp, const char *key) if (! fp) return NULL; char *val = NULL; - char buf[1024] = {0}; - while (fgets(buf, 1024, fp)) + char buf[2048] = {0}; + while (fgets(buf, 2048, fp)) { if (strncmp(buf, key, strlen(key)) == 0) { @@ -56,8 +56,11 @@ int verify_file(char *pFileName) void kdk_edid(char *name) { char edid_text[2048] = "\0"; - char *edid_character = (char *)malloc(sizeof(char) * 512); - char temp[512] = "\0"; + char *edid_character = (char *)malloc(sizeof(char) * 1024); + if(!edid_character) + { + return; + } FILE *pipeLine = popen("xrandr --prop", "r"); // 建立流管道 if (!pipeLine) { @@ -116,13 +119,7 @@ char **kdk_edid_get_interface() XRROutputInfo *info; int iscres; int icrtc; - char name[100]; - char *tmp = (char *)malloc(100 * sizeof(char)); - if (!tmp) - { - klog_err("内存申请失败:%s\n", strerror(errno)); - return NULL; - } + char tmp[128] = "\0"; char **res = NULL; int count = 0; char test[100] = {0}; @@ -138,7 +135,7 @@ char **kdk_edid_get_interface() { for (icrtc = info->ncrtc; icrtc > 0;) { - memset(tmp, 0, 100 * sizeof(char)); + memset(tmp, 0, sizeof(tmp)); if (strstr(test, info->name)) { @@ -146,12 +143,10 @@ char **kdk_edid_get_interface() } else { - strcpy(name, info->name); - strcat(tmp, name); + strcpy(tmp, info->name); + strcpy(test, tmp); --icrtc; } - strcat(test, tmp); - strcat(test, ","); res = realloc(res, (count + 1) * sizeof(char *)); if (!res) @@ -172,14 +167,10 @@ char **kdk_edid_get_interface() XRRFreeOutputInfo(info); } XRRFreeScreenResources(screen); - free(tmp); res[count] = NULL; goto out; err_out: -#ifdef __linux__ - free(tmp); -#endif while (count) { free(res[count - 1]); @@ -425,15 +416,15 @@ const float kdk_edid_get_gamma(char *name) } int fd; unsigned char *edid; - char path[128] = "\0"; + char path[512] = "\0"; DIR *dirfd = NULL; struct dirent *direfd = NULL; float ga = 0.00; char canonical_filename[100] = "\0"; char filename[100] = "\0"; - char edid_text[24] = "\0"; - char num[24] = "\0"; - char line[11520] = "\0"; + // char edid_text[24] = "\0"; + // char num[24] = "\0"; + // char line[11520] = "\0"; char str_name[32] = "\0"; strcpy(str_name, name); dirfd = opendir("/sys/class/drm"); @@ -552,13 +543,13 @@ float kdk_edid_get_size(char *name) } int fd; unsigned char *edid; - char path[128] = "\0"; + char path[512] = "\0"; DIR *dirfd = NULL; struct dirent *direfd = NULL; char canonical_filename[100] = "\0"; float size = 0.00; char filename[100] = "\0"; - char edid_text[24] = "\0"; + // char edid_text[24] = "\0"; char str_name[32] = "\0"; strcpy(str_name, name); @@ -677,17 +668,18 @@ char *kdk_edid_get_max_resolution(char *name) return NULL; } char edid_text[2048] = "\0"; - char tmp[32] = "\0"; - char *res = (char *)malloc(sizeof(char) * 32); + char tmp[64] = "\0"; + char *res = (char *)malloc(sizeof(char) * 64); if(!res) { return NULL; } + memset(res, 0, 64); FILE *pipeLine = popen("xrandr --prop", "r"); // 建立流管道 if (!pipeLine) { free(res); - return; + return NULL; } int i = 0; while(fgets(edid_text, sizeof(edid_text), pipeLine)) @@ -698,16 +690,21 @@ char *kdk_edid_get_max_resolution(char *name) { i = 1; } - else{ - continue; - } + continue; } if(strstr(edid_text, "+")) { - strcpy(tmp, edid_text); + strncpy(tmp, edid_text, 63); } + } + pclose(pipeLine); sscanf(tmp, "%s", res); + if(strlen(res) == 0) + { + free(res); + return NULL; + } return res; } @@ -782,25 +779,32 @@ char *kdk_edid_get_model(char *name) return NULL; } int fd; - unsigned char *edid; - char path[128] = "\0"; - char str_path[256] = "\0"; + // unsigned char *edid; + char path[512] = "\0"; + char str_path[600] = "\0"; DIR *dirfd = NULL; struct dirent *direfd = NULL; char canonical_filename[100] = "\0"; char filename[100] = "\0"; - char edid_text[24] = "\0"; - char *model = NULL; + char *edid_text = NULL; + char *model = (char *) malloc(128 *sizeof(char)); + if(!model) + { + return NULL; + } + memset(model, 0, 128); char str_name[32] = "\0"; strcpy(str_name, name); dirfd = opendir("/sys/class/drm"); if (!dirfd) { + free(model); return NULL; } char **fg = strsplit(str_name, '-'); if (!fg) { + free(model); closedir(dirfd); return NULL; } @@ -817,81 +821,70 @@ char *kdk_edid_get_model(char *name) if (!realpath(path, canonical_filename) || !verify_file(canonical_filename) \ || (fd = open(canonical_filename, O_RDONLY)) == -1) { - // close(fd); kdk_edid(name); if (!realpath("/tmp/sdk-edid", filename) || !verify_file(filename)) { + free(model); return NULL; } FILE *fs = fopen(filename, "r"); if(!fs) { + free(model); return NULL; } fclose(fs); FILE *fp = popen("edid-decode /tmp/sdk-edid", "r"); if(!fp) { + free(model); return NULL; } - model = get_val_from_file(fp, "Display Product Name"); - if(model) + edid_text = get_val_from_file(fp, "Display Product Name"); + if(!edid_text) { - strstripspace(model); - pclose(fp); - return model; + char *str_model = get_val_from_file(fp, "Alphanumeric Data String"); + if(!str_model) + { + goto err_out; + } + else{ + strcpy(model, str_model); + } } + else{ + strcpy(model, edid_text); + } + + if(strlen(model) == 0) + { + goto err_out; + } + strstripspace(model); + pclose(fp); + return model; } sprintf(str_path, "edid-decode %s", path); FILE *fp = popen(str_path, "r"); if(!fp) { - return NULL; + goto err_out; } - model = get_val_from_file(fp, "Display Product Name"); - if(model) + edid_text = get_val_from_file(fp, "Display Product Name"); + if(!edid_text) { - strstripspace(model); - } - pclose(fp); - if(!model) - { - // close(fd); - kdk_edid(name); - if (!realpath("/tmp/sdk-edid", filename) || !verify_file(filename)) + char *str_model = get_val_from_file(fp, "Alphanumeric Data String"); + if(!str_model) { - return NULL; - } - FILE *fs = fopen(filename, "r"); - if(!fs) - { - return NULL; - } - fclose(fs); - FILE *fp = popen("edid-decode /tmp/sdk-edid", "r"); - if(!fp) - { - return NULL; - } - char *src_model = get_val_from_file(fp, "Alphanumeric Data String"); - pclose(fp); - if(src_model) - { - strstripspace(src_model); - return src_model; - } - else{ hd_data_t *hd_data; hd_data = (hd_data_t *)calloc(1, sizeof *hd_data); if(!hd_data) - return NULL; - char *src_model = (char *)malloc(sizeof(char) * 512); - if (!src_model) { - free(hd_data); - return NULL; + goto err_out; } + char src_model[128] = "\0"; + memset(src_model, 0, 128); hd_data->progress = NULL; hd_data->debug = ~(HD_DEB_DRIVER_INFO | HD_DEB_HDDB); @@ -903,15 +896,35 @@ char *kdk_edid_get_model(char *name) if(hd->model) { strcpy(src_model, hd->model); - free(hd_data); - return src_model; } } free(hd_data); - free(src_model); + if(strlen(src_model) == 0) + { + goto err_out; + } + else{ + strcpy(model, src_model); + } + } + else{ + strcpy(model, str_model); } } + else{ + strcpy(model, edid_text); + } + if(strlen(model) == 0) + { + goto err_out; + } + strstripspace(model); + pclose(fp); return model; +err_out: + free(model); + pclose(fp); + return NULL; } char *kdk_edid_get_visible_area(char *name) @@ -922,17 +935,17 @@ char *kdk_edid_get_visible_area(char *name) } int fd; unsigned char *edid; - char path[128] = "\0"; + char path[512] = "\0"; DIR *dirfd = NULL; struct dirent *direfd = NULL; char canonical_filename[100] = "\0"; char tmp[20] = "\0"; char filename[100] = "\0"; - char edid_text[24] = "\0"; + // char edid_text[24] = "\0"; char str_name[32] = "\0"; strcpy(str_name, name); - char *area = (char *)malloc(sizeof(char) * 20); + char *area = (char *)malloc(sizeof(char) * 32); if (!area) { klog_err("内存申请失败:%s\n", strerror(errno)); @@ -1078,7 +1091,7 @@ char *kdk_edid_get_manufacturer(char *name) } int fd; unsigned char *edid; - char path[128] = "\0"; + char path[512] = "\0"; DIR *dirfd = NULL; struct dirent *direfd = NULL; char canonical_filename[100] = "\0"; @@ -1091,6 +1104,7 @@ char *kdk_edid_get_manufacturer(char *name) { return NULL; } + memset(manufacturer, 0, 128); dirfd = opendir("/sys/class/drm"); if (!dirfd) @@ -1148,8 +1162,16 @@ char *kdk_edid_get_manufacturer(char *name) free(manufacturer); return NULL; } - char tmp[16] = "\0"; + char tmp[128] = "\0"; sscanf(msize, "%s", tmp); + if(tmp[0] == '\0') + { + free(msize); + closedir(dirfd); + pclose(fp); + free(manufacturer); + return NULL; + } strcpy(manufacturer, tmp); free(msize); closedir(dirfd); @@ -1201,7 +1223,7 @@ int kdk_edid_get_week(char *name) } int fd; unsigned char *edid; - char path[128] = "\0"; + char path[512] = "\0"; DIR *dirfd = NULL; struct dirent *direfd = NULL; char canonical_filename[100] = "\0"; @@ -1336,7 +1358,7 @@ int kdk_edid_get_year(char *name) } int fd; unsigned char *edid; - char path[128] = "\0"; + char path[512] = "\0"; DIR *dirfd = NULL; struct dirent *direfd = NULL; char canonical_filename[100] = "\0"; @@ -1511,6 +1533,7 @@ char *kdk_edid_get_resolution(char *name) { return NULL; } + memset(resolution, 0, 20); disp = XOpenDisplay(0); screen = XRRGetScreenResources(disp, DefaultRootWindow(disp)); @@ -1540,6 +1563,11 @@ char *kdk_edid_get_resolution(char *name) XRRFreeOutputInfo(info); } XRRFreeScreenResources(screen); + if(strlen(resolution) == 0) + { + free(resolution); + return NULL; + } return resolution; } @@ -1613,17 +1641,17 @@ char* kdk_edid_get_character(char *name) return NULL; } FILE *fd = NULL; - char *chater = (char *)malloc(sizeof(char) * 1024); + char *chater = (char *)malloc(sizeof(char) * 2048); if(!chater) { return NULL; } - char path[128] = "\0"; + char path[512] = "\0"; DIR *dirfd = NULL; struct dirent *direfd = NULL; char canonical_filename[100] = "\0"; - unsigned char buf[512] = "\0"; - char hex[1024] = "\0"; + unsigned char buf[2048] = "\0"; + char hex[2048] = "\0"; char str_name[32] = "\0"; strcpy(str_name, name); @@ -1657,6 +1685,10 @@ char* kdk_edid_get_character(char *name) free(chater); char edid_text[2048] = "\0"; char *edid_character = (char *)malloc(sizeof(char) * 2048); + if(!edid_character) + { + return NULL; + } FILE *pipeLine = popen("xrandr --prop", "r"); // 建立流管道 if (!pipeLine) { @@ -1664,7 +1696,7 @@ char* kdk_edid_get_character(char *name) return NULL; } int i = 0; - memset(edid_character, 0, sizeof(edid_character)); + memset(edid_character, 0, 2048); while(fgets(edid_text, sizeof(edid_text), pipeLine)) { if(i != 1) diff --git a/src/hardware/test/kyedid-test.c b/src/hardware/test/kyedid-test.c index cc8f992..ac52409 100644 --- a/src/hardware/test/kyedid-test.c +++ b/src/hardware/test/kyedid-test.c @@ -6,18 +6,6 @@ int main() { char** name = kdk_edid_get_interface(); size_t count = 0; - // float gamma = 0.00; - // float size = 0.00; - // char* max_resolution = NULL; - // char* model = NULL; - // char *area = NULL; - // char *manufacturer = NULL; - // int week; - // int year; - // int primary; - // char* resolution = NULL; - // char *ratio = NULL; - // char *character = NULL; while (name[count]) { printf("当前接口 = %s\n", name[count]); @@ -61,4 +49,4 @@ int main() } kdk_edid_freeall(name); return 0; -} \ No newline at end of file +} diff --git a/src/libkysdk-system-javascript-websocket/kysdk接口封装规范.md b/src/libkysdk-system-javascript-websocket/kysdk接口封装规范.md deleted file mode 100644 index 6af8270..0000000 --- a/src/libkysdk-system-javascript-websocket/kysdk接口封装规范.md +++ /dev/null @@ -1,435 +0,0 @@ -# 系统能力SDK -## 分辨率 -**服务名称:** com.kylin.kysdk.service - -**路径名称:** /com/kylin/kysdk/resolution/ - -**接口名称:** com.kylin.kysdk.resolution - - Methods: - 1. QStringList getSysLegalResolution(void) - 输出:屏幕,屏幕设置的分辨率,屏幕支持的分辨率 - -**JS接口:** - URL: - 1. 127.0.0.1:8090/resolution/getSysLegalResolution - 网页返回值:{"Result":0,"ResultMessage":["Arial","Helvetica","Times","Courier"]} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getSysLegalResolution()方法输出的信息 - ---- -## 网络连接 -**服务名称:** com.kylin.kysdk.service - -**路径名称:** /com/kylin/kysdk/netLink/ - -**接口名称:** com.kylin.kysdk.netLink - - Methods: - 1. unsigned int getNetState(void) - 输出: 网络连接状态 - -**JS接口:** - URL: - 1. 127.0.0.1:8090/netLink/getNetState - 网页返回值:{"Result":0,"ResultMessage":60} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getNetState()方法输出的信息 - - ---- -## 外设打印 -**服务名称:** com.kylin.kysdk.service - -**路径名称:** /com/kylin/kysdk/print/ - -**接口名称:** com.kylin.kysdk.print - - Methods: - 1. print - 应用程序打印文档、图片 - in: string - out: bool ---- -## 外设设备枚举 -**服务名称:** com.kylin.kysdk.service - -**路径名称:** /com/kylin/kysdk/peripheralsenum/ - -**接口名称:** com.kylin.kysdk.peripheralsenum - - Methods: - 1. QStringList getAllUsbInfo(void) - 输出:所有usb设备的名称、类型、PID、VID、序列号、设备节点(若没有对应信息,输出null) - -**JS接口:** - URL: - 1. 127.0.0.1:8090/peripheralsenum/getAllUsbInfo - 网页返回值:{"Result":0,"ResultMessage":["bing","hausd"]} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getAllUsbInfo()方法输出的信息 ---- -## 网卡信息 -**服务名称:** com.kylin.kysdk.service - -**路径名称:** /com/kylin/kysdk/netcard/ - -**接口名称:** com.kylin.kysdk.netcard - - Methods: - 1. QStringList getNetCardName(void) - 输出:所有网卡的名称 - 2. int getNetCardType(QString netCardName) - 输入:网卡名称 - 输出:网卡类型,有线(0)/无线(1) - 3. QStringList getNetCardProduct(QString netCardName) - 输入:网卡名称 - 输出:厂商,型号 - -**JS接口:** - URL: - 1. 127.0.0.1:8090/netcard/getNetCardName - 网页返回值:{"Result":0,"ResultMessage":["sit0"]} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getNetCardName()方法输出的信息 - - 2. 127.0.0.1:8090/netcard/getNetCardType?netCardName=test - 网页返回值:{"Result":0,"ResultMessage":0} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getNetCardType(QString netCardName)方法输出的信息,URL中“?”之后为参数netCardName, - 并给netCardName参数赋值为“test” - - 3. 127.0.0.1:8090/netcard/getNetCardProduct?netCardName=test - 网页返回值:{"Result":0,"ResultMessage":["netCardName","vendor","product"]} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getNetCardProduct(QString netCardName)方法输出的信息,URL中“?”之后为参数netCardName, - 并给netCardName参数赋值为“test” ---- -## BIOS信息 -**服务名称:** com.kylin.kysdk.service - -**路径名称:** /com/kylin/kysdk/bios/ - -**接口名称:** com.kylin.kysdk.bios - - Methods: - 1. QStringList getBiosVendorVersion(void) - 输出:BIOS厂商,版本号 - -**JS接口:** - URL: - 1. 127.0.0.1:8090/bios/getBiosVendorVersion - 网页返回值:{"Result":0,"ResultMessage":["Vendor: LENOVO","Version: 7VET87WW (3.17 )","Release Date: 07/30/2010","Address: 0xE0000","Runtime Size: 128 kB"]} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getBiosVendorVersion()方法输出的信息 - ---- -## 主板信息 -**服务名称:** com.kylin.kysdk.service - -**路径名称:** /com/kylin/kysdk/mainboard/ - -**接口名称:** com.kylin.kysdk.mainboard - - Methods: - 1. QString getMainboardName(void) - 输出:主板型号 - 2. QString getMainboardDate(void) - 输出:发布日期 - 3. QString getMainboardSerial(void) - 输出:主板序列号 - 4. QString getMainboardVendor(void) - 输出:主板厂商 - -**JS接口:** - URL: - 1. 127.0.0.1:8090/mainboard/getMainboardName - 网页返回值:{"Result":0,"ResultMessage":"Intel Corporation"} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getMainboardName()方法输出的信息 - - 2. 127.0.0.1:8090/mainboard/getMainboardDate - 网页返回值:{"Result":0,"ResultMessage":"8570 / R7 240/340"} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getMainboardDate()方法输出的信息 - - 3. 127.0.0.1:8090/mainboard/getMainboardSerial - 网页返回值:{"Result":0,"ResultMessage":"AZPM61102417"} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getMainboardSerial()方法输出的信息 - - 4. 127.0.0.1:8090/mainboard/getMainboardVendor - 网页返回值:{"Result":0,"ResultMessage":"DMI type 2, 20 bytes."} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getMainboardVendor()方法输出的信息 - ---- -## 磁盘 -**服务名称:** com.kylin.kysdk.service - -**路径名称:** /com/kylin/kysdk/disk/ - -**接口名称:** com.kylin.kysdk.disk - - - Methods: - 1. QString getDiskType(QString) - 输入:指定磁盘 - 输出:磁盘类型,机械(DISK_TYPE_HDD)/固态(DISK_TYPE_SSD)/其他(DISK_TYPE_OTHER) - 2. QString getDiskVersion(QString diskname) - 输入:指定磁盘 - 输出:固件版本信息 - 3. unsigned int getDiskSpeed(QString diskname) - 输入:指定磁盘 - 输出:返回磁盘转速 - 4. unsigned long long getDiskSectorNum(QString diskname) - 输入:指定磁盘 - 输出:返回磁盘扇区数量 - -**JS接口:** - URL: - 1. 127.0.0.1:8090/disk/getDiskType?diskname=test - 网页返回值:{"Result":0,"ResultMessage":"DISK_TYPE_SSD"} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getDiskType(QString diskname)方法输出的信息,URL中“?”之后为参数diskname, - 并给diskname参数赋值为“test” - - 2. 127.0.0.1:8090/disk/getDiskVersion?diskname=test - 网页返回值:{"Result":0,"ResultMessage":"CT500MX500SSD1M3CR"} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getDiskVersion(QString diskname)方法输出的信息,URL中“?”之后为参数diskname, - 并给diskname参数赋值为“test” - - 3. 127.0.0.1:8090/disk/getDiskSpeed?diskname=test - 网页返回值:{"Result":0,"ResultMessage":"5400"} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getDiskSpeed(QString diskname)方法输出的信息,URL中“?”之后为参数diskname, - 并给diskname参数赋值为“test” - - 4. 127.0.0.1:8090/disk/getDiskSectorNum?diskname=test - 网页返回值:{"Result":0,"ResultMessage":"12345678900"} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getDiskSectorNum(QString diskname)方法输出的信息,URL中“?”之后为参数diskname, - 并给diskname参数赋值为“test” - ---- -## 网络 -**服务名称:** com.kylin.kysdk.service - -**路径名称:** /com/kylin/kysdk/net/ - -**接口名称:** com.kylin.kysdk.net - - Methods:获取端口状态,网关信息,防火墙状态 - 1. int getPortState(int port) - 输入:端口号 - 输出:端口状态 - (0-FREE, 1-TCP_ESTABLISHED, 2-TCP_SYN_SENT, 3-TCP_SYN_RECV, - 4-TCP_FIN_WAIT1, 5-TCP_FIN_WAIT2, 6-TCP_TIME_WAIT, 7-TCP_CLOSE, 8-TCP_CLOSE_WAIT, 9-TCP_LAST_ACL, 10-TCP_LISTEN, 11-TCP_CLOSING) - 2. QStringList getGatewayInfo(void) - 输出:网关信息-名称,地址 - 3. getFirewallState? - -**JS接口:** - URL: - 1. 127.0.0.1:8090/net/getPortState?port=12345 - 网页返回值:{"Result":0,"ResultMessage":6} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getPortState(int port)方法输出的信息,URL中“?”之后为参数port, - 并给port参数赋值为12345 - - 2. 127.0.0.1:8090/net/getGatewayInfo - 网页返回值:{"Result":0,"ResultMessage":["WIFI","Address"]} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getGatewayInfo)方法输出的信息 - ---- -## 运行时信息 -**服务名称:** com.kylin.kysdk.service - -**路径名称:** /com/kylin/kysdk/runinfo/ - -**接口名称:** com.kylin.kysdk.runinfo - - Methods: - 1. double getIoSpeed(void) - 输出:实时IO读写速率 - 2. double getNetSpeed(void) - 输出:实时网速 - 3. double getMainboardTemperature(void) - 输出:实时主板温度? - 4. double getCpuTemperature(void) - 输出:实时CPU温度 - 5. double getDiskTemperature(QString diskpath) - 输入:硬盘绝对路径 - 输出:实时硬盘温度 - -**JS接口:** - URL: - 1. 127.0.0.1:8090/runinfo/getIoSpeed - 网页返回值:{"Result":0,"ResultMessage":0} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getIoSpeed()方法输出的信息 - - 2. 127.0.0.1:8090/runinfo/getNetSpeed - 网页返回值:{"Result":0,"ResultMessage":0} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getNetSpeed()方法输出的信息 - - 3. 127.0.0.1:8090/runinfo/getMainboardTemperature - 网页返回值:{"Result":0,"ResultMessage":0} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getMainboardTemperature()方法输出的信息 - - 4. 127.0.0.1:8090/runinfo/getCpuTemperature - 网页返回值:{"Result":0,"ResultMessage":67} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getCpuTemperature()方法输出的信息 - - 5. 127.0.0.1:8090/runinfo/getDiskTemperature?diskpath=test - 网页返回值:{"Result":0,"ResultMessage":-1} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getDiskTemperature(QString diskpath)方法输出的信息,URL中“?”之后为参数diskpath, - 并给diskpath参数赋值为"test" - ---- -## 地理位置 -**服务名称:** com.kylin.kysdk.service - -**路径名称:** /com/kylin/kysdk/gps/ - -**接口名称:** com.kylin.kysdk.gps - - Methods: - 1. QString getGPSInfo(void) - 输出:国家城市经纬度 - -**JS接口:** - URL: - 1. 127.0.0.1:8090/gps/getGPSInfo - 网页返回值:{"Result":0,"ResultMessage":"117:10E,39:10N"} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getGPSInfo()方法输出的信息 - ---- -## 进程信息 -**服务名称:** com.kylin.kysdk.service - -**路径名称:** /com/kylin/kysdk/process/ - -**接口名称:** com.kylin.kysdk.process - - Methods: - 1. double getProcInfoCpuUsage(int pid) - 输入:进程号 - 输出:CPU瞬时使用率 - 2. double getProcInfoIoUsage(int pid) - 输入:进程号 - 输出:IO使用率 - 3. double getProcInfoMemUsage(int pid) - 输入:进程号 - 输出:内存占用率 - 4. QString getProcInfoStatus(int pid) - 输入:进程号 - 输出:进程状态 - 5. int getProcInfoPort(int pid) - 输入:进程号 - 输出:进程使用的端口号 - 6. QString getProcInfoStartTime(int pid) - 输入:进程号 - 输出:进程的启动时间 - 7. QString getProcInfoRunningTime(int pid) - 输入:进程号 - 输出:进程的运行时间 - 8. QString getProcInfoCpuTime(int pid) - 输入:进程号 - 输出:CPU时间 - 9. QString getProcInfoCmd(int pid) - 输入:进程号 - 输出:cmd - 10. QString getProcInfoUser(int pid) - 输入:进程号 - 输出:属主 - 11. QStringList getProcInfo(QString processname) - 输入:进程名 - 输出:某进程所有信息 - -**JS接口:** - URL: - 1. 127.0.0.1:8090/process/getProcInfoCpuUsage?pid=3009 - 网页返回值:{"Result":0,"ResultMessage":0} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getProcInfoCpuUsage(int pid)方法输出的信息,URL中“?”之后为参数pid, - 并给pid参数赋值为3009 - 2. 127.0.0.1:8090/process/getProcInfoIoUsage?pid=3009 - 网页返回值:{"Result":0,"ResultMessage":0} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getProcInfoIoUsage(int pid)方法输出的信息,URL中“?”之后为参数pid, - 并给pid参数赋值为3009 - - 3. 127.0.0.1:8090/process/getProcInfoMemUsage?pid=3009 - 网页返回值:{"Result":0,"ResultMessage":0} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getProcInfoMemUsage(int pid)方法输出的信息,URL中“?”之后为参数pid, - 并给pid参数赋值为3009 - - 4. 127.0.0.1:8090/process/getProcInfoStatus?pid=3009 - 网页返回值:{"Result":0,"ResultMessage":"0"} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getProcInfoStatus(int pid)方法输出的信息,URL中“?”之后为参数pid, - 并给pid参数赋值为3009 - - 5. 127.0.0.1:8090/process/getProcInfoPort?pid=3009 - 网页返回值:{"Result":0,"ResultMessage":0} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getProcInfoPort(int pid)方法输出的信息,URL中“?”之后为参数pid, - 并给pid参数赋值为3009 - - 6. 127.0.0.1:8090/process/getProcInfoStartTime?pid=3009 - 网页返回值:{"Result":0,"ResultMessage":""} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getProcInfoStartTime(int pid)方法输出的信息,URL中“?”之后为参数pid, - 并给pid参数赋值为3009 - - 7. 127.0.0.1:8090/process/getProcInfoRunningTime?pid=3009 - 网页返回值:{"Result":0,"ResultMessage":""} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getProcInfoRunningTime(int pid)方法输出的信息,URL中“?”之后为参数pid, - 并给pid参数赋值为3009 - - 8. 127.0.0.1:8090/process/getProcInfoCpuTime?pid=3009 - 网页返回值:{"Result":0,"ResultMessage":""} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getProcInfoCpuTime(int pid)方法输出的信息,URL中“?”之后为参数pid, - 并给pid参数赋值为3009 - - 9. 127.0.0.1:8090/process/getProcInfoCmd?pid=3009 - 网页返回值:{"Result":0,"ResultMessage":""} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getProcInfoCmd(int pid)方法输出的信息,URL中“?”之后为参数pid, - 并给pid参数赋值为3009 - - 10. 127.0.0.1:8090/process/getProcInfoUser?pid=3009 - 网页返回值:{"Result":0,"ResultMessage":""} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getProcInfoUser(int pid)方法输出的信息,URL中“?”之后为参数pid, - 并给pid参数赋值为3009 - - 11. 127.0.0.1:8090/process/getProcInfo?processname=bash - 网页返回值:{"Result":0,"ResultMessage":[]} - Result:连接dbus服务是否成功,0 成功,-1失败 - ResultMessage:调用getProcInfo(QString processname)方法输出的信息,URL中“?”之后为参数processname, - 并给pid参数赋值为"bash" - ---- -## 依赖关系调整 -**服务名称:** com.kylin.kysdk.service - -**路径名称:** /com/kylin/kysdk/dependence/ - -**接口名称:** com.kylin.kysdk.dependence - - Methods: - 1. rmDependence - 移除对任何kylin特性应用的依赖 - in: null - out: bool ---- \ No newline at end of file diff --git a/src/net/libkynetinfo.c b/src/net/libkynetinfo.c index ba0b507..399d4ab 100644 --- a/src/net/libkynetinfo.c +++ b/src/net/libkynetinfo.c @@ -835,6 +835,7 @@ char *kdk_net_get_hosts() fclose(fp); return NULL; } + memset(hosts, 0, 64); char line[4096] = "\0"; memset(hosts, 0, sizeof(hosts)); while (fgets(line, sizeof(line), fp)) @@ -864,6 +865,7 @@ char *kdk_net_get_hosts_domain() fclose(fp); return NULL; } + memset(hosts, 0, 256); char line[4096] = "\0"; memset(hosts, 0, sizeof(hosts)); int i = 0;