---
title: mmpm_add_rule
description: "多模规则匹配引擎导入规则集合。rule->key和rule->key_len需要一一对应，否则不确保功能符合预期。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/252RC1/ida/kunpeng_datadistribution_01_0015.html
sourcePath: /source/zh/kunpengboostkithistory/252RC1/ida/kunpeng_datadistribution_01_0015.html
indexId: beafe8c93d3e0dc389359ce715b4db0897e92072b9fa5566bea6d59088ca838582
---
# mmpm_add_rule

#### 接口功能

多模规则匹配引擎导入规则集合。rule->key和rule->key_len需要一一对应，否则不确保功能符合预期。


#### 接口定义

```
int mmpm_add_rule(mmpm_handler_t *handler, mmpm_rule_t *rule, uint32_t rule_num);
```


#### 参数说明

| 参数名 | 描述 | 取值范围 | 输入/输出 |
| --- | --- | --- | --- |
| handler | 匹配引擎句柄 | 非NULL | 输入 |
| rule | 待导入的规则数组 | 非NULL | 输入 |
| rule\_num | 导入规则数量 | 非负值，取值范围跟uint32\_t保持一致；值必须与参数rule的实际数组长度一致，否则会出现访问越界异常 | 输入 |


#### 返回值

- 成功：返回0。
- 失败：返回错误码。
