script.c
script_runreason(const struct interface *ifp, const char *reason)
elen = (size_t)make_env(ifp, reason, &env);
pid = exec_script(ifp->ctx, argv, env);

make_env(const struct interface *ifp, const char *reason, char ***argv)

exec_script(const struct dhcpcd_ctx *ctx, char *const *argv, char *const *env)
posix_spawn(&pid, argv[0], NULL, &attr, argv, env);

posix_spawn.c
intposix_spawn(pid_t *pid, const char *path,const posix_spawn_file_actions_t *file_actions,const posix_spawnattr_t *attrp,char *const argv[], char *const envp[])
execve(path, argv, envp);

dhcpcd.c
eloop_event_add(ctx.eloop, ctx.link_fd, dhcpcd_handlelink, &ctx);

dhcpcd.c
static void dhcpcd_handlelink(void *arg)
{
struct dhcpcd_ctx *ctx;

ctx = arg;
if (if_handlelink(ctx) == -1) {
logger(ctx, LOG_ERR, "if_handlelink: %m");
eloop_event_delete(ctx->eloop, ctx->link_fd);
close(ctx->link_fd);
ctx->link_fd = -1;
}
}

if-linux.c
if_handlelink(struct dhcpcd_ctx *ctx)
{

return get_netlink(ctx, ctx->iov, NULL,
ctx->link_fd, MSG_DONTWAIT, &link_netlink);
}

if-linux.c
get_netlink(struct dhcpcd_ctx *ctx, struct iovec *iov,struct interface *ifp, int fd, int flags,int (*callback)(struct dhcpcd_ctx *, struct interface *, struct nlmsghdr *))
if (callback && (r = callback(ctx, ifp, nlm)) != 0)
break;

dhcpcd.c
949run_preinit(struct interface *ifp)

netlink
rtnetlink.h
struct ifinfomsg {
unsigned char ifi_family;
unsigned char __ifi_pad;
unsigned short ifi_type; /* ARPHRD_* */
int ifi_index; /* Link index */
unsigned ifi_flags; /* IFF_* flags */
unsigned ifi_change; /* IFF_* change mask */
};

netlink.h
struct nlmsghdr {
__u32 nlmsg_len; /* Length of message including header */
__u16 nlmsg_type; /* Message content */
__u16 nlmsg_flags; /* Additional flags */
__u32 nlmsg_seq; /* Sequence number */
__u32 nlmsg_pid; /* Sending process port ID */
};

#define NLMSG_ALIGNTO 4U
#define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
#define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN))
#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
#define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0)))
#define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
(struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
(nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
(nlh)->nlmsg_len <= (len))
#define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))

#define NLMSG_NOOP 0x1 /* Nothing. */
#define NLMSG_ERROR 0x2 /* Error */
#define NLMSG_DONE 0x3 /* End of a dump */
#define NLMSG_OVERRUN 0x4 /* Data lost */

#define NLMSG_MIN_TYPE 0x10 /* < 0x10: reserved control messages */

if.h
#define IFF_UP 0x1 /* interface is up */
#define IFF_BROADCAST 0x2 /* broadcast address valid */
#define IFF_DEBUG 0x4 /* turn on debugging */
#define IFF_LOOPBACK 0x8 /* is a loopback net */
#define IFF_POINTOPOINT 0x10 /* interface is has p-p link */
#define IFF_NOTRAILERS 0x20 /* avoid use of trailers */
#define IFF_RUNNING 0x40 /* interface RFC2863 OPER_UP */
#define IFF_NOARP 0x80 /* no ARP protocol */
#define IFF_PROMISC 0x100 /* receive all packets */
#define IFF_ALLMULTI 0x200 /* receive all multicast packets*/

#define IFF_MASTER 0x400 /* master of a load balancer */
#define IFF_SLAVE 0x800 /* slave of a load balancer */

#define IFF_MULTICAST 0x1000 /* Supports multicast */

./configure CC=/opt_gccarm/1295_toolchain/bin/aarch64-openwrt-linux-gcc --prefix=/home/jack/pratice/dhcpcd/dhcpcd-6.11.5/_install/

wewqe的更多相关文章

随机推荐

  1. maven配置多仓库镜像(转)

    原文地址:maven配置多仓库镜像 问题场景: 1.国内访问maven默认远程中央镜像特别慢 2.用阿里的镜像替代远程中央镜像 3.大部分jar包都可以在阿里镜像中找到,部分jar包在阿里镜像中没有, ...

  2. Linux -- 基于zookeeper的java api(一)

    Linux -- 基于zookeeper的java api 首先启动你所有的 zkService.sh 查看状态:检查是否启动正确 [root@hu-hadoop2 ~]# zkServer.sh s ...

  3. python 文件的打开与读取

    python 文件的打开与读取 其实网上其他人写的都挺好的,我也是看他们的.办公室用的2.7.笔记本用的3.6.发现没有file 类,尴尬了 with open(r'C:\Users\HBX\Docu ...

  4. react native 入门 (1)- 环境搭建, 创建第一个Hello World

    Create React Native App 是开始构建新的React Native应用程序的最简单方法.它允许您启动项目而无需安装或配置任何工具来构建本机代码 - 无需安装Xcode或Androi ...

  5. ORM框架(ITDOS实战源码)

    ORM提供了实现持久化层的另一种模式,它采用映射元数据来描述对象关系的映射,使得ORM中间件能在任何一个应用的业务逻辑层和数据库层之间充当桥梁. 如以下示例: public int GetSystem ...

  6. Object转Integer,String

    object先转为字符串,然后通过int 的封装类(Integer)的pasreInt()方法转为int 例如: Object  ob = 123; Integer.parseInt(String.v ...

  7. R中sort(), rank(), order()

    在R中,和排序相关的函数主要有三个:sort(),rank(),order(). sort(x)是对向量x进行排序,返回值排序后的数值向量.rank()是求秩的函数,它的返回值是这个向量中对应元素的“ ...

  8. struts访问

    struts基本工程结构: 1. struts.xml支持语法提示;2. struts.xml配置常量, 用来覆盖struts.properties中的默认常量配置  一般情况下, 这个配置放在str ...

  9. bzoj1692

    题解: 二分最近的不相同 然后hash判断是否相同 然后贪心 代码: #include<bits/stdc++.h> using namespace std; #define ull un ...

  10. tomcat 服务器线程问题

    http://blog.csdn.net/wtopps/article/details/71339295 http://blog.csdn.net/wtopps/article/details/713 ...