mirror of
https://github.com/hashcat/hashcat.git
synced 2024-12-22 06:38:11 +00:00
Prepare for rules_ctx_t
This commit is contained in:
parent
8c6907a3d7
commit
ebe9f1c07f
30
include/rp.h
Normal file
30
include/rp.h
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#ifndef _RP_H
|
||||
#define _RP_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define RP_RULE_BUFSIZ 0x100
|
||||
|
||||
#define INCR_RULES 10000
|
||||
|
||||
#define MAX_KERNEL_RULES 31
|
||||
|
||||
bool class_num (const u8 c);
|
||||
bool class_lower (const u8 c);
|
||||
bool class_upper (const u8 c);
|
||||
bool class_alpha (const u8 c);
|
||||
|
||||
int conv_ctoi (const u8 c);
|
||||
int conv_itoc (const u8 c);
|
||||
|
||||
int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], u32 rp_gen_func_min, u32 rp_gen_func_max);
|
||||
|
||||
int cpu_rule_to_kernel_rule (char *rule_buf, uint rule_len, kernel_rule_t *rule);
|
||||
int kernel_rule_to_cpu_rule (char *rule_buf, kernel_rule_t *rule);
|
||||
|
||||
#endif // _RP_H
|
@ -8,79 +8,11 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define RP_RULE_BUFSIZ 0x100
|
||||
|
||||
#define RULE_RC_SYNTAX_ERROR -1
|
||||
#define RULE_RC_REJECT_ERROR -2
|
||||
|
||||
#define RULE_OP_MANGLE_NOOP ':'
|
||||
#define RULE_OP_MANGLE_LREST 'l'
|
||||
#define RULE_OP_MANGLE_UREST 'u'
|
||||
#define RULE_OP_MANGLE_LREST_UFIRST 'c'
|
||||
#define RULE_OP_MANGLE_UREST_LFIRST 'C'
|
||||
#define RULE_OP_MANGLE_TREST 't'
|
||||
#define RULE_OP_MANGLE_TOGGLE_AT 'T'
|
||||
#define RULE_OP_MANGLE_REVERSE 'r'
|
||||
#define RULE_OP_MANGLE_DUPEWORD 'd'
|
||||
#define RULE_OP_MANGLE_DUPEWORD_TIMES 'p'
|
||||
#define RULE_OP_MANGLE_REFLECT 'f'
|
||||
#define RULE_OP_MANGLE_ROTATE_LEFT '{'
|
||||
#define RULE_OP_MANGLE_ROTATE_RIGHT '}'
|
||||
#define RULE_OP_MANGLE_APPEND '$'
|
||||
#define RULE_OP_MANGLE_PREPEND '^'
|
||||
#define RULE_OP_MANGLE_DELETE_FIRST '['
|
||||
#define RULE_OP_MANGLE_DELETE_LAST ']'
|
||||
#define RULE_OP_MANGLE_DELETE_AT 'D'
|
||||
#define RULE_OP_MANGLE_EXTRACT 'x'
|
||||
#define RULE_OP_MANGLE_OMIT 'O'
|
||||
#define RULE_OP_MANGLE_INSERT 'i'
|
||||
#define RULE_OP_MANGLE_OVERSTRIKE 'o'
|
||||
#define RULE_OP_MANGLE_TRUNCATE_AT '\''
|
||||
#define RULE_OP_MANGLE_REPLACE 's'
|
||||
#define RULE_OP_MANGLE_PURGECHAR '@'
|
||||
#define RULE_OP_MANGLE_TOGGLECASE_REC 'a'
|
||||
#define RULE_OP_MANGLE_DUPECHAR_FIRST 'z'
|
||||
#define RULE_OP_MANGLE_DUPECHAR_LAST 'Z'
|
||||
#define RULE_OP_MANGLE_DUPECHAR_ALL 'q'
|
||||
#define RULE_OP_MANGLE_EXTRACT_MEMORY 'X'
|
||||
#define RULE_OP_MANGLE_APPEND_MEMORY '4'
|
||||
#define RULE_OP_MANGLE_PREPEND_MEMORY '6'
|
||||
|
||||
#define RULE_OP_MEMORIZE_WORD 'M'
|
||||
|
||||
#define RULE_OP_REJECT_LESS '<'
|
||||
#define RULE_OP_REJECT_GREATER '>'
|
||||
#define RULE_OP_REJECT_CONTAIN '!'
|
||||
#define RULE_OP_REJECT_NOT_CONTAIN '/'
|
||||
#define RULE_OP_REJECT_EQUAL_FIRST '('
|
||||
#define RULE_OP_REJECT_EQUAL_LAST ')'
|
||||
#define RULE_OP_REJECT_EQUAL_AT '='
|
||||
#define RULE_OP_REJECT_CONTAINS '%'
|
||||
#define RULE_OP_REJECT_MEMORY 'Q'
|
||||
|
||||
/* hashcat only */
|
||||
#define RULE_OP_MANGLE_SWITCH_FIRST 'k'
|
||||
#define RULE_OP_MANGLE_SWITCH_LAST 'K'
|
||||
#define RULE_OP_MANGLE_SWITCH_AT '*'
|
||||
#define RULE_OP_MANGLE_CHR_SHIFTL 'L'
|
||||
#define RULE_OP_MANGLE_CHR_SHIFTR 'R'
|
||||
#define RULE_OP_MANGLE_CHR_INCR '+'
|
||||
#define RULE_OP_MANGLE_CHR_DECR '-'
|
||||
#define RULE_OP_MANGLE_REPLACE_NP1 '.'
|
||||
#define RULE_OP_MANGLE_REPLACE_NM1 ','
|
||||
#define RULE_OP_MANGLE_DUPEBLOCK_FIRST 'y'
|
||||
#define RULE_OP_MANGLE_DUPEBLOCK_LAST 'Y'
|
||||
#define RULE_OP_MANGLE_TITLE 'E'
|
||||
|
||||
#define INCR_RULES 10000
|
||||
|
||||
int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], u32 rp_gen_func_min, u32 rp_gen_func_max);
|
||||
#define RULE_RC_SYNTAX_ERROR -1
|
||||
#define RULE_RC_REJECT_ERROR -2
|
||||
|
||||
int _old_apply_rule (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, char out[BLOCK_SIZE]);
|
||||
|
||||
int cpu_rule_to_kernel_rule (char *rule_buf, uint rule_len, kernel_rule_t *rule);
|
||||
int kernel_rule_to_cpu_rule (char *rule_buf, kernel_rule_t *rule);
|
||||
|
||||
int run_rule_engine (const int rule_len, const char *rule_buf);
|
||||
|
||||
#endif // _RP_CPU_H
|
||||
|
@ -77,14 +77,6 @@ typedef enum hl_mode
|
||||
|
||||
} hl_mode_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *file_name;
|
||||
long seek;
|
||||
time_t ctime;
|
||||
|
||||
} outfile_data_t;
|
||||
|
||||
typedef enum attack_mode
|
||||
{
|
||||
ATTACK_MODE_STRAIGHT = 0,
|
||||
@ -133,7 +125,67 @@ typedef enum kern_run_mp
|
||||
|
||||
} kern_run_mp_t;
|
||||
|
||||
typedef enum rule_functions
|
||||
{
|
||||
RULE_OP_MANGLE_NOOP = ':',
|
||||
RULE_OP_MANGLE_LREST = 'l',
|
||||
RULE_OP_MANGLE_UREST = 'u',
|
||||
RULE_OP_MANGLE_LREST_UFIRST = 'c',
|
||||
RULE_OP_MANGLE_UREST_LFIRST = 'C',
|
||||
RULE_OP_MANGLE_TREST = 't',
|
||||
RULE_OP_MANGLE_TOGGLE_AT = 'T',
|
||||
RULE_OP_MANGLE_REVERSE = 'r',
|
||||
RULE_OP_MANGLE_DUPEWORD = 'd',
|
||||
RULE_OP_MANGLE_DUPEWORD_TIMES = 'p',
|
||||
RULE_OP_MANGLE_REFLECT = 'f',
|
||||
RULE_OP_MANGLE_ROTATE_LEFT = '{',
|
||||
RULE_OP_MANGLE_ROTATE_RIGHT = '}',
|
||||
RULE_OP_MANGLE_APPEND = '$',
|
||||
RULE_OP_MANGLE_PREPEND = '^',
|
||||
RULE_OP_MANGLE_DELETE_FIRST = '[',
|
||||
RULE_OP_MANGLE_DELETE_LAST = ']',
|
||||
RULE_OP_MANGLE_DELETE_AT = 'D',
|
||||
RULE_OP_MANGLE_EXTRACT = 'x',
|
||||
RULE_OP_MANGLE_OMIT = 'O',
|
||||
RULE_OP_MANGLE_INSERT = 'i',
|
||||
RULE_OP_MANGLE_OVERSTRIKE = 'o',
|
||||
RULE_OP_MANGLE_TRUNCATE_AT = '\'',
|
||||
RULE_OP_MANGLE_REPLACE = 's',
|
||||
RULE_OP_MANGLE_PURGECHAR = '@',
|
||||
RULE_OP_MANGLE_TOGGLECASE_REC = 'a',
|
||||
RULE_OP_MANGLE_DUPECHAR_FIRST = 'z',
|
||||
RULE_OP_MANGLE_DUPECHAR_LAST = 'Z',
|
||||
RULE_OP_MANGLE_DUPECHAR_ALL = 'q',
|
||||
RULE_OP_MANGLE_EXTRACT_MEMORY = 'X',
|
||||
RULE_OP_MANGLE_APPEND_MEMORY = '4',
|
||||
RULE_OP_MANGLE_PREPEND_MEMORY = '6',
|
||||
|
||||
RULE_OP_MEMORIZE_WORD = 'M',
|
||||
|
||||
RULE_OP_REJECT_LESS = '<',
|
||||
RULE_OP_REJECT_GREATER = '>',
|
||||
RULE_OP_REJECT_CONTAIN = '!',
|
||||
RULE_OP_REJECT_NOT_CONTAIN = '/',
|
||||
RULE_OP_REJECT_EQUAL_FIRST = '(',
|
||||
RULE_OP_REJECT_EQUAL_LAST = ')',
|
||||
RULE_OP_REJECT_EQUAL_AT = '=',
|
||||
RULE_OP_REJECT_CONTAINS = '%',
|
||||
RULE_OP_REJECT_MEMORY = 'Q',
|
||||
|
||||
RULE_OP_MANGLE_SWITCH_FIRST = 'k',
|
||||
RULE_OP_MANGLE_SWITCH_LAST = 'K',
|
||||
RULE_OP_MANGLE_SWITCH_AT = '*',
|
||||
RULE_OP_MANGLE_CHR_SHIFTL = 'L',
|
||||
RULE_OP_MANGLE_CHR_SHIFTR = 'R',
|
||||
RULE_OP_MANGLE_CHR_INCR = '+',
|
||||
RULE_OP_MANGLE_CHR_DECR = '-',
|
||||
RULE_OP_MANGLE_REPLACE_NP1 = '.',
|
||||
RULE_OP_MANGLE_REPLACE_NM1 = ',',
|
||||
RULE_OP_MANGLE_DUPEBLOCK_FIRST = 'y',
|
||||
RULE_OP_MANGLE_DUPEBLOCK_LAST = 'Y',
|
||||
RULE_OP_MANGLE_TITLE = 'E',
|
||||
|
||||
} rule_functions_t;
|
||||
|
||||
/**
|
||||
* structs
|
||||
@ -186,6 +238,14 @@ typedef struct
|
||||
|
||||
} hash_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *file_name;
|
||||
long seek;
|
||||
time_t ctime;
|
||||
|
||||
} outfile_data_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool enabled;
|
||||
|
@ -163,7 +163,7 @@ LFLAGS_CROSS_WIN := -lpsapi
|
||||
## Objects
|
||||
##
|
||||
|
||||
OBJS_ALL := affinity attack_mode autotune benchmark bitmap bitops common convert cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 data debugfile dictstat dispatch dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling filenames folder hash_management hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile powertune remove restore rp_cpu rp_kernel_on_cpu runtime session shared status stdout terminal thread timer tuningdb usage user_options version weak_hash wordlist
|
||||
OBJS_ALL := affinity attack_mode autotune benchmark bitmap bitops common convert cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 data debugfile dictstat dispatch dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling filenames folder hash_management hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile powertune remove restore rp rp_cpu rp_kernel_on_cpu runtime session shared status stdout terminal thread timer tuningdb usage user_options version weak_hash wordlist
|
||||
|
||||
NATIVE_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.o)
|
||||
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "data.h"
|
||||
#include "terminal.h"
|
||||
#include "status.h"
|
||||
#include "rp.h"
|
||||
#include "rp_cpu.h"
|
||||
#include "rp_kernel_on_cpu.h"
|
||||
#include "hlfmt.h"
|
||||
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "restore.h"
|
||||
#include "hash_management.h"
|
||||
#include "locking.h"
|
||||
#include "rp.h"
|
||||
#include "rp_cpu.h"
|
||||
#include "rp_kernel_on_cpu.h"
|
||||
#include "terminal.h"
|
||||
|
698
src/rp.c
Normal file
698
src/rp.c
Normal file
@ -0,0 +1,698 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#if defined (__APPLE__)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "shared.h"
|
||||
#include "rp.h"
|
||||
|
||||
static const char grp_op_nop[] =
|
||||
{
|
||||
RULE_OP_MANGLE_LREST,
|
||||
RULE_OP_MANGLE_UREST,
|
||||
RULE_OP_MANGLE_LREST_UFIRST,
|
||||
RULE_OP_MANGLE_UREST_LFIRST,
|
||||
RULE_OP_MANGLE_TREST,
|
||||
RULE_OP_MANGLE_REVERSE,
|
||||
RULE_OP_MANGLE_DUPEWORD,
|
||||
RULE_OP_MANGLE_REFLECT,
|
||||
RULE_OP_MANGLE_DELETE_FIRST,
|
||||
RULE_OP_MANGLE_DELETE_LAST,
|
||||
RULE_OP_MANGLE_ROTATE_LEFT,
|
||||
RULE_OP_MANGLE_ROTATE_RIGHT,
|
||||
RULE_OP_MANGLE_SWITCH_FIRST,
|
||||
RULE_OP_MANGLE_SWITCH_LAST,
|
||||
RULE_OP_MANGLE_DUPECHAR_ALL,
|
||||
RULE_OP_MANGLE_TITLE,
|
||||
RULE_OP_MANGLE_APPEND_MEMORY,
|
||||
RULE_OP_MANGLE_PREPEND_MEMORY,
|
||||
};
|
||||
|
||||
static const char grp_op_pos_p0[] =
|
||||
{
|
||||
RULE_OP_MANGLE_TOGGLE_AT,
|
||||
RULE_OP_MANGLE_DELETE_AT,
|
||||
RULE_OP_MANGLE_TRUNCATE_AT,
|
||||
RULE_OP_MANGLE_CHR_INCR,
|
||||
RULE_OP_MANGLE_CHR_DECR,
|
||||
RULE_OP_MANGLE_CHR_SHIFTL,
|
||||
RULE_OP_MANGLE_CHR_SHIFTR,
|
||||
RULE_OP_MANGLE_REPLACE_NP1,
|
||||
RULE_OP_MANGLE_REPLACE_NM1
|
||||
};
|
||||
|
||||
static const char grp_op_pos_p1[] =
|
||||
{
|
||||
RULE_OP_MANGLE_DUPEWORD_TIMES,
|
||||
RULE_OP_MANGLE_DUPECHAR_FIRST,
|
||||
RULE_OP_MANGLE_DUPECHAR_LAST,
|
||||
RULE_OP_MANGLE_DUPEBLOCK_FIRST,
|
||||
RULE_OP_MANGLE_DUPEBLOCK_LAST
|
||||
};
|
||||
|
||||
static const char grp_op_chr[] =
|
||||
{
|
||||
RULE_OP_MANGLE_APPEND,
|
||||
RULE_OP_MANGLE_PREPEND,
|
||||
RULE_OP_MANGLE_PURGECHAR
|
||||
};
|
||||
|
||||
static const char grp_op_chr_chr[] =
|
||||
{
|
||||
RULE_OP_MANGLE_REPLACE
|
||||
};
|
||||
|
||||
static const char grp_op_pos_chr[] =
|
||||
{
|
||||
RULE_OP_MANGLE_INSERT,
|
||||
RULE_OP_MANGLE_OVERSTRIKE
|
||||
};
|
||||
|
||||
static const char grp_op_pos_pos0[] =
|
||||
{
|
||||
RULE_OP_MANGLE_SWITCH_AT
|
||||
};
|
||||
|
||||
static const char grp_op_pos_pos1[] =
|
||||
{
|
||||
RULE_OP_MANGLE_EXTRACT,
|
||||
RULE_OP_MANGLE_OMIT
|
||||
};
|
||||
|
||||
static const char grp_op_pos1_pos2_pos3[] =
|
||||
{
|
||||
RULE_OP_MANGLE_EXTRACT_MEMORY
|
||||
};
|
||||
|
||||
static const char grp_pos[] =
|
||||
{
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B'
|
||||
};
|
||||
|
||||
bool class_num (const u8 c)
|
||||
{
|
||||
return ((c >= '0') && (c <= '9'));
|
||||
}
|
||||
|
||||
bool class_lower (const u8 c)
|
||||
{
|
||||
return ((c >= 'a') && (c <= 'z'));
|
||||
}
|
||||
|
||||
bool class_upper (const u8 c)
|
||||
{
|
||||
return ((c >= 'A') && (c <= 'Z'));
|
||||
}
|
||||
|
||||
bool class_alpha (const u8 c)
|
||||
{
|
||||
return (class_lower (c) || class_upper (c));
|
||||
}
|
||||
|
||||
int conv_ctoi (const u8 c)
|
||||
{
|
||||
if (class_num (c))
|
||||
{
|
||||
return c - '0';
|
||||
}
|
||||
else if (class_upper (c))
|
||||
{
|
||||
return c - 'A' + 10;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int conv_itoc (const u8 c)
|
||||
{
|
||||
if (c < 10)
|
||||
{
|
||||
return c + '0';
|
||||
}
|
||||
else if (c < 37)
|
||||
{
|
||||
return c + 'A' - 10;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], u32 rp_gen_func_min, u32 rp_gen_func_max)
|
||||
{
|
||||
u32 rp_gen_num = get_random_num (rp_gen_func_min, rp_gen_func_max);
|
||||
|
||||
u32 j;
|
||||
|
||||
u32 rule_pos = 0;
|
||||
|
||||
for (j = 0; j < rp_gen_num; j++)
|
||||
{
|
||||
u32 r = 0;
|
||||
u32 p1 = 0;
|
||||
u32 p2 = 0;
|
||||
u32 p3 = 0;
|
||||
|
||||
switch ((char) get_random_num (0, 9))
|
||||
{
|
||||
case 0:
|
||||
r = get_random_num (0, sizeof (grp_op_nop));
|
||||
rule_buf[rule_pos++] = grp_op_nop[r];
|
||||
break;
|
||||
|
||||
case 1:
|
||||
r = get_random_num (0, sizeof (grp_op_pos_p0));
|
||||
rule_buf[rule_pos++] = grp_op_pos_p0[r];
|
||||
p1 = get_random_num (0, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p1];
|
||||
break;
|
||||
|
||||
case 2:
|
||||
r = get_random_num (0, sizeof (grp_op_pos_p1));
|
||||
rule_buf[rule_pos++] = grp_op_pos_p1[r];
|
||||
p1 = get_random_num (1, 6);
|
||||
rule_buf[rule_pos++] = grp_pos[p1];
|
||||
break;
|
||||
|
||||
case 3:
|
||||
r = get_random_num (0, sizeof (grp_op_chr));
|
||||
rule_buf[rule_pos++] = grp_op_chr[r];
|
||||
p1 = get_random_num (0x20, 0x7e);
|
||||
rule_buf[rule_pos++] = (char) p1;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
r = get_random_num (0, sizeof (grp_op_chr_chr));
|
||||
rule_buf[rule_pos++] = grp_op_chr_chr[r];
|
||||
p1 = get_random_num (0x20, 0x7e);
|
||||
rule_buf[rule_pos++] = (char) p1;
|
||||
p2 = get_random_num (0x20, 0x7e);
|
||||
while (p1 == p2)
|
||||
p2 = get_random_num (0x20, 0x7e);
|
||||
rule_buf[rule_pos++] = (char) p2;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
r = get_random_num (0, sizeof (grp_op_pos_chr));
|
||||
rule_buf[rule_pos++] = grp_op_pos_chr[r];
|
||||
p1 = get_random_num (0, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p1];
|
||||
p2 = get_random_num (0x20, 0x7e);
|
||||
rule_buf[rule_pos++] = (char) p2;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
r = get_random_num (0, sizeof (grp_op_pos_pos0));
|
||||
rule_buf[rule_pos++] = grp_op_pos_pos0[r];
|
||||
p1 = get_random_num (0, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p1];
|
||||
p2 = get_random_num (0, sizeof (grp_pos));
|
||||
while (p1 == p2)
|
||||
p2 = get_random_num (0, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p2];
|
||||
break;
|
||||
|
||||
case 7:
|
||||
r = get_random_num (0, sizeof (grp_op_pos_pos1));
|
||||
rule_buf[rule_pos++] = grp_op_pos_pos1[r];
|
||||
p1 = get_random_num (0, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p1];
|
||||
p2 = get_random_num (1, sizeof (grp_pos));
|
||||
while (p1 == p2)
|
||||
p2 = get_random_num (1, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p2];
|
||||
break;
|
||||
|
||||
case 8:
|
||||
r = get_random_num (0, sizeof (grp_op_pos1_pos2_pos3));
|
||||
rule_buf[rule_pos++] = grp_op_pos1_pos2_pos3[r];
|
||||
p1 = get_random_num (0, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p1];
|
||||
p2 = get_random_num (1, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p1];
|
||||
p3 = get_random_num (0, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (rule_pos);
|
||||
}
|
||||
|
||||
#define INCR_POS if (++rule_pos == rule_len) return (-1)
|
||||
|
||||
#define SET_NAME(rule,val) (rule)->cmds[rule_cnt] = ((val) & 0xff) << 0
|
||||
#define SET_P0(rule,val) INCR_POS; (rule)->cmds[rule_cnt] |= ((val) & 0xff) << 8
|
||||
#define SET_P1(rule,val) INCR_POS; (rule)->cmds[rule_cnt] |= ((val) & 0xff) << 16
|
||||
#define GET_NAME(rule) rule_cmd = (((rule)->cmds[rule_cnt] >> 0) & 0xff)
|
||||
#define GET_P0(rule) INCR_POS; rule_buf[rule_pos] = (((rule)->cmds[rule_cnt] >> 8) & 0xff)
|
||||
#define GET_P1(rule) INCR_POS; rule_buf[rule_pos] = (((rule)->cmds[rule_cnt] >> 16) & 0xff)
|
||||
|
||||
#define SET_P0_CONV(rule,val) INCR_POS; (rule)->cmds[rule_cnt] |= ((conv_ctoi (val)) & 0xff) << 8
|
||||
#define SET_P1_CONV(rule,val) INCR_POS; (rule)->cmds[rule_cnt] |= ((conv_ctoi (val)) & 0xff) << 16
|
||||
#define GET_P0_CONV(rule) INCR_POS; rule_buf[rule_pos] = conv_itoc (((rule)->cmds[rule_cnt] >> 8) & 0xff)
|
||||
#define GET_P1_CONV(rule) INCR_POS; rule_buf[rule_pos] = conv_itoc (((rule)->cmds[rule_cnt] >> 16) & 0xff)
|
||||
|
||||
int cpu_rule_to_kernel_rule (char *rule_buf, uint rule_len, kernel_rule_t *rule)
|
||||
{
|
||||
uint rule_pos;
|
||||
uint rule_cnt;
|
||||
|
||||
for (rule_pos = 0, rule_cnt = 0; rule_pos < rule_len && rule_cnt < MAX_KERNEL_RULES; rule_pos++, rule_cnt++)
|
||||
{
|
||||
switch (rule_buf[rule_pos])
|
||||
{
|
||||
case ' ':
|
||||
rule_cnt--;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_NOOP:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_LREST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_UREST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_LREST_UFIRST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_UREST_LFIRST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TREST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TOGGLE_AT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REVERSE:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEWORD:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEWORD_TIMES:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REFLECT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_ROTATE_LEFT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_ROTATE_RIGHT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_APPEND:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_PREPEND:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DELETE_FIRST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DELETE_LAST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DELETE_AT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_EXTRACT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
SET_P1_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_OMIT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
SET_P1_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_INSERT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
SET_P1 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_OVERSTRIKE:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
SET_P1 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TRUNCATE_AT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REPLACE:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
SET_P1 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_PURGECHAR:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TOGGLECASE_REC:
|
||||
return -1;
|
||||
|
||||
case RULE_OP_MANGLE_DUPECHAR_FIRST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPECHAR_LAST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPECHAR_ALL:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_SWITCH_FIRST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_SWITCH_LAST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_SWITCH_AT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
SET_P1_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_SHIFTL:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_SHIFTR:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_INCR:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_DECR:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REPLACE_NP1:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REPLACE_NM1:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEBLOCK_FIRST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEBLOCK_LAST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TITLE:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (rule_pos < rule_len) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kernel_rule_to_cpu_rule (char *rule_buf, kernel_rule_t *rule)
|
||||
{
|
||||
uint rule_cnt;
|
||||
uint rule_pos;
|
||||
uint rule_len = HCBUFSIZ_LARGE - 1; // maximum possible len
|
||||
|
||||
char rule_cmd;
|
||||
|
||||
for (rule_cnt = 0, rule_pos = 0; rule_pos < rule_len && rule_cnt < MAX_KERNEL_RULES; rule_pos++, rule_cnt++)
|
||||
{
|
||||
GET_NAME (rule);
|
||||
|
||||
if (rule_cnt > 0) rule_buf[rule_pos++] = ' ';
|
||||
|
||||
switch (rule_cmd)
|
||||
{
|
||||
case RULE_OP_MANGLE_NOOP:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_LREST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_UREST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_LREST_UFIRST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_UREST_LFIRST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TREST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TOGGLE_AT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REVERSE:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEWORD:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEWORD_TIMES:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REFLECT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_ROTATE_LEFT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_ROTATE_RIGHT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_APPEND:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_PREPEND:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DELETE_FIRST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DELETE_LAST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DELETE_AT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_EXTRACT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
GET_P1_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_OMIT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
GET_P1_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_INSERT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
GET_P1 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_OVERSTRIKE:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
GET_P1 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TRUNCATE_AT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REPLACE:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0 (rule);
|
||||
GET_P1 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_PURGECHAR:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TOGGLECASE_REC:
|
||||
return -1;
|
||||
|
||||
case RULE_OP_MANGLE_DUPECHAR_FIRST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPECHAR_LAST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPECHAR_ALL:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_SWITCH_FIRST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_SWITCH_LAST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_SWITCH_AT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
GET_P1_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_SHIFTL:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_SHIFTR:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_INCR:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_DECR:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REPLACE_NP1:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REPLACE_NM1:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEBLOCK_FIRST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEBLOCK_LAST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TITLE:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
return rule_pos - 1;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (rule_cnt > 0)
|
||||
{
|
||||
return rule_pos;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
713
src/rp_cpu.c
713
src/rp_cpu.c
@ -9,178 +9,8 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "interface.h"
|
||||
#include "timer.h"
|
||||
#include "memory.h"
|
||||
#include "logging.h"
|
||||
#include "ext_OpenCL.h"
|
||||
#include "ext_ADL.h"
|
||||
#include "ext_nvapi.h"
|
||||
#include "ext_nvml.h"
|
||||
#include "ext_xnvctrl.h"
|
||||
#include "convert.h"
|
||||
#include "tuningdb.h"
|
||||
#include "thread.h"
|
||||
#include "opencl.h"
|
||||
#include "hwmon.h"
|
||||
#include "restore.h"
|
||||
#include "hash_management.h"
|
||||
#include "rp.h"
|
||||
#include "rp_cpu.h"
|
||||
#include "terminal.h"
|
||||
#include "mpsp.h"
|
||||
#include "rp_cpu.h"
|
||||
#include "outfile.h"
|
||||
#include "potfile.h"
|
||||
#include "debugfile.h"
|
||||
#include "loopback.h"
|
||||
#include "data.h"
|
||||
#include "shared.h"
|
||||
#include "rp_cpu.h"
|
||||
|
||||
static const char grp_op_nop[] =
|
||||
{
|
||||
RULE_OP_MANGLE_LREST,
|
||||
RULE_OP_MANGLE_UREST,
|
||||
RULE_OP_MANGLE_LREST_UFIRST,
|
||||
RULE_OP_MANGLE_UREST_LFIRST,
|
||||
RULE_OP_MANGLE_TREST,
|
||||
RULE_OP_MANGLE_REVERSE,
|
||||
RULE_OP_MANGLE_DUPEWORD,
|
||||
RULE_OP_MANGLE_REFLECT,
|
||||
RULE_OP_MANGLE_DELETE_FIRST,
|
||||
RULE_OP_MANGLE_DELETE_LAST,
|
||||
RULE_OP_MANGLE_ROTATE_LEFT,
|
||||
RULE_OP_MANGLE_ROTATE_RIGHT,
|
||||
RULE_OP_MANGLE_SWITCH_FIRST,
|
||||
RULE_OP_MANGLE_SWITCH_LAST,
|
||||
RULE_OP_MANGLE_DUPECHAR_ALL,
|
||||
RULE_OP_MANGLE_TITLE,
|
||||
RULE_OP_MANGLE_APPEND_MEMORY,
|
||||
RULE_OP_MANGLE_PREPEND_MEMORY,
|
||||
};
|
||||
|
||||
static const char grp_op_pos_p0[] =
|
||||
{
|
||||
RULE_OP_MANGLE_TOGGLE_AT,
|
||||
RULE_OP_MANGLE_DELETE_AT,
|
||||
RULE_OP_MANGLE_TRUNCATE_AT,
|
||||
RULE_OP_MANGLE_CHR_INCR,
|
||||
RULE_OP_MANGLE_CHR_DECR,
|
||||
RULE_OP_MANGLE_CHR_SHIFTL,
|
||||
RULE_OP_MANGLE_CHR_SHIFTR,
|
||||
RULE_OP_MANGLE_REPLACE_NP1,
|
||||
RULE_OP_MANGLE_REPLACE_NM1
|
||||
};
|
||||
|
||||
static const char grp_op_pos_p1[] =
|
||||
{
|
||||
RULE_OP_MANGLE_DUPEWORD_TIMES,
|
||||
RULE_OP_MANGLE_DUPECHAR_FIRST,
|
||||
RULE_OP_MANGLE_DUPECHAR_LAST,
|
||||
RULE_OP_MANGLE_DUPEBLOCK_FIRST,
|
||||
RULE_OP_MANGLE_DUPEBLOCK_LAST
|
||||
};
|
||||
|
||||
static const char grp_op_chr[] =
|
||||
{
|
||||
RULE_OP_MANGLE_APPEND,
|
||||
RULE_OP_MANGLE_PREPEND,
|
||||
RULE_OP_MANGLE_PURGECHAR
|
||||
};
|
||||
|
||||
static const char grp_op_chr_chr[] =
|
||||
{
|
||||
RULE_OP_MANGLE_REPLACE
|
||||
};
|
||||
|
||||
static const char grp_op_pos_chr[] =
|
||||
{
|
||||
RULE_OP_MANGLE_INSERT,
|
||||
RULE_OP_MANGLE_OVERSTRIKE
|
||||
};
|
||||
|
||||
static const char grp_op_pos_pos0[] =
|
||||
{
|
||||
RULE_OP_MANGLE_SWITCH_AT
|
||||
};
|
||||
|
||||
static const char grp_op_pos_pos1[] =
|
||||
{
|
||||
RULE_OP_MANGLE_EXTRACT,
|
||||
RULE_OP_MANGLE_OMIT
|
||||
};
|
||||
|
||||
static const char grp_op_pos1_pos2_pos3[] =
|
||||
{
|
||||
RULE_OP_MANGLE_EXTRACT_MEMORY
|
||||
};
|
||||
|
||||
static const char grp_pos[] =
|
||||
{
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B'
|
||||
};
|
||||
|
||||
static bool class_num (const u8 c)
|
||||
{
|
||||
return ((c >= '0') && (c <= '9'));
|
||||
}
|
||||
|
||||
static bool class_lower (const u8 c)
|
||||
{
|
||||
return ((c >= 'a') && (c <= 'z'));
|
||||
}
|
||||
|
||||
static bool class_upper (const u8 c)
|
||||
{
|
||||
return ((c >= 'A') && (c <= 'Z'));
|
||||
}
|
||||
|
||||
static bool class_alpha (const u8 c)
|
||||
{
|
||||
return (class_lower (c) || class_upper (c));
|
||||
}
|
||||
|
||||
static int conv_ctoi (const u8 c)
|
||||
{
|
||||
if (class_num (c))
|
||||
{
|
||||
return c - '0';
|
||||
}
|
||||
else if (class_upper (c))
|
||||
{
|
||||
return c - 'A' + 10;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int conv_itoc (const u8 c)
|
||||
{
|
||||
if (c < 10)
|
||||
{
|
||||
return c + '0';
|
||||
}
|
||||
else if (c < 37)
|
||||
{
|
||||
return c + 'A' - 10;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#define INCR_POS if (++rule_pos == rule_len) return (-1)
|
||||
#define SET_NAME(rule,val) (rule)->cmds[rule_cnt] = ((val) & 0xff) << 0
|
||||
#define SET_P0(rule,val) INCR_POS; (rule)->cmds[rule_cnt] |= ((val) & 0xff) << 8
|
||||
#define SET_P1(rule,val) INCR_POS; (rule)->cmds[rule_cnt] |= ((val) & 0xff) << 16
|
||||
#define MAX_KERNEL_RULES 31
|
||||
#define GET_NAME(rule) rule_cmd = (((rule)->cmds[rule_cnt] >> 0) & 0xff)
|
||||
#define GET_P0(rule) INCR_POS; rule_buf[rule_pos] = (((rule)->cmds[rule_cnt] >> 8) & 0xff)
|
||||
#define GET_P1(rule) INCR_POS; rule_buf[rule_pos] = (((rule)->cmds[rule_cnt] >> 16) & 0xff)
|
||||
|
||||
#define SET_P0_CONV(rule,val) INCR_POS; (rule)->cmds[rule_cnt] |= ((conv_ctoi (val)) & 0xff) << 8
|
||||
#define SET_P1_CONV(rule,val) INCR_POS; (rule)->cmds[rule_cnt] |= ((conv_ctoi (val)) & 0xff) << 16
|
||||
#define GET_P0_CONV(rule) INCR_POS; rule_buf[rule_pos] = conv_itoc (((rule)->cmds[rule_cnt] >> 8) & 0xff)
|
||||
#define GET_P1_CONV(rule) INCR_POS; rule_buf[rule_pos] = conv_itoc (((rule)->cmds[rule_cnt] >> 16) & 0xff)
|
||||
|
||||
#define NEXT_RULEPOS(rp) if (++(rp) == rule_len) return (RULE_RC_SYNTAX_ERROR)
|
||||
#define NEXT_RPTOI(r,rp,up) if (((up) = conv_ctoi ((r)[(rp)])) == -1) return (RULE_RC_SYNTAX_ERROR)
|
||||
@ -622,107 +452,6 @@ static int mangle_title (char arr[BLOCK_SIZE], int arr_len)
|
||||
return (arr_len);
|
||||
}
|
||||
|
||||
int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], u32 rp_gen_func_min, u32 rp_gen_func_max)
|
||||
{
|
||||
u32 rp_gen_num = get_random_num (rp_gen_func_min, rp_gen_func_max);
|
||||
|
||||
u32 j;
|
||||
|
||||
u32 rule_pos = 0;
|
||||
|
||||
for (j = 0; j < rp_gen_num; j++)
|
||||
{
|
||||
u32 r = 0;
|
||||
u32 p1 = 0;
|
||||
u32 p2 = 0;
|
||||
u32 p3 = 0;
|
||||
|
||||
switch ((char) get_random_num (0, 9))
|
||||
{
|
||||
case 0:
|
||||
r = get_random_num (0, sizeof (grp_op_nop));
|
||||
rule_buf[rule_pos++] = grp_op_nop[r];
|
||||
break;
|
||||
|
||||
case 1:
|
||||
r = get_random_num (0, sizeof (grp_op_pos_p0));
|
||||
rule_buf[rule_pos++] = grp_op_pos_p0[r];
|
||||
p1 = get_random_num (0, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p1];
|
||||
break;
|
||||
|
||||
case 2:
|
||||
r = get_random_num (0, sizeof (grp_op_pos_p1));
|
||||
rule_buf[rule_pos++] = grp_op_pos_p1[r];
|
||||
p1 = get_random_num (1, 6);
|
||||
rule_buf[rule_pos++] = grp_pos[p1];
|
||||
break;
|
||||
|
||||
case 3:
|
||||
r = get_random_num (0, sizeof (grp_op_chr));
|
||||
rule_buf[rule_pos++] = grp_op_chr[r];
|
||||
p1 = get_random_num (0x20, 0x7e);
|
||||
rule_buf[rule_pos++] = (char) p1;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
r = get_random_num (0, sizeof (grp_op_chr_chr));
|
||||
rule_buf[rule_pos++] = grp_op_chr_chr[r];
|
||||
p1 = get_random_num (0x20, 0x7e);
|
||||
rule_buf[rule_pos++] = (char) p1;
|
||||
p2 = get_random_num (0x20, 0x7e);
|
||||
while (p1 == p2)
|
||||
p2 = get_random_num (0x20, 0x7e);
|
||||
rule_buf[rule_pos++] = (char) p2;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
r = get_random_num (0, sizeof (grp_op_pos_chr));
|
||||
rule_buf[rule_pos++] = grp_op_pos_chr[r];
|
||||
p1 = get_random_num (0, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p1];
|
||||
p2 = get_random_num (0x20, 0x7e);
|
||||
rule_buf[rule_pos++] = (char) p2;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
r = get_random_num (0, sizeof (grp_op_pos_pos0));
|
||||
rule_buf[rule_pos++] = grp_op_pos_pos0[r];
|
||||
p1 = get_random_num (0, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p1];
|
||||
p2 = get_random_num (0, sizeof (grp_pos));
|
||||
while (p1 == p2)
|
||||
p2 = get_random_num (0, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p2];
|
||||
break;
|
||||
|
||||
case 7:
|
||||
r = get_random_num (0, sizeof (grp_op_pos_pos1));
|
||||
rule_buf[rule_pos++] = grp_op_pos_pos1[r];
|
||||
p1 = get_random_num (0, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p1];
|
||||
p2 = get_random_num (1, sizeof (grp_pos));
|
||||
while (p1 == p2)
|
||||
p2 = get_random_num (1, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p2];
|
||||
break;
|
||||
|
||||
case 8:
|
||||
r = get_random_num (0, sizeof (grp_op_pos1_pos2_pos3));
|
||||
rule_buf[rule_pos++] = grp_op_pos1_pos2_pos3[r];
|
||||
p1 = get_random_num (0, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p1];
|
||||
p2 = get_random_num (1, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p1];
|
||||
p3 = get_random_num (0, sizeof (grp_pos));
|
||||
rule_buf[rule_pos++] = grp_pos[p3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (rule_pos);
|
||||
}
|
||||
|
||||
int _old_apply_rule (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, char out[BLOCK_SIZE])
|
||||
{
|
||||
char mem[BLOCK_SIZE] = { 0 };
|
||||
@ -1062,445 +791,6 @@ int _old_apply_rule (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len,
|
||||
return (out_len);
|
||||
}
|
||||
|
||||
int cpu_rule_to_kernel_rule (char *rule_buf, uint rule_len, kernel_rule_t *rule)
|
||||
{
|
||||
uint rule_pos;
|
||||
uint rule_cnt;
|
||||
|
||||
for (rule_pos = 0, rule_cnt = 0; rule_pos < rule_len && rule_cnt < MAX_KERNEL_RULES; rule_pos++, rule_cnt++)
|
||||
{
|
||||
switch (rule_buf[rule_pos])
|
||||
{
|
||||
case ' ':
|
||||
rule_cnt--;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_NOOP:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_LREST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_UREST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_LREST_UFIRST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_UREST_LFIRST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TREST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TOGGLE_AT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REVERSE:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEWORD:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEWORD_TIMES:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REFLECT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_ROTATE_LEFT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_ROTATE_RIGHT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_APPEND:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_PREPEND:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DELETE_FIRST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DELETE_LAST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DELETE_AT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_EXTRACT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
SET_P1_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_OMIT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
SET_P1_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_INSERT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
SET_P1 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_OVERSTRIKE:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
SET_P1 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TRUNCATE_AT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REPLACE:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
SET_P1 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_PURGECHAR:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TOGGLECASE_REC:
|
||||
return -1;
|
||||
|
||||
case RULE_OP_MANGLE_DUPECHAR_FIRST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPECHAR_LAST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPECHAR_ALL:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_SWITCH_FIRST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_SWITCH_LAST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_SWITCH_AT:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
SET_P1_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_SHIFTL:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_SHIFTR:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_INCR:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_DECR:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REPLACE_NP1:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REPLACE_NM1:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEBLOCK_FIRST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEBLOCK_LAST:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
SET_P0_CONV (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TITLE:
|
||||
SET_NAME (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (rule_pos < rule_len) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kernel_rule_to_cpu_rule (char *rule_buf, kernel_rule_t *rule)
|
||||
{
|
||||
uint rule_cnt;
|
||||
uint rule_pos;
|
||||
uint rule_len = HCBUFSIZ_LARGE - 1; // maximum possible len
|
||||
|
||||
char rule_cmd;
|
||||
|
||||
for (rule_cnt = 0, rule_pos = 0; rule_pos < rule_len && rule_cnt < MAX_KERNEL_RULES; rule_pos++, rule_cnt++)
|
||||
{
|
||||
GET_NAME (rule);
|
||||
|
||||
if (rule_cnt > 0) rule_buf[rule_pos++] = ' ';
|
||||
|
||||
switch (rule_cmd)
|
||||
{
|
||||
case RULE_OP_MANGLE_NOOP:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_LREST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_UREST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_LREST_UFIRST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_UREST_LFIRST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TREST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TOGGLE_AT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REVERSE:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEWORD:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEWORD_TIMES:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REFLECT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_ROTATE_LEFT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_ROTATE_RIGHT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_APPEND:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_PREPEND:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DELETE_FIRST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DELETE_LAST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DELETE_AT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_EXTRACT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
GET_P1_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_OMIT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
GET_P1_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_INSERT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
GET_P1 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_OVERSTRIKE:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
GET_P1 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TRUNCATE_AT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REPLACE:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0 (rule);
|
||||
GET_P1 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_PURGECHAR:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TOGGLECASE_REC:
|
||||
return -1;
|
||||
|
||||
case RULE_OP_MANGLE_DUPECHAR_FIRST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPECHAR_LAST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPECHAR_ALL:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_SWITCH_FIRST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_SWITCH_LAST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_SWITCH_AT:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
GET_P1_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_SHIFTL:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_SHIFTR:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_INCR:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_CHR_DECR:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REPLACE_NP1:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REPLACE_NM1:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEBLOCK_FIRST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_DUPEBLOCK_LAST:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
GET_P0_CONV (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TITLE:
|
||||
rule_buf[rule_pos] = rule_cmd;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
return rule_pos - 1;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (rule_cnt > 0)
|
||||
{
|
||||
return rule_pos;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int run_rule_engine (const int rule_len, const char *rule_buf)
|
||||
{
|
||||
if (rule_len == 0)
|
||||
@ -1514,4 +804,3 @@ int run_rule_engine (const int rule_len, const char *rule_buf)
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "rp_cpu.h"
|
||||
#include "rp_kernel_on_cpu.h"
|
||||
|
||||
static u32 generate_cmask (u32 buf)
|
||||
|
Loading…
Reference in New Issue
Block a user