Beispiel #1
0
void proxy_t::routeHandlesProcessRequest(
    const McRequestWithMcOp<mc_op_stats>& req,
    std::unique_ptr<ProxyRequestContextTyped<
      McRequestWithMcOp<mc_op_stats>>> ctx) {

  ctx->sendReply(stats_reply(this, req.fullKey()));
}
Beispiel #2
0
/**Processes the actions received from the socket.
 * returns
 * 	-1 on error
 * 	0 on success
 */
int process_action(as_p the_as)
{
   unsigned int ac_len;
   ac_len=(the_as->ac_buffer.s[0]<<24)|(the_as->ac_buffer.s[1]<<16)|(the_as->ac_buffer.s[2]<<8)|((the_as->ac_buffer.s[3])&0xFF);
   /*yeah, it comes in network byte order*/
   /*if ac_len > BUF_SIZE then a flag should be put on the AS so that the whole length
    * of the action is skipped, until a mechanism for handling big packets is implemented*/
   if(use_stats)
      stats_reply();
   if(ac_len>AS_BUF_SIZE){
      LM_WARN("action too big (%d)!!! should be skipped and"
			  " an error returned!\n",ac_len);
      return -1;
   }
   while (the_as->ac_buffer.len>=ac_len) {
      LM_DBG("Processing action %d bytes long\n",ac_len);
      switch(the_as->ac_buffer.s[4]){
	 case REPLY_PROV:
	 case REPLY_FIN:
	    LM_DBG("Processing a REPLY action from AS (length=%d): %.*s\n",
				ac_len,the_as->name.len,the_as->name.s);
	    ac_reply(the_as,the_as->ac_buffer.s+5,ac_len-5);
	    break;
	 case UAC_REQ:
	    LM_DBG("Processing an UAC REQUEST action from AS (length=%d): %.*s\n",
				ac_len,the_as->name.len,the_as->name.s);
	    ac_uac_req(the_as,the_as->ac_buffer.s+5,ac_len-5);
	    break;
	 case AC_CANCEL:
	    LM_DBG("Processing a CANCEL REQUEST action from AS (length=%d): %.*s\n",
				ac_len,the_as->name.len,the_as->name.s);
	    ac_cancel(the_as,the_as->ac_buffer.s+5,ac_len-5);
	    break;
	 case SL_MSG:
	    LM_DBG("Processing a STATELESS MESSAGE action from AS (length=%d): %.*s\n",
				ac_len,the_as->name.len,the_as->name.s);
	    ac_sl_msg(the_as,the_as->ac_buffer.s+5,ac_len-5);
	    break;
	 case JAIN_PONG:
	    LM_DBG("Processing a PONG\n");
	    ac_jain_pong(the_as,the_as->ac_buffer.s+5,ac_len-5);
	    break;
	 default:
	    LM_DBG("Processing a UNKNOWN TYPE action from AS (length=%d): %.*s\n",
				ac_len,the_as->name.len,the_as->name.s);
	    break;
      }
      memmove(the_as->ac_buffer.s,the_as->ac_buffer.s+ac_len,(the_as->ac_buffer.len)-ac_len);
      (the_as->ac_buffer.len)-=ac_len;
      if(the_as->ac_buffer.len>5){
	 ac_len=(the_as->ac_buffer.s[0]<<24)|(the_as->ac_buffer.s[1]<<16)|(the_as->ac_buffer.s[2]<<8)|((the_as->ac_buffer.s[3])&0xFF);
      }else{
	 return 0;
      }
   }
   return 0;
}