- 博客(43)
- 资源 (22)
- 收藏
- 关注
翻译 insmod VS modprobe
`modprobe` and `insmod` are both commands used in Linux for managing kernel modules, but they have some key differences in terms of functionality and usage.1. Purpose: - `modprobe`: The `modprobe` command is used to automatically load modules and their
2023-06-09 09:00:28
162
原创 /etc/sudoers: Permission denied的修复
sudo: unable to stat /etc/sudoers: Permission deniedsudo: no valid sudoers sources found, quittingsudo: unable to initialize policy plugin执行命令chmod g+x /
2019-09-26 09:07:59
5734
原创 C++中 无参数函数模板使用
头文件中定义:template<class ia_t>T_bool isIgmpV3MultSrcSupported();template <> T_bool isIgmpV3MultSrcSupported<ia4_t>();template <> T_bool isIgmpV3MultSrcSupported<ia6_t>(...
2018-12-17 16:27:20
3486
原创 接收和发送消息
q_receive __q_receive syncobj_wait_grant monitor_wait_grant threadobj_cond_wait pthread_cond_wait,消息队列阻塞在此 q_send __q_send_inner ...
2018-09-03 17:01:52
308
转载 set_new_handler例子
#include /// buffer to be allocated after custom new handler has been installedchar* g_pSafetyBuffer = NULL;/// exceptional one time release of a global reservevoid my_new_handler(){
2018-01-15 11:12:46
287
原创 radius的简单配置
环境是Ubuntu安装命令:sudo apt-get install freeradius启动服务:service freeradius start调试启动:freeradius -X实验举例:设置网段为135.251.0.0/16的client与服务器之间的radius密码是“alcatel”则在client.conf中增加如下client 135.251.0
2017-11-23 14:25:47
5221
原创 Centos 7.0下samba笔记
查看smb的当前状态:systemctl status smb查看当前samba用户:pdbedit -L启动服务:systemctl restart smb问题1. 当电脑上映射网络驱动无法访问时可以使用如下命令解决setenforce 0
2017-06-02 16:39:21
398
原创 web 笔记
1. php中调用写文件调试file_put_contents("hello.txt", $sql);2. sql中判断一个字段为空自动设置为其他字符串IFNULL(rank_name,'普通用户')
2017-04-26 10:45:36
308
原创 ifconfig调用过程
ifconfig命令是可以查看当前网络设备信息,在openwrt环境中,ifconfig源码位于busybox文件夹下找到入口函数ifocnfig_main,位于ifconfig.c文件中int ifconfig_main(int argc UNUSED_PARAM, char **argv){ struct ifreq ifr; struct sockaddr_in sai
2017-04-13 17:04:33
5218
原创 vi 操作
vi filename.cvi +457 filename.c 打开文件同时跳至457行shirt+zz,保存并退出:w!,保存退出:q!,不保存退出:457,跳至457行
2017-04-13 09:39:36
481
原创 设备通知链
直接上代码static int brcm_device_event(struct notifier_block *unused, unsigned long event, void *ptr){ printk(KERN_INFO "brcm_device_event = %d\n", event); return NOTIFY_DONE;}static struc
2017-04-12 17:40:25
316
原创 多线程与inet_ntoa
今天在调BUG发现一个很奇怪的问题,描述如下: void file_do_transmit_firmware(evutil_socket_t fd, short event, void *arg) { struct sockaddr_in peeraddr; pthread_t thread_id; socklen_t socklen; int s, clientfd; c
2017-04-12 17:09:25
1381
原创 ioctl之用户空间与内核的通信
内核部分代码在include\uapi\linux\sockios.h文件内增加如下消息定义#define SIOCGIFBRCM 0x8984 /* */#define SIOCSIFBRCM 0x8985 /* */ 在net\socket.c文件内增加static DEFINE_MUTEX(brcm_ioctl_mutex);static int (*br
2017-04-12 16:45:55
1505
原创 netlink 通信广播demo
最近在做工程时,用到了内核间通信,需要把内核部分得到发送至用户空间。下面给出demo例子:分为内核部分和用户空间部分:首先在内核部分增加一个netlink消息类型#define NETLINK_URL 23创建内核的netlink socket static struct sock *nlfd; struct netlink_kernel_cfg cfg =
2017-04-11 10:27:27
1197
原创 次优路径算法
SPF算法找的是最优路径,下面的代码是在SPF基础上修改,查找的是次优路径 #include #include #include #include struct listnode { struct listnode *next; struct listnode *prev; void *data;};struct list { struct listnode
2017-03-20 17:55:08
2446
原创 合并算法
编写该算法解决的是,在tcp报文里面有很多的块,需要合并成一整块进行处理。使用的是递归 #include #include #include #include #include "list.h"typedef unsigned int uint32;#define HERE printf("HERE: %s %d\n", __FUNCTION__,__LINE__)#d
2017-03-20 17:51:35
863
原创 openwrt配置实验
使用的机器有四个LAN口,LAN1-4,1个WAN口默认的配置情况是,LAN1-LAN4为vlan-id1,wan口为vlan-id2,在LAN口下能通过dhcp分配ip地址,电脑接入lan口后能访问外网。我本次实验的目的是1,创建一个新的桥br-test。(默认桥接口是br-lan)2,创建一个新的子端口eth0.3并与LAN1关联,即LAN1接收到的数据会进入eth0.3子端口
2017-03-17 17:25:10
5485
原创 openwrt之dhcp客户端是如何设置端口ip地址的
dhcp协议就不在这里多介绍了,主要想说下dhcp客户端设置端口ip地址的流程。客户端执行的命令是:(关于dhcp客户端如何被执行的可以参考上一篇文章)root@BDCOM:~# ps -w | grep udh 1761 root 1484 S udhcpc -p /var/run/udhcpc-eth0.2.pid -s /lib/netifd/dhcp.scrip
2017-03-17 10:28:32
14668
原创 openwrt 之dhcp客户端调用分析
客户端程序root@BDCOM:/proc/1679# ps -w | grep udh 1679 root 1484 S udhcpc -p /var/run/udhcpc-eth0.2.pid -s /lib/netifd/dhcp.script -f -t 0 -i eth0.2 -V 3830d84fd8bc77bf -C其父进程为 netifdroot@B
2017-03-16 14:56:44
10325
1
转载 DHCP options
CodeData lengthDescriptionReferences00Pad.RFC 213214Subnet Mask.RFC 213224Time Offset (deprecated).RFC 213234+Router.RFC 213244+Time Ser
2017-03-15 17:18:44
7412
原创 openwrt创建子端口
创建子端口vconfig eth0 3,与交换机的vlan3对应ifconfig eth0.3 up查看交换机信息:swconfig listswconfig dev switch0 show配置子端口ip地址ifconfig eth0.3 172.16.20.104 netmask 255.255.0.0删除ip地址ifconfig eth0.3 0.0.0.
2017-03-15 15:35:37
1826
转载 找到一个可用的数字
源码来自Linux 桥模块/* find an available port number */static int find_portno(struct net_bridge *br){ int index; struct net_bridge_port *p; unsigned long *inuse; inuse = kcalloc(BITS_TO_LONGS(BR_MAX
2017-02-28 17:10:50
339
原创 eventfd的用法
eventfd不同于以前使用的fd,其write和read方法不一样。举例子说明:static void thread_notify(evutil_socket_t fd, short event, void *arg) { uint64_t msg = 0; uint64_t r; sleep(4); r = read(fd, (void*) &msg, sizeof(
2017-02-20 16:07:07
2005
原创 工作之后我推荐看的书籍
1. 算法导论(原书第3版)/计算机科学丛书 [Introduction to Algorithms, third edition]超过50万人阅读的算法圣经!算法标准教材,国内外1000余所高校采用[美] Thomas H.Cormen,[美] Charles E.Leiserson,[美] Ronald L.Rivest,[美] Clifford Stein 著;殷建平,徐云,王刚 等
2017-02-07 10:54:46
3270
转载 exec系列函数
转载地址:http://www.cnblogs.com/memset/p/linux_exec_function_family.html
2017-01-06 15:26:48
265
原创 在脚本里面使用uci读取配置信息
配置文件:/etc/config/cdnconfig cdnclient 'main' option host '127.0.0.1' option port '31200' option frequency '5'脚本命令start_instance () { local cfg="$1" config_get _host
2017-01-03 15:23:18
1203
原创 使用procd执行进程
在openwrt系统内init进程被procd取代,procd作为父进程可以监控子进程的状态。一旦子进程退出后即可在某一个时刻尝试进行重启进程。在op系统内使用procd监控的有uhttpd,netifd等。在/etc/init.d/文件夹内带有USE_PROCD=1标志,下面就介绍如何让procd启动某一个应用程序。
2016-12-28 10:44:57
16259
原创 使用fscanf获取固定格式内容
需求:读取/proc/net/arp文件的ip和mac信息#include #include char *arp_get(){ FILE *proc; char ip[16]; char mac[18]; if (!(proc = fopen("/proc/net/arp", "r"))) { return NULL; } /* Skip first line */
2016-12-26 15:08:11
1999
原创 简单定时器实现
经常会遇到这样的功能,需要开辟一个现场同时循环的跑一个任务,下面是简单实现的代码 调用select 加超时时间 #include #include #include #include #include void thread_client_timeout(const void *arg){ int count = 0; while (1) { struc
2016-12-26 13:50:30
315
原创 异步接收子线程的返回值
上次在做版本升级时遇到一个这样的需求:服务器需要向客户端发送版本文件,采用的是TCP + pthread来实现,其中,发送结果需要返回给主线程。这让我想起了子进程的操作退出后会给主进程发送一个信号,而主进程会在收到信号后调用WaitPid来获取返回值。而在线程里面退出就没有类似的信号发送出来,刚开始感觉无从下手,后面浏览了libevent代码后便有有了灵感,使用eventfd可以解决这个问题。
2016-12-20 13:16:30
1351
原创 libubox库avl树的使用例子
1. 定义一棵avl树struct avl_tree services;2. 初始化avl树int avl_strcmp(const void *k1, const void *k2, void *ptr){ return strcmp(k1, k2);}avl_init(&services, avl_strcmp, false, NULL);3. 插入结点
2016-12-20 10:26:26
2575
原创 ubus客户端向服务器请求信息的例子
openwrt用户空间进中通信常用的通信方式是使用ubus通信,下面给出一个例子,是客户端向服务器请求ap的个数。 服务器端代码 #include #include #include "libubus.h"static struct ubus_context *ctx;static struct blob_buf b;enum { REQ_STATION_COUN
2016-12-16 16:11:04
5901
原创 在shell中向应用程序的socket发送信息
今天在做一个东东,即在shell脚本上面wget一个文件成功后通知应用程序,想到的方法有如下:1. 使用ubus,需要在应用程序中增加一个服务对象,写回调函数2. 创建一个控制程序,通过unix socket的方式让控制程序与后台进程通信,然后脚本执行控制程序。这种方法编码更多 随后在组长的帮助下,用了一个很简单的命令通过telnet的方式就可以了。首先后台应用程序创建一个tc
2016-11-23 13:33:24
11216
原创 在openwrt上使用libevent库
定时器的使用#include ...#include struct event *ev;static void levent_udp_timeout(evutil_socket_t fd, short what, void *arg){ printf("hello timeout\n"); struct timeval timeout; timeout.tv_sec
2016-11-21 16:46:34
2601
原创 内核定时器的简单使用
static struct timer_list timer;static void flow_shrink(unsigned long arg){ //do your work mod_timer(&timer, jiffies + FLOW_SHRINK_PERIOD); //重置定时器}void flow_timer_init(){ init_timer(&timer
2016-11-17 16:40:55
332
原创 libubox中uloop库的使用
uloop.c是libubox的一个小模块,简化了编程1. socket 使用#include ""struct uloop_fd ufd; //创建uloop_fd全局变量static void fd_handler(struct uloop_fd *u, unsigned int ev){ if(recvfrom(u->fd, s, DEFAULT_BUFFERLE
2016-11-17 16:00:59
14323
2
原创 解决由于libiconv库无法编码通过的问题
gconvert.c:66:2: error: #error GNU libiconv not in use but included iconv.h is from libiconv #error GNU libiconv not in use but included iconv.h is from libiconv 解决方法:$ cd build_dir/host/p
2016-11-15 10:29:08
2834
live 生日提醒 理财易 备忘本 小软件
2011-03-10
live 生日提醒 理财易 备忘本 小软件
2011-01-14
live 生日提醒 理财易 备忘本 小软件
2010-10-14
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人