Changeset 745 for trunk/server/source4/nbt_server/register.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source4/nbt_server/register.c
r414 r745 94 94 io.in.name = iname->name; 95 95 io.in.dest_addr = iface->bcast_address; 96 io.in.dest_port = lp _nbt_port(iface->nbtsrv->task->lp_ctx);96 io.in.dest_port = lpcfg_nbt_port(iface->nbtsrv->task->lp_ctx); 97 97 io.in.address = iface->ip_address; 98 98 io.in.nb_flags = iname->nb_flags; … … 119 119 { 120 120 uint32_t refresh_time; 121 uint32_t max_refresh_time = lp _parm_int(iname->iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "max_refresh_time", 7200);121 uint32_t max_refresh_time = lpcfg_parm_int(iname->iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "max_refresh_time", 7200); 122 122 123 123 refresh_time = MIN(max_refresh_time, iname->ttl/2); … … 129 129 } 130 130 131 struct nbtd_register_name_state { 132 struct nbtd_iface_name *iname; 133 struct nbt_name_register_bcast io; 134 }; 131 135 132 136 /* 133 137 a name registration has completed 134 138 */ 135 static void nbtd_register_handler(struct composite_context *creq) 136 { 137 struct nbtd_iface_name *iname = talloc_get_type(creq->async.private_data, 138 struct nbtd_iface_name); 139 static void nbtd_register_name_handler(struct tevent_req *subreq) 140 { 141 struct nbtd_register_name_state *state = 142 tevent_req_callback_data(subreq, 143 struct nbtd_register_name_state); 144 struct nbtd_iface_name *iname = state->iname; 139 145 NTSTATUS status; 140 TALLOC_CTX *tmp_ctx = talloc_new(iname); 141 142 status = nbt_name_register_bcast_recv(creq);146 147 status = nbt_name_register_bcast_recv(subreq); 148 TALLOC_FREE(subreq); 143 149 if (NT_STATUS_IS_OK(status)) { 144 150 /* good - nobody complained about our registration */ 145 151 iname->nb_flags |= NBT_NM_ACTIVE; 146 152 DEBUG(3,("Registered %s with %s on interface %s\n", 147 nbt_name_string( tmp_ctx, &iname->name),153 nbt_name_string(state, &iname->name), 148 154 iname->iface->ip_address, iname->iface->bcast_address)); 149 155 iname->registration_time = timeval_current(); 150 talloc_free( tmp_ctx);156 talloc_free(state); 151 157 nbtd_start_refresh_timer(iname); 152 158 return; … … 157 163 158 164 DEBUG(1,("Error registering %s with %s on interface %s - %s\n", 159 nbt_name_string( tmp_ctx, &iname->name),165 nbt_name_string(state, &iname->name), 160 166 iname->iface->ip_address, iname->iface->bcast_address, 161 167 nt_errstr(status))); 162 talloc_free( tmp_ctx);168 talloc_free(state); 163 169 } 164 170 … … 172 178 { 173 179 struct nbtd_iface_name *iname; 174 const char *scope = lp _netbios_scope(iface->nbtsrv->task->lp_ctx);175 struct nbt _name_register_bcast io;176 struct composite_context *creq;180 const char *scope = lpcfg_netbios_scope(iface->nbtsrv->task->lp_ctx); 181 struct nbtd_register_name_state *state; 182 struct tevent_req *subreq; 177 183 struct nbtd_server *nbtsrv = iface->nbtsrv; 178 184 … … 189 195 } 190 196 iname->nb_flags = nb_flags; 191 iname->ttl = lp _parm_int(iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "bcast_ttl", 300000);197 iname->ttl = lpcfg_parm_int(iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "bcast_ttl", 300000); 192 198 iname->registration_time = timeval_zero(); 193 199 iname->wins_server = NULL; … … 209 215 } 210 216 217 state = talloc_zero(iname, struct nbtd_register_name_state); 218 if (state == NULL) { 219 return; 220 } 221 222 state->iname = iname; 223 211 224 /* setup a broadcast name registration request */ 212 io.in.name= iname->name;213 io.in.dest_addr= iface->bcast_address;214 io.in.dest_port = lp_nbt_port(iface->nbtsrv->task->lp_ctx);215 io.in.address= iface->ip_address;216 io.in.nb_flags= nb_flags;217 io.in.ttl= iname->ttl;225 state->io.in.name = iname->name; 226 state->io.in.dest_addr = iface->bcast_address; 227 state->io.in.dest_port = lpcfg_nbt_port(iface->nbtsrv->task->lp_ctx); 228 state->io.in.address = iface->ip_address; 229 state->io.in.nb_flags = nb_flags; 230 state->io.in.ttl = iname->ttl; 218 231 219 232 nbtsrv->stats.total_sent++; 220 creq = nbt_name_register_bcast_send(iface->nbtsock, &io); 221 if (creq == NULL) return; 222 223 creq->async.fn = nbtd_register_handler; 224 creq->async.private_data = iname; 233 234 subreq = nbt_name_register_bcast_send(state, nbtsrv->task->event_ctx, 235 iface->nbtsock, &state->io); 236 if (subreq == NULL) { 237 return; 238 } 239 240 tevent_req_set_callback(subreq, nbtd_register_name_handler, state); 225 241 } 226 242 … … 263 279 /* note that we don't initially mark the names "ACTIVE". They are 264 280 marked active once registration is successful */ 265 nbtd_register_name(nbtsrv, lp _netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_CLIENT, nb_flags);266 nbtd_register_name(nbtsrv, lp _netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_USER, nb_flags);267 nbtd_register_name(nbtsrv, lp _netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_SERVER, nb_flags);268 269 aliases = lp _netbios_aliases(nbtsrv->task->lp_ctx);281 nbtd_register_name(nbtsrv, lpcfg_netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_CLIENT, nb_flags); 282 nbtd_register_name(nbtsrv, lpcfg_netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_USER, nb_flags); 283 nbtd_register_name(nbtsrv, lpcfg_netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_SERVER, nb_flags); 284 285 aliases = lpcfg_netbios_aliases(nbtsrv->task->lp_ctx); 270 286 while (aliases && aliases[0]) { 271 287 nbtd_register_name(nbtsrv, aliases[0], NBT_NAME_CLIENT, nb_flags); … … 274 290 } 275 291 276 if (lp _server_role(nbtsrv->task->lp_ctx) == ROLE_DOMAIN_CONTROLLER) {292 if (lpcfg_server_role(nbtsrv->task->lp_ctx) == ROLE_DOMAIN_CONTROLLER) { 277 293 bool is_pdc = samdb_is_pdc(nbtsrv->sam_ctx); 278 294 if (is_pdc) { 279 nbtd_register_name(nbtsrv, lp _workgroup(nbtsrv->task->lp_ctx),295 nbtd_register_name(nbtsrv, lpcfg_workgroup(nbtsrv->task->lp_ctx), 280 296 NBT_NAME_PDC, nb_flags); 281 297 } 282 nbtd_register_name(nbtsrv, lp _workgroup(nbtsrv->task->lp_ctx),298 nbtd_register_name(nbtsrv, lpcfg_workgroup(nbtsrv->task->lp_ctx), 283 299 NBT_NAME_LOGON, nb_flags | NBT_NM_GROUP); 284 300 } 285 301 286 302 nb_flags |= NBT_NM_GROUP; 287 nbtd_register_name(nbtsrv, lp _workgroup(nbtsrv->task->lp_ctx), NBT_NAME_CLIENT, nb_flags);303 nbtd_register_name(nbtsrv, lpcfg_workgroup(nbtsrv->task->lp_ctx), NBT_NAME_CLIENT, nb_flags); 288 304 289 305 nb_flags |= NBT_NM_PERMANENT;
Note:
See TracChangeset
for help on using the changeset viewer.