static ssize_t mydev_write(struct file *filep, const char *buffer, size_t len, loff_t *offset){
copy_from_user(ips[i], buffer,256);
printk(KERN_INFO "ips: %s \n", ips[i]);
i++;
if(strncmp(ips[0],"wh",2)==0){
BORW=0;
int rete1 = nf_register_net_hook(&init_net, &w_drop);
if(rete1){
printk(KERN_ALERT "FAILED\n");
}
printk(KERN_INFO "white list\n");
}
else if(strncmp(ips[0],"bl",2)==0){
BORW=1;
int rete = nf_register_net_hook(&init_net, &b_drop);
if(rete){
printk(KERN_ALERT "FAILED\n");
}
printk(KERN_INFO "block list\n");
}
else{
BORW=1;
int rete = nf_register_net_hook(&init_net, &b_drop);
if(rete){
printk(KERN_ALERT "FAILED\n");
}
printk(KERN_INFO "defult is block list\n");
}
return len;
}
copy_from_user(ips[i], buffer,256); printk(KERN_INFO "ips: %s \n", ips[i]); i++; if(strncmp(ips[0],"wh",2)==0){
почему он работает,
как его можно переписать, чтобы было удобнее читать?
static ssize_t mydev_write(struct file * filep, const char * buffer, size_t len, loff_t * offset) {
copy_from_user(ips[i], buffer, 256);
printk(KERN_INFO "ips: %s \n", ips[i]);
i++;
if (strncmp(ips[0], "wh", 2) == 0) {
BORW = 0;
if (nf_register_net_hook( & init_net, &w_drop) {
printk(KERN_ALERT "FAILED\n");
}
printk(KERN_INFO "white list\n");
return len;
}
if (strncmp(ips[0], "bl", 2) == 0) {
BORW = 1;
if (nf_register_net_hook( & init_net, &b_drop)) {
printk(KERN_ALERT "FAILED\n");
}
printk(KERN_INFO "block list\n");
return len;
}
BORW = 1;
if (nf_register_net_hook( & init_net, &b_drop)) {
printk(KERN_ALERT "FAILED\n");
}
printk(KERN_INFO "defult is block list\n");
return len;
}