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. ​ oracle分区表(附带按照月自动分区、按天自动分区)

    --list_range  示例   drop table list_range_tab purge; create table list_range_tab(n1 number,n2 date)pa ...

  2. ActiveMQ异步分发消息

    org.apache.activemq.ActiveMQConnection 类中有个参数: protected boolean dispatchAsync=true; 这个参数的含义到底是什么? 使 ...

  3. PyCharm+QTDesigner+PyUIC使用教程

    我们在PyCharm安装配置Qt Designer+PyUIC教程中已配置好了PyCharm+QTDesigner+PyUIC环境 这里在此基上我们演示如何使用这些工具,编写一个图形界面程序: 程序主 ...

  4. [转]JVM内存模型

    最近排查一个线上java服务常驻内存异常高的问题,大概现象是:java堆Xmx配置了8G,但运行一段时间后常驻内存RES从5G逐渐增长到13G #补图#,导致机器开始swap从而服务整体变慢.由于Xm ...

  5. Sql server2008如何导入Excel文件数据?

    sql server 中如何使用Excel文件导入数据?我做个测试,首先建立一个测试表(民族表) --创建一个民族表-- create table BdsNation( Uid int not nul ...

  6. 字符串和数组----vector

    vector能容纳绝大多数类型的对象作为其元素,但是因为引用不是对象,所以不存在包含引用的vector. 使用vector需要包含头文件vector. 1.初始化vector对象的方法 1)vecto ...

  7. day_07_python_1124

    01 昨日内容回顾 数据类型补充: str <---> list split join list <---> set set(list) list(set()) list &l ...

  8. unity中让摄像机移动到鼠标点击的位置和鼠标控制平移视角

    private Vector3 targetVector3; private float movespeed=0.5f; private bool IsOver = true; private Gam ...

  9. python 学习 模块

    在计算机程序的开发过程中,随着程序代码越写越多,在一个文件里代码就越来越长,越来越不容易 维护, 为了编写可维护的代码,我们把很多函数分组,分别放到不同的文件里,这样,每个文件包含的代码就相对较少,很 ...

  10. linux-安装jdk以及tomcat

    1.安装jdk   下载地址:www.oracle.com/technetwork/cn/java/javase/downloads/jdk7-downloads-1880260.html 将jdk下 ...