|
|
|
@ -102,14 +102,14 @@ int process_request(NEW_CTL_MSG *mp, NEW_CTL_RESPONSE *rp, const char* theirhos
|
|
|
|
|
print_request("process_request", mp);
|
|
|
|
|
|
|
|
|
|
if (!prepare_response(mp, rp))
|
|
|
|
|
return PROC_RETQ_ERR;
|
|
|
|
|
return PROC_REQ_ERR;
|
|
|
|
|
|
|
|
|
|
/* Ensure null-termination */
|
|
|
|
|
mp->l_name[sizeof(mp->l_name)-1] = 0;
|
|
|
|
|
mp->r_name[sizeof(mp->r_name)-1] = 0;
|
|
|
|
|
mp->r_tty[sizeof(mp->r_tty)-1] = 0;
|
|
|
|
|
|
|
|
|
|
ret = PROC_RETQ_OK;
|
|
|
|
|
ret = PROC_REQ_OK;
|
|
|
|
|
|
|
|
|
|
switch (mp->type) {
|
|
|
|
|
|
|
|
|
@ -121,8 +121,8 @@ int process_request(NEW_CTL_MSG *mp, NEW_CTL_RESPONSE *rp, const char* theirhos
|
|
|
|
|
|
|
|
|
|
/* Store in table if normal announce or answmach replacing it.
|
|
|
|
|
Not if re-announce, nor if error, nor for forwarding machine */
|
|
|
|
|
if ((ret == PROC_RETQ_OK) || (ret == PROC_RETQ_ANSWMACH_NOT_LOGGED)
|
|
|
|
|
|| (ret == PROC_RETQ_ANSWMACH_NOT_HERE))
|
|
|
|
|
if ((ret == PROC_REQ_OK) || (ret == PROC_REQ_ANSWMACH_NOT_LOGGED)
|
|
|
|
|
|| (ret == PROC_REQ_ANSWMACH_NOT_HERE))
|
|
|
|
|
ktable->insert_table(mp, rp, 0L);
|
|
|
|
|
|
|
|
|
|
case LEAVE_INVITE:
|
|
|
|
@ -143,7 +143,7 @@ int process_request(NEW_CTL_MSG *mp, NEW_CTL_RESPONSE *rp, const char* theirhos
|
|
|
|
|
rp->answer = SUCCESS;
|
|
|
|
|
} else {
|
|
|
|
|
if (ForwMachine::forwMachProcessLookup(ktable->getTable(), mp)) {
|
|
|
|
|
ret = PROC_RETQ_FORWMACH; // Don't send any response, forwmach will do it
|
|
|
|
|
ret = PROC_REQ_FORWMACH; // Don't send any response, forwmach will do it
|
|
|
|
|
} else
|
|
|
|
|
rp->answer = NOT_HERE;
|
|
|
|
|
}
|
|
|
|
@ -157,7 +157,7 @@ int process_request(NEW_CTL_MSG *mp, NEW_CTL_RESPONSE *rp, const char* theirhos
|
|
|
|
|
rp->answer = UNKNOWN_REQUEST;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (ret != PROC_RETQ_FORWMACH)
|
|
|
|
|
if (ret != PROC_REQ_FORWMACH)
|
|
|
|
|
print_response("=> response", rp);
|
|
|
|
|
if (mp->vers == 0) { // it's kotalkd talking to us.
|
|
|
|
|
// Let's prepare an OTALK response, shifting the first 2 fields
|
|
|
|
@ -187,7 +187,7 @@ int do_announce(NEW_CTL_MSG *mp, NEW_CTL_RESPONSE *rp, const char* theirhost, in
|
|
|
|
|
ktalk_debug("dupannounce %d", mp->id_num);
|
|
|
|
|
rp->id_num = htonl(ptr->id_num);
|
|
|
|
|
rp->answer = SUCCESS;
|
|
|
|
|
return PROC_RETQ_ERR;
|
|
|
|
|
return PROC_REQ_ERR;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (ptr == (NEW_CTL_MSG *) 0) { /* Not already in the table */
|
|
|
|
@ -202,7 +202,7 @@ int do_announce(NEW_CTL_MSG *mp, NEW_CTL_RESPONSE *rp, const char* theirhost, in
|
|
|
|
|
(FWR & FWT) : we'll receive the LOOK_UP */
|
|
|
|
|
ktable->insert_table(mp, 0L, fwm);
|
|
|
|
|
fwm->start(mp->id_num);
|
|
|
|
|
return PROC_RETQ_FORWMACH;
|
|
|
|
|
return PROC_REQ_FORWMACH;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -223,7 +223,7 @@ int do_announce(NEW_CTL_MSG *mp, NEW_CTL_RESPONSE *rp, const char* theirhost, in
|
|
|
|
|
ktalk_debug("Not logged.");
|
|
|
|
|
rp->answer = SUCCESS;
|
|
|
|
|
endpwent();
|
|
|
|
|
return PROC_RETQ_ANSWMACH_NOT_LOGGED; /* answer machine. */
|
|
|
|
|
return PROC_REQ_ANSWMACH_NOT_LOGGED; /* answer machine. */
|
|
|
|
|
} else
|
|
|
|
|
{ /* Non-existent user ... */
|
|
|
|
|
endpwent();
|
|
|
|
@ -236,11 +236,11 @@ int do_announce(NEW_CTL_MSG *mp, NEW_CTL_RESPONSE *rp, const char* theirhost, in
|
|
|
|
|
case 2: /* Paranoid setting. Do nothing. */
|
|
|
|
|
ktalk_debug("Paranoid setting. Do nothing.");
|
|
|
|
|
rp->answer = NOT_HERE;
|
|
|
|
|
return PROC_RETQ_ERR;
|
|
|
|
|
return PROC_REQ_ERR;
|
|
|
|
|
case 0: /* Launch answering machine. */
|
|
|
|
|
ktalk_debug("Not here.");
|
|
|
|
|
rp->answer = SUCCESS;
|
|
|
|
|
return PROC_RETQ_ANSWMACH_NOT_HERE;
|
|
|
|
|
return PROC_REQ_ANSWMACH_NOT_HERE;
|
|
|
|
|
case 1: /* NEU_user will take the talk. */
|
|
|
|
|
ktalk_debug("Not here. I ll take the talk.");
|
|
|
|
|
fwm = new ForwMachine(mp, Options.NEU_user,
|
|
|
|
@ -248,14 +248,14 @@ int do_announce(NEW_CTL_MSG *mp, NEW_CTL_RESPONSE *rp, const char* theirhost, in
|
|
|
|
|
/* store in table, because we'll receive the LOOK_UP */
|
|
|
|
|
ktable->insert_table(mp, 0L, fwm);
|
|
|
|
|
fwm->start(mp->id_num);
|
|
|
|
|
return PROC_RETQ_FORWMACH;
|
|
|
|
|
return PROC_REQ_FORWMACH;
|
|
|
|
|
} /* switch */
|
|
|
|
|
} /* getpwnam */
|
|
|
|
|
} /* result */
|
|
|
|
|
else {
|
|
|
|
|
ktalk_debug("not SUCCESS, nor NOT_HERE");
|
|
|
|
|
rp->answer = result; /* not SUCCESS, nor NOT_HERE*/
|
|
|
|
|
return PROC_RETQ_ERR;
|
|
|
|
|
return PROC_REQ_ERR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -266,9 +266,9 @@ int do_announce(NEW_CTL_MSG *mp, NEW_CTL_RESPONSE *rp, const char* theirhost, in
|
|
|
|
|
|
|
|
|
|
if (ptr == (NEW_CTL_MSG *) 0) { /* Not already in the table => announce */
|
|
|
|
|
rp->answer = announce(mp, theirhost, disp, usercfg, callee);
|
|
|
|
|
if (rp->answer == PERMISSION_DENIED) return PROC_RETQ_ERR;
|
|
|
|
|
if (rp->answer == PERMISSION_DENIED) return PROC_REQ_ERR;
|
|
|
|
|
ktalk_debug("Announce done.");
|
|
|
|
|
return PROC_RETQ_OK;
|
|
|
|
|
return PROC_REQ_OK;
|
|
|
|
|
} else {
|
|
|
|
|
/* This is an explicit re-announce, so update the id_num
|
|
|
|
|
* field to avoid duplicates and re-announce the talk. */
|
|
|
|
@ -279,7 +279,7 @@ int do_announce(NEW_CTL_MSG *mp, NEW_CTL_RESPONSE *rp, const char* theirhost, in
|
|
|
|
|
ptr->id_num = new_id_num; /* update in the table */
|
|
|
|
|
rp->id_num = htonl(ptr->id_num);
|
|
|
|
|
rp->answer = announce(mp, theirhost, disp, usercfg, callee);
|
|
|
|
|
return PROC_RETQ_ANSWMACH;
|
|
|
|
|
return PROC_REQ_ANSWMACH;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|