第一章:connmand 架构介绍

connmand 架构介绍

总体架构图

image

文件结构

src/util.c - /dev/urandom support
src/inotify.c - used by the core (config.c) and the session policy plugin
src/technology.c – used for technology interface
src/notifier.c – basic notifier infrastructure
src/agent.c – agent interface
src/service.c – used for service interface
src/peer_service.c – p2p peer service API
src/peer.c – p2p peer object’s core logic
src/provider.c – provider infrastructure
src/network.c – network infrastructure used by plug-ins
src/config.c – framework for configuration files
src/device.c – device infrastructure used by plug-ins
src/iptables.c – iptables support (netfilter chains and rules)
src/firewall-iptables.c, nftables.c (older firewall.c) – firewall infrastructure.
src/nat.c – used for NAT
src/tethering.c  – tethering infrastructure
src/manager.c – Manager interface
src/stats.c – used for storing service stats ( mmaped into memory)
src/ipconfig.c – IP configuration framework
src/rtnl.c – netlink support
src/session.c – Allows 3rd party applications to request a network session 
src/resolver.c – resolver framework
src/dhcp.c, dhcpv6.c – dhcp framework
src/rfkill.c – rfkill interface support
src/machine.c -  basic systemd-hostnamed ( machine-type- “chassis”) support

结构体关系

在这里插入图片描述

connman_xxx(technology,network,device)分别描述了特征, 并单向关联了对应的driver行为, connmnad_xxx_driver 描述了具体行为接口,大致如下,具体接口定义在各个插件中实现, 通过 connman_xxx(technology,network,device)从而统一底层不同网络类型与connmand 和上层与connmand 的交互

        const char *name;
        enum connman_device_type type;
        int priority;
        int (*probe) (struct connman_device *device);
        void (*remove) (struct connman_device *device);
        int (*enable) (struct connman_device *device);
        int (*disable) (struct connman_device *device);
        int (*scan)(struct connman_device *device,
                        struct connman_device_scan_params *params);
        void (*stop_scan) (enum connman_service_type type,
                        struct connman_device *device);
        int (*set_regdom) (struct connman_device *device,
                                                const char *alpha2);
connman_technology

struct connman_technology {
        int refcount;
        enum connman_service_type type;
        char *path;
        GSList *device_list;
        ...
        //单向关联connman_technology_driver, 可以同时存在多种technology的行为定义
        GSList *driver_list;  
        ....
};
connman_technology_driver
struct connman_technology_driver {
        const char *name;
        enum connman_service_type type;
        int priority;
        int (*probe) (struct connman_technology *technology);
        void (*remove) (struct connman_technology *technology);
        void (*add_interface) (struct connman_technology *technology,
                                                int index, const char *name,
                                                        const char *ident);
        void (*remove_interface) (struct connman_technology *technology,
                                                                int index);
        int (*set_tethering) (struct connman_technology *technology,
                                const char *identifier, const char *passphrase,
                                const char *bridge, bool enabled);
        int (*set_regdom) (struct connman_technology *technology,
                                                const char *alpha2);
};
connman_device

每个插件编写处理新设备检测的代码;但插件发现有新设备, 插件需要通过调用 connman_device_create() 通知 ConnMand。

struct connman_device {
        ...
        struct connman_device_driver *driver;  // 具体网络类型的行为
        ...
        struct connman_network *network;
        GHashTable *networks;  //存储底层上报的network哈希表
};
connman_device_driver

描述各个网络设备插件的行为, 主要为扫描, 上下电等接口

struct connman_device_driver {
        const char *name;
        enum connman_device_type type;
        int priority;
        int (*probe) (struct connman_device *device);
        void (*remove) (struct connman_device *device);
        int (*enable) (struct connman_device *device);
        int (*disable) (struct connman_device *device);
        int (*scan)(struct connman_device *device,
                        struct connman_device_scan_params *params);
        void (*stop_scan) (enum connman_service_type type,
                        struct connman_device *device);
        int (*set_regdom) (struct connman_device *device,
                                                const char *alpha2);
};
connman_network
struct connman_network {
         ...
         //关联网络的行为,如关联和去关联等
        struct connman_network_driver *driver;
        ...
        struct connman_device *device;

};
network_driver

描述每种类型的技术建立/处理连接的细节.

struct connman_network_driver {
        const char *name;
        enum connman_network_type type;
        int priority;
        int (*probe) (struct connman_network *network);
        void (*remove) (struct connman_network *network);
        int (*connect) (struct connman_network *network);
        int (*disconnect) (struct connman_network *network);
        int (*set_autoconnect) (struct connman_network *network,
                                bool autoconnect);
};
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值