summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
authorSergey V. Lobanov <sergey@lobanov.in>2024-09-01 08:59:09 +0000
committerSergey V. Lobanov <sergey@lobanov.in>2024-09-02 12:42:58 +0000
commitcbfa3efe7ae135b4ae8890485701677f56087f50 (patch)
tree3541b071ebfdb37699043e7c55b02ca6c230304e /accel-pppd
parent0c021f60244a7fd992916a882fb4ed7277f5cba8 (diff)
downloadaccel-ppp-cbfa3efe7ae135b4ae8890485701677f56087f50.tar.gz
accel-ppp-cbfa3efe7ae135b4ae8890485701677f56087f50.zip
migrate from pcre to pcre2
PCRE is not supported anymore and removed from several distros
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/CMakeLists.txt4
-rw-r--r--accel-pppd/cli/cli.c64
-rw-r--r--accel-pppd/cli/cli.h8
-rw-r--r--accel-pppd/cli/show_sessions.c19
-rw-r--r--accel-pppd/cli/std_cmd.c20
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c62
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c60
7 files changed, 119 insertions, 118 deletions
diff --git a/accel-pppd/CMakeLists.txt b/accel-pppd/CMakeLists.txt
index 496fbdca..b1606279 100644
--- a/accel-pppd/CMakeLists.txt
+++ b/accel-pppd/CMakeLists.txt
@@ -176,9 +176,9 @@ CHECK_FUNCTION_EXISTS(getcontext HAVE_GETCONTEXT)
CHECK_FUNCTION_EXISTS(setcontext HAVE_SETCONTEXT)
IF (HAVE_GETCONTEXT AND HAVE_SETCONTEXT)
- TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre)
+ TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre2-8)
ELSE (HAVE_GETCONTEXT AND HAVE_SETCONTEXT)
- TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre ucontext)
+ TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre2-8 ucontext)
ENDIF (HAVE_GETCONTEXT AND HAVE_SETCONTEXT)
set_property(TARGET accel-pppd PROPERTY CMAKE_SKIP_BUILD_RPATH FALSE)
diff --git a/accel-pppd/cli/cli.c b/accel-pppd/cli/cli.c
index 7d440727..6b71cb04 100644
--- a/accel-pppd/cli/cli.c
+++ b/accel-pppd/cli/cli.c
@@ -63,51 +63,6 @@ void __export cli_register_simple_cmd2(
va_end(ap);
}
-void __export cli_register_regexp_cmd(struct cli_regexp_cmd_t *cmd)
-{
- int err;
- int erroffset;
- const char *errptr;
-
- if (cmd->exec == NULL) {
- log_emerg("cli: impossible to register regexp command"
- " without an execution callback function\n");
- _exit(EXIT_FAILURE);
- }
- if (cmd->pattern == NULL) {
- log_emerg("cli: impossible to register regexp command"
- " without pattern\n");
- _exit(EXIT_FAILURE);
- }
- cmd->re = pcre_compile2(cmd->pattern, cmd->options, &err,
- &errptr, &erroffset, NULL);
- if (!cmd->re) {
- log_emerg("cli: failed to compile regexp \"%s\": %s (error %i)"
- " at positon %i (unprocessed characters: \"%s\")\n",
- cmd->pattern, errptr, err, erroffset,
- cmd->pattern + erroffset);
- _exit(EXIT_FAILURE);
- }
-
- if (cmd->h_pattern) {
- cmd->h_re = pcre_compile2(cmd->h_pattern, cmd->h_options, &err,
- &errptr, &erroffset, NULL);
- if (!cmd->h_re) {
- log_emerg("cli: failed to compile help regexp \"%s\":"
- " %s (error %i) at position %i (unprocessed"
- " characters: \"%s\")\n",
- cmd->h_pattern, errptr, err, erroffset,
- cmd->h_pattern + erroffset);
- _exit(EXIT_FAILURE);
- }
- } else {
- cmd->h_re = NULL;
- cmd->h_pattern = NULL;
- }
-
- list_add_tail(&cmd->entry, &regexp_cmd_list);
-}
-
int __export cli_send(void *client, const char *data)
{
struct cli_client_t *cln = (struct cli_client_t *)client;
@@ -189,13 +144,15 @@ static int cli_process_help_cmd(struct cli_client_t *cln)
cmd_found = 1;
list_for_each_entry(recmd, &regexp_cmd_list, entry) {
+ pcre2_match_data *match_data = pcre2_match_data_create(0, NULL);
if (cmd[0] == '\0'
- || pcre_exec(recmd->h_re, NULL, cmd, strlen(cmd),
- 0, 0, NULL, 0) >= 0) {
+ || pcre2_match(recmd->h_re, (PCRE2_SPTR)cmd, strlen(cmd),
+ 0, 0, match_data, NULL) >= 0) {
cmd_found = 1;
if (recmd->help)
recmd->help(cmd, cln);
}
+ pcre2_match_data_free(match_data);
}
nb_items = split(cmd, items);
@@ -230,14 +187,19 @@ static int cli_process_regexp_cmd(struct cli_client_t *cln, int *err)
int res;
cmd = skip_space(cmd);
- list_for_each_entry(recmd, &regexp_cmd_list, entry)
- if (pcre_exec(recmd->re, NULL, cmd, strlen(cmd),
- 0, 0, NULL, 0) >= 0) {
+ list_for_each_entry(recmd, &regexp_cmd_list, entry) {
+ pcre2_match_data *match_data = pcre2_match_data_create(0, NULL);
+ if (pcre2_match(recmd->re, (PCRE2_SPTR)cmd, strlen(cmd),
+ 0, 0, match_data, NULL) >= 0) {
found = 1;
res = recmd->exec(cmd, cln);
- if (res != CLI_CMD_OK)
+ if (res != CLI_CMD_OK) {
+ pcre2_match_data_free(match_data);
break;
+ }
}
+ pcre2_match_data_free(match_data);
+ }
if (found)
*err = res;
diff --git a/accel-pppd/cli/cli.h b/accel-pppd/cli/cli.h
index 6eda5d3f..3d8069b3 100644
--- a/accel-pppd/cli/cli.h
+++ b/accel-pppd/cli/cli.h
@@ -1,7 +1,8 @@
#ifndef __CLI_H
#define __CLI_H
-#include <pcre.h>
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
#include "list.h"
@@ -23,11 +24,11 @@ struct cli_simple_cmd_t
struct cli_regexp_cmd_t
{
struct list_head entry;
- pcre *re;
+ pcre2_code *re;
const char *pattern;
int options;
int (*exec)(const char *cmd, void *client);
- pcre *h_re;
+ pcre2_code *h_re;
const char *h_pattern;
int h_options;
int (*help)(const char *cmd, void *client);
@@ -42,7 +43,6 @@ void cli_register_simple_cmd2(
int hdr_len,
...
);
-void cli_register_regexp_cmd(struct cli_regexp_cmd_t *cmd);
void cli_show_ses_register(const char *name, const char *desc, void (*print)(struct ap_session *ses, char *buf));
int cli_send(void *client, const char *data);
diff --git a/accel-pppd/cli/show_sessions.c b/accel-pppd/cli/show_sessions.c
index 22f5318a..ca2ec68d 100644
--- a/accel-pppd/cli/show_sessions.c
+++ b/accel-pppd/cli/show_sessions.c
@@ -128,9 +128,9 @@ static int show_ses_exec(const char *cmd, char * const *f, int f_cnt, void *cli)
struct column_t *match_key = NULL;
char *match_pattern = NULL;
struct column_t *order_key = NULL;
- pcre *re = NULL;
- const char *pcre_err;
- int pcre_offset;
+ pcre2_code *re = NULL;
+ int pcre_err;
+ PCRE2_SIZE pcre_offset;
struct column_t *column;
struct col_t *col;
struct row_t *row;
@@ -169,9 +169,11 @@ static int show_ses_exec(const char *cmd, char * const *f, int f_cnt, void *cli)
}
if (match_key) {
- re = pcre_compile2(match_pattern, 0, NULL, &pcre_err, &pcre_offset, NULL);
+ re = pcre2_compile((PCRE2_SPTR)match_pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL);
if (!re) {
- cli_sendv(cli, "match: %s at %i\r\n", pcre_err, pcre_offset);
+ PCRE2_UCHAR err_msg[64];
+ pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg));
+ cli_sendv(cli, "match: %s at %i\r\n", err_msg, (int)pcre_offset);
return CLI_CMD_OK;
}
}
@@ -262,10 +264,13 @@ static int show_ses_exec(const char *cmd, char * const *f, int f_cnt, void *cli)
row = list_entry(t_list.next, typeof(*row), entry);
list_del(&row->entry);
if (match_key) {
- if (pcre_exec(re, NULL, row->match_key, strlen(row->match_key), 0, 0, NULL, 0) < 0) {
+ pcre2_match_data *match_data = pcre2_match_data_create(0, NULL);
+ if (pcre2_match(re, (PCRE2_SPTR)row->match_key, strlen(row->match_key), 0, 0, match_data, NULL) < 0) {
free_row(row);
+ pcre2_match_data_free(match_data);
continue;
}
+ pcre2_match_data_free(match_data);
}
if (order_key)
insert_row(&r_list, row);
@@ -362,7 +367,7 @@ out:
}
if (re)
- pcre_free(re);
+ pcre2_code_free(re);
return CLI_CMD_OK;
diff --git a/accel-pppd/cli/std_cmd.c b/accel-pppd/cli/std_cmd.c
index fc073526..ace48391 100644
--- a/accel-pppd/cli/std_cmd.c
+++ b/accel-pppd/cli/std_cmd.c
@@ -123,9 +123,9 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli)
{
struct ap_session *ses;
int hard = 0;
- pcre *re;
- const char *pcre_err;
- int pcre_offset;
+ pcre2_code *re;
+ int pcre_err;
+ PCRE2_SIZE pcre_offset;
if (f_cnt == 5) {
if (!strcmp(f[4], "hard"))
@@ -135,9 +135,11 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli)
} else if (f_cnt != 4)
return CLI_CMD_SYNTAX;
- re = pcre_compile2(f[3], 0, NULL, &pcre_err, &pcre_offset, NULL);
+ re = pcre2_compile((PCRE2_SPTR)f[3], PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL);
if (!re) {
- cli_sendv(cli, "match: %s at %i\r\n", pcre_err, pcre_offset);
+ PCRE2_UCHAR err_msg[64];
+ pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg));
+ cli_sendv(cli, "match: %s at %i\r\n", err_msg, (int)pcre_offset);
return CLI_CMD_OK;
}
@@ -145,8 +147,12 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli)
list_for_each_entry(ses, &ses_list, entry) {
if (!ses->username)
continue;
- if (pcre_exec(re, NULL, ses->username, strlen(ses->username), 0, 0, NULL, 0) < 0)
+ pcre2_match_data *match_data = pcre2_match_data_create(0, NULL);
+ if (pcre2_match(re, (PCRE2_SPTR)ses->username, strlen(ses->username), 0, 0, match_data, NULL) < 0) {
+ pcre2_match_data_free(match_data);
continue;
+ }
+ pcre2_match_data_free(match_data);
if (hard)
triton_context_call(ses->ctrl->ctx, (triton_event_func)__terminate_hard, ses);
else
@@ -154,7 +160,7 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli)
}
pthread_rwlock_unlock(&ses_lock);
- pcre_free(re);
+ pcre2_code_free(re);
return CLI_CMD_OK;
}
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 95ff8568..6139d24e 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -20,8 +20,6 @@
#endif
#include <linux/route.h>
-#include <pcre.h>
-
#include "events.h"
#include "list.h"
#include "triton.h"
@@ -56,7 +54,7 @@
#define SESSION_TERMINATED "Session was terminated"
struct iplink_arg {
- pcre *re;
+ pcre2_code *re;
const char *opt;
long *arg1;
};
@@ -2804,10 +2802,10 @@ void ipoe_vlan_mon_notify(int ifindex, int vid, int vlan_ifindex)
struct ifreq ifr;
char *ptr;
int len, r, svid;
- pcre *re = NULL;
- const char *pcre_err;
+ pcre2_code *re = NULL;
+ int pcre_err;
char *pattern;
- int pcre_offset;
+ PCRE2_SIZE pcre_offset;
char ifname[IFNAMSIZ];
if (!sect)
@@ -2905,15 +2903,17 @@ void ipoe_vlan_mon_notify(int ifindex, int vid, int vlan_ifindex)
memcpy(pattern, opt->val + 3, ptr - (opt->val + 3));
pattern[ptr - (opt->val + 3)] = 0;
- re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL);
+ re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL);
_free(pattern);
if (!re)
continue;
- r = pcre_exec(re, NULL, ifname, len, 0, 0, NULL, 0);
- pcre_free(re);
+ pcre2_match_data *match_data = pcre2_match_data_create(0, NULL);
+ r = pcre2_match(re, (PCRE2_SPTR)ifname, len, 0, 0, match_data, NULL);
+ pcre2_match_data_free(match_data);
+ pcre2_code_free(re);
if (r < 0)
continue;
@@ -3358,8 +3358,12 @@ static void load_interface(const char *opt)
static int __load_interface_re(int index, int flags, const char *name, int iflink, int vid, struct iplink_arg *arg)
{
- if (pcre_exec(arg->re, NULL, name, strlen(name), 0, 0, NULL, 0) < 0)
+ pcre2_match_data *match_data = pcre2_match_data_create(0, NULL);
+ if (pcre2_match(arg->re, (PCRE2_SPTR)name, strlen(name), 0, 0, match_data, NULL) < 0) {
+ pcre2_match_data_free(match_data);
return 0;
+ }
+ pcre2_match_data_free(match_data);
add_interface(name, index, arg->opt, iflink, vid, 0);
@@ -3368,11 +3372,11 @@ static int __load_interface_re(int index, int flags, const char *name, int iflin
static void load_interface_re(const char *opt)
{
- pcre *re = NULL;
- const char *pcre_err;
+ pcre2_code *re = NULL;
+ int pcre_err;
char *pattern;
const char *ptr;
- int pcre_offset;
+ PCRE2_SIZE pcre_offset;
struct iplink_arg arg;
struct ipoe_serv *serv;
@@ -3382,10 +3386,12 @@ static void load_interface_re(const char *opt)
memcpy(pattern, opt + 3, ptr - (opt + 3));
pattern[ptr - (opt + 3)] = 0;
- re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL);
+ re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL);
if (!re) {
- log_error("ipoe: '%s': %s at %i\r\n", pattern, pcre_err, pcre_offset);
+ PCRE2_UCHAR err_msg[64];
+ pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg));
+ log_error("ipoe: '%s': %s at %i\r\n", pattern, err_msg, (int)pcre_offset);
return;
}
@@ -3398,11 +3404,13 @@ static void load_interface_re(const char *opt)
if (serv->active)
continue;
- if (pcre_exec(re, NULL, serv->ifname, strlen(serv->ifname), 0, 0, NULL, 0) >= 0)
+ pcre2_match_data *match_data = pcre2_match_data_create(0, NULL);
+ if (pcre2_match(re, (PCRE2_SPTR)serv->ifname, strlen(serv->ifname), 0, 0, match_data, NULL) >= 0)
add_interface(serv->ifname, serv->ifindex, opt, 0, 0, 0);
+ pcre2_match_data_free(match_data);
}
- pcre_free(re);
+ pcre2_code_free(re);
_free(pattern);
}
@@ -3670,8 +3678,12 @@ static int __load_vlan_mon_re(int index, int flags, const char *name, int iflink
long mask1[4096/8/sizeof(long)];
struct ipoe_serv *serv;
- if (pcre_exec(arg->re, NULL, name, strlen(name), 0, 0, NULL, 0) < 0)
+ pcre2_match_data *match_data = pcre2_match_data_create(0, NULL);
+ if (pcre2_match(arg->re, (PCRE2_SPTR)name, strlen(name), 0, 0, match_data, NULL) < 0) {
+ pcre2_match_data_free(match_data);
return 0;
+ }
+ pcre2_match_data_free(match_data);
if (!(flags & IFF_UP)) {
memset(&ifr, 0, sizeof(ifr));
@@ -3701,11 +3713,11 @@ static int __load_vlan_mon_re(int index, int flags, const char *name, int iflink
static void load_vlan_mon_re(const char *opt, long *mask, int len)
{
- pcre *re = NULL;
- const char *pcre_err;
+ pcre2_code *re = NULL;
+ int pcre_err;
char *pattern;
const char *ptr;
- int pcre_offset;
+ PCRE2_SIZE pcre_offset;
struct iplink_arg arg;
for (ptr = opt; *ptr && *ptr != ','; ptr++);
@@ -3714,10 +3726,12 @@ static void load_vlan_mon_re(const char *opt, long *mask, int len)
memcpy(pattern, opt + 3, ptr - (opt + 3));
pattern[ptr - (opt + 3)] = 0;
- re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL);
+ re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL);
if (!re) {
- log_error("ipoe: '%s': %s at %i\r\n", pattern, pcre_err, pcre_offset);
+ PCRE2_UCHAR err_msg[64];
+ pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg));
+ log_error("ipoe: '%s': %s at %i\r\n", pattern, err_msg, (int)pcre_offset);
return;
}
@@ -3727,7 +3741,7 @@ static void load_vlan_mon_re(const char *opt, long *mask, int len)
iplink_list((iplink_list_func)__load_vlan_mon_re, &arg);
- pcre_free(re);
+ pcre2_code_free(re);
_free(pattern);
}
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index 8678db80..c8007414 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -83,7 +83,7 @@ struct padi_t
};
struct iplink_arg {
- pcre *re;
+ pcre2_code *re;
const char *opt;
void *cli;
long *arg1;
@@ -1368,8 +1368,12 @@ out_err:
static int __pppoe_add_interface_re(int index, int flags, const char *name, int iflink, int vid, struct iplink_arg *arg)
{
- if (pcre_exec(arg->re, NULL, name, strlen(name), 0, 0, NULL, 0) < 0)
+ pcre2_match_data *match_data = pcre2_match_data_create(0, NULL);
+ if (pcre2_match(arg->re, (PCRE2_SPTR)name, strlen(name), 0, 0, match_data, NULL) < 0) {
+ pcre2_match_data_free(match_data);
return 0;
+ }
+ pcre2_match_data_free(match_data);
__pppoe_server_start(name, arg->opt, arg->cli, iflink, vid, 0);
@@ -1378,11 +1382,11 @@ static int __pppoe_add_interface_re(int index, int flags, const char *name, int
static void pppoe_add_interface_re(const char *opt, void *cli)
{
- pcre *re = NULL;
- const char *pcre_err;
+ pcre2_code *re = NULL;
+ int pcre_err;
char *pattern;
const char *ptr;
- int pcre_offset;
+ PCRE2_SIZE pcre_offset;
struct iplink_arg arg;
for (ptr = opt; *ptr && *ptr != ','; ptr++);
@@ -1391,12 +1395,14 @@ static void pppoe_add_interface_re(const char *opt, void *cli)
memcpy(pattern, opt + 3, ptr - (opt + 3));
pattern[ptr - (opt + 3)] = 0;
- re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL);
+ re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL);
if (!re) {
- if (cli)
- cli_sendv(cli, "pppoe: %s at %i\r\n", pcre_err, pcre_offset);
- log_error("pppoe: %s at %i\r\n", pcre_err, pcre_offset);
+ PCRE2_UCHAR err_msg[64];
+ pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg));
+ if (cli)
+ cli_sendv(cli, "pppoe: %s at %i\r\n", err_msg, (int)pcre_offset);
+ log_error("pppoe: %s at %i\r\n", err_msg, (int)pcre_offset);
return;
}
@@ -1406,7 +1412,7 @@ static void pppoe_add_interface_re(const char *opt, void *cli)
iplink_list((iplink_list_func)__pppoe_add_interface_re, &arg);
- pcre_free(re);
+ pcre2_code_free(re);
_free(pattern);
}
@@ -1678,10 +1684,10 @@ void pppoe_vlan_mon_notify(int ifindex, int vid, int vlan_ifindex)
struct ifreq ifr;
char *ptr;
int len, r, svid;
- pcre *re = NULL;
- const char *pcre_err;
+ pcre2_code *re = NULL;
+ int pcre_err;
char *pattern;
- int pcre_offset;
+ PCRE2_SIZE pcre_offset;
char ifname[IFNAMSIZ];
if (!sect)
@@ -1779,15 +1785,17 @@ void pppoe_vlan_mon_notify(int ifindex, int vid, int vlan_ifindex)
memcpy(pattern, opt->val + 3, ptr - (opt->val + 3));
pattern[ptr - (opt->val + 3)] = 0;
- re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL);
+ re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL);
_free(pattern);
if (!re)
continue;
- r = pcre_exec(re, NULL, ifr.ifr_name, len, 0, 0, NULL, 0);
- pcre_free(re);
+ pcre2_match_data *match_data = pcre2_match_data_create(0, NULL);
+ r = pcre2_match(re, (PCRE2_SPTR)ifr.ifr_name, len, 0, 0, match_data, NULL);
+ pcre2_match_data_free(match_data);
+ pcre2_code_free(re);
if (r < 0)
continue;
@@ -1862,8 +1870,12 @@ static int __load_vlan_mon_re(int index, int flags, const char *name, int iflink
long mask1[4096/8/sizeof(long)];
struct pppoe_serv_t *serv;
- if (pcre_exec(arg->re, NULL, name, strlen(name), 0, 0, NULL, 0) < 0)
+ pcre2_match_data *match_data = pcre2_match_data_create(0, NULL);
+ if (pcre2_match(arg->re, (PCRE2_SPTR)name, strlen(name), 0, 0, match_data, NULL) < 0) {
+ pcre2_match_data_free(match_data);
return 0;
+ }
+ pcre2_match_data_free(match_data);
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, name);
@@ -1896,11 +1908,11 @@ static int __load_vlan_mon_re(int index, int flags, const char *name, int iflink
static void load_vlan_mon_re(const char *opt, long *mask, int len)
{
- pcre *re = NULL;
- const char *pcre_err;
+ pcre2_code *re = NULL;
+ int pcre_err;
char *pattern;
const char *ptr;
- int pcre_offset;
+ PCRE2_SIZE pcre_offset;
struct iplink_arg arg;
for (ptr = opt; *ptr && *ptr != ','; ptr++);
@@ -1909,10 +1921,12 @@ static void load_vlan_mon_re(const char *opt, long *mask, int len)
memcpy(pattern, opt + 3, ptr - (opt + 3));
pattern[ptr - (opt + 3)] = 0;
- re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL);
+ re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL);
if (!re) {
- log_error("pppoe: '%s': %s at %i\r\n", pattern, pcre_err, pcre_offset);
+ PCRE2_UCHAR err_msg[64];
+ pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg));
+ log_error("pppoe: '%s': %s at %i\r\n", pattern, err_msg, (int)pcre_offset);
return;
}
@@ -1922,7 +1936,7 @@ static void load_vlan_mon_re(const char *opt, long *mask, int len)
iplink_list((iplink_list_func)__load_vlan_mon_re, &arg);
- pcre_free(re);
+ pcre2_code_free(re);
_free(pattern);
}