예제 #1
1
//  ------------------------------------------------------------------------
//  ------------------------------------------------------------------------
void entering_info( DWORD SesId, DWORD SesTyp, HANDLE token, LPVOID param ){	//определение пользователя
    char *wuser = NULL;
    char *bufa = NULL;
    char *whost = NULL;
    DWORD usersize = 0;
    DWORD hostsize = 0;
    DWORD size = 0;
//  --
    if((!WTSQuerySessionInformation( WTS_CURRENT_SERVER_HANDLE, SesId, WTSUserName, &wuser, &usersize ))
    ||(!WTSQuerySessionInformation( WTS_CURRENT_SERVER_HANDLE, SesId, WTSClientAddress, &bufa, &size ))){
        prn_err( "WTSQuerySessionInformation failed.", GetLastError() );
        return;
    }else if( bufa ){
        WTS_CLIENT_ADDRESS *pAddr = (WTS_CLIENT_ADDRESS *) bufa;
        if(!WTSQuerySessionInformation( WTS_CURRENT_SERVER_HANDLE, SesId, WTSClientName, &whost, &hostsize )){
            prn_err( "WTSQuerySessionInformation failed.", GetLastError() );
        }else{
            char bs[10];
            ZeroMemory(&bs, 12 );
            char ba[25];
            ZeroMemory(&ba, 26 );
            sprintf( ba, "%u.%u.%u.%u", pAddr->Address[2], pAddr->Address[3], pAddr->Address[4], pAddr->Address[5] );
// ipv6     sprintf( ba, "%u.%u.%u.%u.%u.%u", pAddr->Address[0], pAddr->Address[1], pAddr->Address[2], pAddr->Address[3], pAddr->Address[4], pAddr->Address[5] );
//  --
            if(( SesTyp == 1 )||( SesTyp == 2 )){
                strcpy( bs, "Console" );
            }else if(( SesTyp == 3 )||( SesTyp == 4 )){
                strcpy( bs, "Remote" );
            }else if(( SesTyp == 5 )||( SesTyp == 6 )){
                strcpy( bs, "Logon" );
            }else if(( SesTyp == 7 )||( SesTyp == 8 )){
                strcpy( bs, "Lock" );
            }else{
                sprintf( bs, "Type-%u", SesTyp );
            }
//  --
            if( strlen( ba ) < 8 ) strcpy( ba, "localhost" );

            char pc[128];		// char *pc = malloc( sizeof( char ) * 64 );
            ZeroMemory(&pc, 128 );
            if( hostsize > 1 ) strcpy( pc, whost );
            else strcpy( pc, "localhost" );
//  --
            if( SesTyp % 2 ){	// если не кратна двум то начало
                sprintf( msg_err, "Begin Session Id-%i, Type-%i (%s), User:%s, Host:%s, IP:%s.", SesId, SesTyp, bs, wuser, pc, ba );
                prn_log( msg_err );
                if(( JOB > 100 )&&( SesTyp < 7 )) new_session( SesId, SesTyp, bs, wuser, token, pc, ba );
            }else{
                sprintf( msg_err, "End Session Id-%i, Type-%i (%s), User:%s.", SesId, SesTyp, bs, wuser );
                prn_log( msg_err );
                if(( JOB > 100 )&&( SesTyp < 7 )) end_session( SesId, SesTyp, bs, wuser );
            }
//  --
            WTSFreeMemory( whost );
        }
//  --
        WTSFreeMemory( bufa );
        WTSFreeMemory( wuser );
    }
}
예제 #2
0
session_t fa_audio_begin_session()
{
    if (!pa_mutex) {
        assert(false && "Module not initalized");
    }

    inform(string("Initializing real-time audio session"));

    fa_thread_lock(pa_mutex);
    {
        if (pa_status) {
            fa_thread_unlock(pa_mutex);
            return (session_t) audio_device_error(string("Overlapping real-time audio sessions"));
        } else {
            Pa_Initialize();
            pa_status = true;
            fa_thread_unlock(pa_mutex);

            session_t session = new_session();
            session_init_devices(session);

            current_session = session;
            return session;
        }
    }
}
예제 #3
0
session_ptr HSSessionMgr::new_session(boost::asio::io_service& io_service, /*int type, */size_t recv_buff_size, size_t send_buff_size)
{
	unsigned int id = ++curr_id_;
	session_ptr new_session(new HSSession(io_service, /*type, */id, recv_buff_size, send_buff_size));
	sessions_.insert(make_pair(id, new_session));
	return new_session;
}
예제 #4
0
struct http_session *http_session_create(struct conf_service *service,
        http_sessions_t http_sessions,
        unsigned int sesid)
{
    NMEM nmem = nmem_create();
    struct http_session *r = nmem_malloc(nmem, sizeof(*r));
    char tmp_str[50];

    sprintf(tmp_str, "session#%u", sesid);
    r->psession = new_session(nmem, service, sesid);
    r->session_id = sesid;
    r->timestamp = 0;
    r->nmem = nmem;
    r->destroy_counter = r->activity_counter = 0;
    r->http_sessions = http_sessions;

    yaz_mutex_enter(http_sessions->mutex);
    r->next = http_sessions->session_list;
    http_sessions->session_list = r;
    yaz_mutex_leave(http_sessions->mutex);

    r->timeout_iochan = iochan_create(-1, session_timeout, 0, "http_session_timeout");
    iochan_setdata(r->timeout_iochan, r);
    yaz_log(http_sessions->log_level, "Session %u created. timeout chan=%p timeout=%d", sesid, r->timeout_iochan, service->session_timeout);
    iochan_settimeout(r->timeout_iochan, service->session_timeout);

    iochan_add(service->server->iochan_man, r->timeout_iochan);
    http_session_use(1);
    return r;
}
예제 #5
0
파일: server.cpp 프로젝트: fengzhyuan/INET
void Server::start() {
    // new request from a client
    typeSession new_session(new Session(io_service_, room_));
    acceptor_.async_accept(new_session->socket(),
        boost::bind(&Server::h_start, this, new_session,
          boost::asio::placeholders::error));
}
예제 #6
0
		void start_accept()
		{
			chat_session_ptr new_session(new chat_session(io_service_, room_));
			acceptor_.async_accept(new_session->socket(),
					boost::bind(&chat_server::handle_accept, this, new_session,
						boost::asio::placeholders::error));
		}
예제 #7
0
/**
 * Creates a Authorization Session.
 */
AAASession* AAACreateAuthSession(void *generic_data,int is_client,int is_statefull,AAASessionCallback_f *cb,void *param)
{
	AAASession *s;
	str id;
	cdp_session_type_t type;
	
	generate_session_id(&id,0);
	
	if (is_client){
		if (is_statefull) type = AUTH_CLIENT_STATEFULL;
		else type = AUTH_CLIENT_STATELESS;
	}else{
		if (is_statefull) type = AUTH_SERVER_STATEFULL;
		else type = AUTH_SERVER_STATELESS;		
	}
	s = new_session(id,type);
	if (s) {
		s->u.auth.generic_data = generic_data;
		s->cb = cb;
		s->cb_param = param;
		s->u.auth.timeout=time(0)+config->tc*30; 
		s->u.auth.lifetime=time(0)+config->tc*32;
		s->u.auth.grace_period=config->tc*2;
		LOG(L_DBG,"id is %.*s",s->id.len,s->id.s);
		LOG(L_DBG,"hash is %u",s->hash);
		add_session(s);
	}
	return s;
}
예제 #8
0
void Server::authorize(struct mg_connection *conn, struct http_message *hm) {
	Server::session *session;
	std::string user = get_http_var(hm, "user");
	std::string password = get_http_var(hm, "password");

	std::string host;
	mg_str *host_hdr = mg_get_http_header(hm, "Host");
	if (host_hdr) {
		if (!CONFIG_STRING(m_config, "service.cert").empty()) {
			host += "https://";
		}
		else {
			host += "http://";
		}
		host += std::string(host_hdr->p, host_hdr->len);
	}

	if (check_password(user, password) && (session = new_session(user)) != NULL) {
		std::cout << "User authorized\n";
		mg_printf(conn, "HTTP/1.1 302 Found\r\n"
			"Set-Cookie: session=%s; max-age=3600; http-only\r\n"  // Session ID
			"Set-Cookie: user=%s\r\n"  // Set user, needed by Javascript code
			"Set-Cookie: admin=%s\r\n"  // Set user, needed by Javascript code
			"Set-Cookie: base_location=%s\r\n"  // Set user, needed by Javascript code
			"Set-Cookie: original_url=/; max-age=0\r\n"  // Delete original_url
			"Location: %s%sinstances\r\n\r\n",
			session->session_id, session->user, session->admin ? "1" : "0", CONFIG_STRING(m_config, "service.base_location").c_str(), host.c_str(), CONFIG_STRING(m_config, "service.base_location").c_str());
	} else {
		// Authentication failure, redirect to login.
		redirect_to(conn, hm, "/login");
	}
}
예제 #9
0
 void start()
 {
     session * new_session( new session( io_service_) );
     acceptor_.async_accept(
         new_session->socket(),
         boost::bind( & server::handle_accept_, this->shared_from_this(),
             new_session, boost::asio::placeholders::error) );
 }
예제 #10
0
void Connection::handle_accept(session_ptr session, const boost::system::error_code& error)
{
	if (!error)
	{
		session->start();
		session_ptr new_session(new Session(io_service_, room_));
		acceptor_.async_accept(new_session->socket(), boost::bind(&Connection::handle_accept, this, new_session, boost::asio::placeholders::error));
	}
}
예제 #11
0
void server::start_accept()
{
	{
		session_ptr new_session(new session(io_service_, this, maxLength_));

		acceptor_.async_accept(new_session->socket(),
				boost::bind(&server::handle_accept, this, new_session,
						boost::asio::placeholders::error));
	}
}
예제 #12
0
netmap_server::netmap_server(boost::asio::io_service& io_service, short server_port, 
                       tcp::endpoint& ep, const std::string& dump_file)
                       : m_io_service(io_service)
                       , m_acceptor(io_service, tcp::endpoint(tcp::v4(), server_port))
                       , m_remote_host(ep)
{
   portmap_session_ptr new_session(new portmap_session(m_io_service, m_remote_host));
   m_acceptor.async_accept(new_session->socket(),
      boost::bind(&netmap_server::handle_accept, this, new_session,
      boost::asio::placeholders::error));
}
예제 #13
0
void server::start_accept()
{
    this->_printDebug("TCPServer::start_accept - Start accepting connections");
	{
        // Need to save session as local member... Going out of scope leads to
        // issues
        session_ptr new_session(new session(io_service_, this, maxLength_, debug));
        sessionWaitingForAccept_ = new_session;
		acceptor_.async_accept(sessionWaitingForAccept_->socket(),
				boost::bind(&server::handle_accept, this, boost::asio::placeholders::error));
	}
}
예제 #14
0
session *
new_ircwindow (server *serv, char *name, int type)
{
	session *sess;

	switch (type)
	{
	case SESS_SERVER:
		serv = new_server ();
		if (prefs.use_server_tab)
		{
			register unsigned int oldh = prefs.hideuserlist;
			prefs.hideuserlist = 1;
			sess = new_session (serv, name, SESS_SERVER);
			prefs.hideuserlist = oldh;
		} else
		{
			sess = new_session (serv, name, SESS_CHANNEL);
		}
		serv->server_session = sess;
		serv->front_session = sess;
		break;
	case SESS_DIALOG:
		sess = new_session (serv, name, type);
		if (prefs.logging)
			log_open (sess);
		break;
	default:
/*	case SESS_CHANNEL:
	case SESS_NOTICES:
	case SESS_SNOTICES:*/
		sess = new_session (serv, name, type);
		break;
	}

	irc_init (sess);
	plugin_emit_dummy_print (sess, "Open Context");

	return sess;
}
예제 #15
0
파일: tftpcmd.c 프로젝트: sbmart/uftpd
int tftp_session(uev_ctx_t *ctx, int sd)
{
	int pid = 0;
	ctrl_t *ctrl;

	ctrl = new_session(ctx, sd, &pid);
	if (!ctrl)
		return pid;

	tftp_command(ctrl);

	exit(del_session(ctrl, 0));
}
예제 #16
0
/**
 * Creates a Generic Session.
 */
AAASession* AAACreateSession(void *generic_data)
{
	AAASession *s;
	str id;
	
	generate_session_id(&id,0);
	s = new_session(id,UNKNOWN_SESSION);
	if (s) {
		s->u.generic_data = generic_data;
	}
	
	return s;
}
예제 #17
0
  void handle_accept(boost::shared_ptr<message_session> session,
      const boost::system::error_code& error)
  {
    if (!error)
    {
      session->start();
      boost::shared_ptr<message_session> new_session(
		  new message_session(io_service_, zmq_recv_loop_, zmq_connection_pool_));

      acceptor_.async_accept(new_session->socket(),
         boost::bind(&message_server::handle_accept, this, new_session,
           boost::asio::placeholders::error));
    }
  }
예제 #18
0
	void Server::main_loop()
	{
		sigset_t sigset_tmpl, sigset;
		pthread_sigmask(0, NULL, &sigset_tmpl);
		sigaddset(&sigset_tmpl, SIGUSR1);
		sigset = sigset_tmpl;
		auto_ptr<DataStream> stream;
		try{
			info_printf(err_cons, "Waiting for connections.");
			while (!shutting_down){
				auto_ptr<DataStream> stream = server.accept(sigset, shutting_down);
				Mutex::Locker l(open_sessions_mutex);
				if (!shutting_down && get_sessions_count() < get_config_max_sessions()){
					try{
						auto_ptr<PackageStream> pstream(new PackageCodec(stream, get_config_max_package_size()));
						shared_ptr<Session> new_session(new Session(*this, pstream));
						open_sessions[new_session->get_id()] = new_session;
						new_session->launch();
					} catch (LoximException &ex) {
						warning_print(err_cons, "Caught exception while creating new session:");
						warning_print(err_cons, ex.to_string());
					} catch (...) {
						warning_print(err_cons, "Caught unknown exception while creating new session");
					}
				}
			}
		} catch (OperationCancelled &ex) {
			//this is a normal way of exiting the server
		} catch (LoximException &ex){
			info_print(err_cons, "Caught exception in server loop, shutting down");
			debug_print(err_cons, ex.to_string());
		} catch (...) {
			info_print(err_cons, "Caught unknown exception in server loop, shutting down");
		}
		{
			Mutex::Locker l(open_sessions_mutex);
			shutting_down = 1;
			info_print(err_cons, "Quitting, telling sessions to shut down");
			for (set<pair<const uint64_t, shared_ptr<Session> > >::iterator i = open_sessions.begin(); i != open_sessions.end(); i++){
				i->second->shutdown(0);
			}
		}
		info_print(err_cons, "Joining threads");
		for (set<pair<const uint64_t, shared_ptr<Session> > >::iterator i = open_sessions.begin(); i != open_sessions.end(); i++){
			pthread_join(i->second->get_thread(), NULL);
		}
		open_sessions.clear();
		info_print(err_cons, "Threads joined");
	}
예제 #19
0
session_ptr HSSessionMgr::new_local_session(boost::asio::io_service& io_service, unsigned int sid, size_t recv_buff_size, size_t send_buff_size)
{
	map<unsigned int, session_ptr>::iterator it = local_sessions_.find(sid);
	if (it != local_sessions_.end()) {
		if (!it->second->is_connected()) {
			return it->second;
		} else {
			return session_ptr();
		}
	}

	session_ptr new_session(new HSSession(io_service, sid, recv_buff_size, send_buff_size));
	local_sessions_.insert(make_pair(sid, new_session));
	return new_session;
}
예제 #20
0
  message_server(boost::asio::io_service& io_service,
      const boost::asio::ip::tcp::endpoint& endpoint,
	  ZmqConnectionPool& zmq_connection_pool)
    : io_service_(io_service),
      acceptor_(io_service, endpoint),
	  zmq_recv_loop_(io_service),
	  zmq_connection_pool_(zmq_connection_pool)
  {
    boost::shared_ptr<message_session> new_session(
		new message_session(io_service_, zmq_recv_loop_, zmq_connection_pool_));

    acceptor_.async_accept(new_session->socket(),
        boost::bind(&message_server::handle_accept, this, new_session,
          boost::asio::placeholders::error));
  }
예제 #21
0
/*
 * add a netmap port. We add them in pairs, so forwarding occurs
 * between two of them.
 */
void
netmap_add_port(const char *dev)
{
	static struct sess *s1 = NULL;	// XXX stateful; bad!
	struct my_netmap_port *port;
        int l;
        struct sess *s2;

        D("opening netmap device %s", dev);
        l = strlen(dev) + 1;
	if (l >= IFNAMSIZ) {
		D("name %s too long, max %d", dev, IFNAMSIZ - 1);
		sleep(2);
		return;
	}
        port = calloc(1, sizeof(*port));
	port->d = nm_open(dev, NULL, 0, NULL);
        if (port->d == NULL) {
                D("error opening %s", dev);
                kern_free(port);	// XXX compat
                return;
        }
	strncpy(port->ifp.if_xname, dev, IFNAMSIZ-1);
	port->allocator_id = port->d->req.nr_arg2;
	D("--- mem_id %d", port->allocator_id);
        s2 = new_session(port->d->fd, netmap_read, port, WANT_READ);
	port->sess = s2;
        D("create sess %p my_netmap_port %p", s2, port);
        if (s1 == NULL) {       /* first of a pair */
                s1 = s2;
        } else {                /* second of a pair, cross link */
                struct my_netmap_port *peer = s1->arg;
                port->peer = peer;
                peer->peer = port;

		port->can_swap_bufs = peer->can_swap_bufs =
			(port->allocator_id == peer->allocator_id);
                D("%p %s %d <-> %p %s %d %s",
                        port, port->d->req.nr_name, port->allocator_id,
                        peer, peer->d->req.nr_name, peer->allocator_id,
			port->can_swap_bufs ? "SWAP" : "COPY");
                s1 = NULL;
        }
}
static gboolean
rakia_nua_i_invite_cb (TpBaseConnection    *conn,
                       const RakiaNuaEvent *ev,
                       tagi_t               tags[],
                       RakiaMediaManager   *fac)
{
  TpHandle handle;
  RakiaSipSession *session;
  struct InviteData *idata;

  /* figure out a handle for the identity */

  handle = rakia_handle_by_requestor (conn, ev->sip);
  if (!handle)
    {
      MESSAGE ("incoming INVITE with invalid sender information");
      nua_respond (ev->nua_handle, 400, "Invalid From address", TAG_END());
      return TRUE;
    }

  DEBUG("Got incoming invite from <%s>",
        rakia_handle_inspect (conn, handle));

  if (handle == tp_base_connection_get_self_handle (conn))
    {
      DEBUG("cannot handle calls from self");
      nua_respond (ev->nua_handle, 501, "Calls from self are not supported", TAG_END());
      /* FIXME: Possible handle leak.. needs double checking ? */
      return TRUE;
    }

  session = new_session (fac, ev->nua_handle, 0);

  /* We delay emission of NewChannel(s) until we have the data on
   * initial media */
  idata = g_slice_new (struct InviteData);
  idata->fac = fac;
  idata->handle = handle;

  g_signal_connect (session, "incoming-call",
      G_CALLBACK (incoming_call_cb), idata);

  return TRUE;
}
예제 #23
0
void do_accept(boost::asio::io_service& io_service,
    unsigned short port, boost::asio::yield_context yield)
{
    boost::asio::ip::tcp::acceptor acceptor(
        io_service,
        boost::asio::ip::tcp::endpoint(
        boost::asio::ip::tcp::v4(), port));

    for (;;)
    {
        boost::system::error_code ec;
        std::shared_ptr<session> new_session(std::make_shared<session>(io_service));
        acceptor.async_accept(new_session->socket(), yield[ec]);
        if (!ec)
        {
            new_session->go();
        }
    }
}
예제 #24
0
// A handler for the /authorize endpoint.
// Login page form sends user name and password to this endpoint.
struct session* authorize_ex(struct mg_connection *conn,
		const struct mg_request_info *request_info) {
	char user[MAX_USER_LEN], password[MAX_USER_LEN];
	struct session *session;

	if (session = if_authorized(conn, request_info))
		return session;

	// Fetch user name and password.
	get_qsvar(request_info, "user", user, sizeof(user));
	get_qsvar(request_info, "password", password, sizeof(password));

	if (check_password(user, password) && (session = new_session()) != NULL) {
		my_strlcpy(session->user, user, sizeof(session->user));
		snprintf(session->random, sizeof(session->random), "%d", rand());
		generate_session_id(session->session_id, session->random,
				session->user);
		return session;
	}

	return 0;
}
예제 #25
0
client_t *client_create(uint16_t id,socket_t *tcp_socket,int connected)
{
	client_t *c = NULL;
	c = calloc(1,sizeof(client_t));
	if(!c)
		goto error;

	c->id = id;
	c->status = CLIENT_STATUS_NEW;
	c->tcp_sock = sock_copy(tcp_socket);
	c->connected = 0;
	c->session_id = new_session();
	c->tcp_data.len = 0;
	c->pack_count = 0;
	c->suspend = CLIENT_UNSUSPEND;


	return c;
error:
	if(c)
		free(c);
	return NULL;
}
예제 #26
0
// A handler for the /authorize endpoint.
// Login page form sends user name and password to this endpoint.
int authorize(struct mg_connection *conn,
		const struct mg_request_info *request_info) {
	char user[MAX_USER_LEN], password[MAX_USER_LEN];
	struct session *session;

	// Fetch user name and password.
	get_qsvar(request_info, "user", user, sizeof(user));
	get_qsvar(request_info, "password", password, sizeof(password));

	if (check_password(user, password) && (session = new_session()) != NULL) {
		// Authentication success:
		//   1. create new session
		//   2. set session ID token in the cookie
		//   3. remove original_url from the cookie - not needed anymore
		//   4. redirect client back to the original URL
		//
		// The most secure way is to stay HTTPS all the time. However, just to
		// show the technique, we redirect to HTTP after the successful
		// authentication. The danger of doing this is that session cookie can
		// be stolen and an attacker may impersonate the user.
		// Secure application must use HTTPS all the time.
		my_strlcpy(session->user, user, sizeof(session->user));
		snprintf(session->random, sizeof(session->random), "%d", rand());
		generate_session_id(session->session_id, session->random,
				session->user);
		mg_printf(conn, "HTTP/1.1 302 Found\r\n"
				"Set-Cookie: session=%s; max-age=3600; http-only\r\n" // Session ID
				"Set-Cookie: user=%s\r\n"// Set user, needed by Javascript code
				"Set-Cookie: original_url=/; max-age=0\r\n"// Delete original_url
				"Location: /\r\n\r\n", session->session_id, session->user);
		return 1;
	} else {
		// Authentication failure, redirect to login.
		redirect_to_login(conn, request_info);
		return 0;
	}
}
예제 #27
0
 ClusterInit()
   : inst(3, 0)
   , session(NULL)
   , schema_alter_session(NULL) {
   new_session();
 }
예제 #28
0
Connection::Connection(boost::asio::io_service& io_service, const tcp::endpoint& endpoint):io_service_(io_service), acceptor_(io_service, endpoint)
{
	session_ptr new_session(new Session(io_service_, room_));
	acceptor_.async_accept(new_session->socket(), boost::bind(&Connection::handle_accept, 
		this, new_session, boost::asio::placeholders::error));
}
예제 #29
0
파일: state.c 프로젝트: gygy/asuswrt
uint
state_process_packet()
{
    session_t           *this_session;
    enum sm_Status       smStatus;

#ifdef  __DEBUG__
    IF_TRACED((TRC_STATE|TRC_PACKET))
        printf("state_process_packet: Entered with event %s",smEvent_names[g_this_event.evtType]);
        if (g_this_event.evtType==evtPacketRcvd)
        {
            printf(" (%s)\n",Topo_opcode_names[g_opcode]);
        } else {
            puts("");
        }
    END_TRACE
#endif

    g_this_event.isInternalEvt = FALSE;	// It's a real event, not internally generated

    /* First, look this RealSrc up in the session table, to
     * locate any association with an established session.
     *
     * If there is no matching session, create a new one, iff the
     * packet is a valid Discover of either topo- or quick- TOS ... */

    g_this_event.isNewSession = FALSE;

    if ((this_session = find_session(&g_base_hdr->tbh_realsrc)) == NULL)
    {
        /* Not found: Check for a Discovery packet (validated in packetio.c) */
        if (g_opcode == Opcode_Discover)
        {
            /* Create a new session for this association */
            if ((this_session = new_session()) == NULL)
            {
                /* No room in the table: drop the packet and whine. */
                warn("state_process_packet: no room to create new session. Packet dropped.\n");
                return UINT_MAX;
            }
            g_this_event.isNewSession = TRUE;

            /* Fill in the newly valid session table entry with info from the packet */
            this_session->ssn_XID            = g_sequencenum;
            this_session->ssn_mapper_real    = g_base_hdr->tbh_realsrc;
            this_session->ssn_mapper_current = g_ethernet_hdr->eh_src;
            this_session->ssn_TypeOfSvc      = g_base_hdr->tbh_tos;
#ifdef  __DEBUG__
            IF_TRACED(TRC_STATE)
                printf("New Session:\n\tXID = %X\n\treal address: " ETHERADDR_FMT \
                       "\n",this_session->ssn_XID, \
                       ETHERADDR_PRINT(&this_session->ssn_mapper_real) );

                printf("\tcurrent address: " ETHERADDR_FMT "\n\tToS: %s\n",
                       ETHERADDR_PRINT(&this_session->ssn_mapper_current),
                       Lld2_tos_names[this_session->ssn_TypeOfSvc] );
            END_TRACE
#endif
            g_this_event.ssn = this_session;

        }   /*** end of if (g_opcode == Opcode_Discover) ***/

        /* Probes are forced to associate with the mapping session, if there is one. */
        if (g_opcode == Opcode_Probe)
        {
             if (g_topo_session != NULL  &&  g_topo_session->ssn_is_valid)
             {
                this_session = g_topo_session;
             }
        }

    }   /*** endo of if (find_session()==NULL) ***/

    /* We have associated whatever session that we can with this packet - pass to state machines */
    g_this_event.ssn = this_session;

    smStatus = smS_process_event( &g_this_event );

    if (smStatus != PROCESSING_ABORTED)
    {
        smStatus = smE_process_event( &g_this_event );
    }

    if (smStatus != PROCESSING_ABORTED)
    {
        smStatus = smT_process_event( &g_this_event );
    }

    /* Remove any "new-session" marking */
    g_this_event.isNewSession = FALSE;

#ifdef  __DEBUG__
    IF_TRACED(TRC_PACKET)
        printf("state_process_packet: Leaving - done with event %s\n",smEvent_names[g_this_event.evtType]);
    END_TRACE
#endif
    return 0;	/* Success! */
}
예제 #30
0
	void ClientController::start_accept() {
		client_ptr new_session( new Client( m_ioservice, *this ) ) ;
		m_acceptor.async_accept( new_session->socket(), boost::bind(&ClientController::accept_handler, this, new_session, boost::asio::placeholders::error));
    }