func: static void transmit_registerack(struct skinny_device *d) struct skinny_req * req ; if ( ! ( req = req_alloc ( sizeof ( struct register_ack_message ) , REGISTER_ACK_MESSAGE ) ) )  static struct skinny_req *req_alloc(size_t size, int response_message) struct skinny_req * req ; if ( ! ( req = ast_calloc ( 1 , skinny_header_size + size + 4 ) ) )  return NULL ; req -> len = htolel ( size + 4 ); req -> e = htolel ( response_message ); return req ; req -> data . regack . res [ 0 ] = '0'; req -> data . regack . res [ 1 ] = '\0'; req -> data . regack . keepAlive = htolel ( keep_alive ); memcpy ( req -> data . regack . dateTemplate , date_format , sizeof ( req -> data . regack . dateTemplate ) ); req -> data . regack . res2 [ 0 ] = '0'; req -> data . regack . res2 [ 1 ] = '\0'; req -> data . regack . secondaryKeepAlive = htolel ( keep_alive ); transmit_response ( d , req ); static void transmit_response(struct skinny_device *d, struct skinny_req *req) transmit_response_bysession ( d -> session , req ); static int transmit_response_bysession(struct skinnysession *s, struct skinny_req *req) if ( ! s )  ast_mutex_lock ( & s -> lock ); SKINNY_DEVONLY ( skinnydebug > 1 ast_verb ( 4 , "Transmitting %s to %s\n" , message2str ( req -> e ) , s -> device -> name ) ) static char *message2str(int type) switch ( letohl ( type ) )  snprintf ( tmp , MESSAGE2STR_BUFSIZE , "UNKNOWN_MESSAGE-%d" , type ); return tmp ; if ( ( letohl ( req -> len ) > SKINNY_MAX_PACKET ) || ( letohl ( req -> len ) < 0 ) )  ast_log ( LOG_WARNING , "transmit_response: the length of the request (%d) is out of bounds (%d)\n" , letohl ( req -> len ) , SKINNY_MAX_PACKET ); ast_mutex_unlock ( & s -> lock ); memset ( s -> outbuf , 0 , sizeof ( s -> outbuf ) ); memcpy ( s -> outbuf , req , skinny_header_size ); memcpy ( s -> outbuf + skinny_header_size , & req -> data , letohl ( req -> len ) ); res = write ( s -> fd , s -> outbuf , letohl ( req -> len ) + 8 ); if ( res != letohl ( req -> len ) + 8 )  ast_log ( LOG_WARNING , "Transmit: write only sent %d out of %d bytes: %s\n" , res , letohl ( req -> len ) + 8 , strerror ( errno ) ); if ( res == - 1 )  skinny_unregister ( NULL , s ); static int skinny_unregister(struct skinny_req *req, struct skinnysession *s) d = s -> device; if ( d )  d -> session = NULL; d -> registered = 0; AST_LIST_TRAVERSE ( & d -> speeddials , sd , list ) AST_LIST_TRAVERSE ( & d -> lines , l , list ) if ( l -> device == d )  manager_event ( EVENT_FLAG_SYSTEM , "PeerStatus" , "ChannelType: Skinny\r\nPeer: Skinny/%s@%s\r\nPeerStatus: Unregistered\r\n" , l -> name , d -> name ); ast_free ( req ); ast_mutex_unlock ( & s -> lock ); 