Lines 120-127
static int move_rules(struct ip_fw_chain *chain, ip_fw3_opheader *op3,
Link Here
|
120 |
struct sockopt_data *sd); |
120 |
struct sockopt_data *sd); |
121 |
static int manage_sets(struct ip_fw_chain *chain, ip_fw3_opheader *op3, |
121 |
static int manage_sets(struct ip_fw_chain *chain, ip_fw3_opheader *op3, |
122 |
struct sockopt_data *sd); |
122 |
struct sockopt_data *sd); |
123 |
static int dump_soptcodes(struct ip_fw_chain *chain, ip_fw3_opheader *op3, |
|
|
124 |
struct sockopt_data *sd); |
125 |
static int dump_srvobjects(struct ip_fw_chain *chain, ip_fw3_opheader *op3, |
123 |
static int dump_srvobjects(struct ip_fw_chain *chain, ip_fw3_opheader *op3, |
126 |
struct sockopt_data *sd); |
124 |
struct sockopt_data *sd); |
127 |
|
125 |
|
Lines 150-156
static struct ipfw_sopt_handler scodes[] = {
Link Here
|
150 |
{ IP_FW_SET_SWAP, 0, HDIR_SET, manage_sets }, |
148 |
{ IP_FW_SET_SWAP, 0, HDIR_SET, manage_sets }, |
151 |
{ IP_FW_SET_MOVE, 0, HDIR_SET, manage_sets }, |
149 |
{ IP_FW_SET_MOVE, 0, HDIR_SET, manage_sets }, |
152 |
{ IP_FW_SET_ENABLE, 0, HDIR_SET, manage_sets }, |
150 |
{ IP_FW_SET_ENABLE, 0, HDIR_SET, manage_sets }, |
153 |
{ IP_FW_DUMP_SOPTCODES, 0, HDIR_GET, dump_soptcodes }, |
|
|
154 |
{ IP_FW_DUMP_SRVOBJECTS,0, HDIR_GET, dump_srvobjects }, |
151 |
{ IP_FW_DUMP_SRVOBJECTS,0, HDIR_GET, dump_srvobjects }, |
155 |
}; |
152 |
}; |
156 |
|
153 |
|
Lines 3096-3152
add_rules(struct ip_fw_chain *chain, ip_fw3_opheader *op3,
Link Here
|
3096 |
return (error); |
3093 |
return (error); |
3097 |
} |
3094 |
} |
3098 |
|
3095 |
|
3099 |
/* |
|
|
3100 |
* Lists all sopts currently registered. |
3101 |
* Data layout (v0)(current): |
3102 |
* Request: [ ipfw_obj_lheader ], size = ipfw_obj_lheader.size |
3103 |
* Reply: [ ipfw_obj_lheader ipfw_sopt_info x N ] |
3104 |
* |
3105 |
* Returns 0 on success |
3106 |
*/ |
3107 |
static int |
3108 |
dump_soptcodes(struct ip_fw_chain *chain, ip_fw3_opheader *op3, |
3109 |
struct sockopt_data *sd) |
3110 |
{ |
3111 |
struct _ipfw_obj_lheader *olh; |
3112 |
ipfw_sopt_info *i; |
3113 |
struct ipfw_sopt_handler *sh; |
3114 |
uint32_t count, n, size; |
3115 |
|
3116 |
olh = (struct _ipfw_obj_lheader *)ipfw_get_sopt_header(sd,sizeof(*olh)); |
3117 |
if (olh == NULL) |
3118 |
return (EINVAL); |
3119 |
if (sd->valsize < olh->size) |
3120 |
return (EINVAL); |
3121 |
|
3122 |
CTL3_LOCK(); |
3123 |
count = ctl3_hsize; |
3124 |
size = count * sizeof(ipfw_sopt_info) + sizeof(ipfw_obj_lheader); |
3125 |
|
3126 |
/* Fill in header regadless of buffer size */ |
3127 |
olh->count = count; |
3128 |
olh->objsize = sizeof(ipfw_sopt_info); |
3129 |
|
3130 |
if (size > olh->size) { |
3131 |
olh->size = size; |
3132 |
CTL3_UNLOCK(); |
3133 |
return (ENOMEM); |
3134 |
} |
3135 |
olh->size = size; |
3136 |
|
3137 |
for (n = 1; n <= count; n++) { |
3138 |
i = (ipfw_sopt_info *)ipfw_get_sopt_space(sd, sizeof(*i)); |
3139 |
KASSERT(i != NULL, ("previously checked buffer is not enough")); |
3140 |
sh = &ctl3_handlers[n]; |
3141 |
i->opcode = sh->opcode; |
3142 |
i->version = sh->version; |
3143 |
i->refcnt = sh->refcnt; |
3144 |
} |
3145 |
CTL3_UNLOCK(); |
3146 |
|
3147 |
return (0); |
3148 |
} |
3149 |
|
3150 |
/* |
3096 |
/* |
3151 |
* Compares two opcodes. |
3097 |
* Compares two opcodes. |
3152 |
* Used both in qsort() and bsearch(). |
3098 |
* Used both in qsort() and bsearch(). |