---
title: mmpm_add_rule
description: "多模规则匹配引擎导入规则集合。rule->key和rule->key_len需要一一对应，否则无法确保功能符合预期。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/2530/ida/kunpeng_datadistribution_01_0015.html
sourcePath: /source/zh/kunpengboostkithistory/2530/ida/kunpeng_datadistribution_01_0015.html
indexId: 72e641c4010120ed2ca0f3c71ff67ba64b606d9b707f364c83c6dc638cb4fd2c80
---
# 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。
- 失败：返回错误码。
