![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
sip.h@13:ae278302dffe, 2014-09-16 (annotated)
- Committer:
- klauss
- Date:
- Tue Sep 16 15:09:11 2014 +0000
- Revision:
- 13:ae278302dffe
- Parent:
- 12:07fd716e0f35
- Child:
- 15:9c7456c1b6f4
one cbx on call per branch
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 0:4d17cd9c8f9d | 1 | #ifndef __SIP_H__ |
klauss | 0:4d17cd9c8f9d | 2 | #define __SIP_H__ |
klauss | 0:4d17cd9c8f9d | 3 | |
klauss | 0:4d17cd9c8f9d | 4 | #include <stdlib.h> |
klauss | 0:4d17cd9c8f9d | 5 | #include <stdint.h> |
klauss | 0:4d17cd9c8f9d | 6 | #include <string.h> |
klauss | 0:4d17cd9c8f9d | 7 | #include "mbed.h" |
klauss | 0:4d17cd9c8f9d | 8 | #include "EthernetInterface.h" |
klauss | 0:4d17cd9c8f9d | 9 | #include "call.h" |
klauss | 0:4d17cd9c8f9d | 10 | #include "vz_protocol.h" |
klauss | 0:4d17cd9c8f9d | 11 | #include "debug.h" |
klauss | 0:4d17cd9c8f9d | 12 | |
klauss | 3:cd9148672e25 | 13 | #define __INVITE_MAX_WAITING_TIME__ 30 |
klauss | 0:4d17cd9c8f9d | 14 | #define SIP_MAXFIELDSIZE 256 |
klauss | 0:4d17cd9c8f9d | 15 | #define SIP_MAXMSGSIZE 2048 |
klauss | 0:4d17cd9c8f9d | 16 | #define SIP_REGISTER_EXPIRES 120 |
klauss | 0:4d17cd9c8f9d | 17 | #define DRAMBASEADDR 0xa0000000 |
klauss | 0:4d17cd9c8f9d | 18 | #define SIP_ALLOW "Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER" |
klauss | 0:4d17cd9c8f9d | 19 | /* #define SIP_ALLOW "Allow: ACK, BYE, CANCEL, INVITE, OPTIONS" */ |
klauss | 0:4d17cd9c8f9d | 20 | |
klauss | 0:4d17cd9c8f9d | 21 | #define __SEVER_IP__ "192.168.120.120" |
klauss | 0:4d17cd9c8f9d | 22 | #define __SERVER_PORT__ 5075 |
klauss | 8:e3bfe62a477e | 23 | //#define __MY_IP__ "192.168.120.191" |
klauss | 0:4d17cd9c8f9d | 24 | #define __MY_PORT__ 5062 |
klauss | 0:4d17cd9c8f9d | 25 | #define __MY_EXT__ 820 |
klauss | 8:e3bfe62a477e | 26 | #define __PEER_EXT__ 913 |
klauss | 8:e3bfe62a477e | 27 | //#define __PEER_EXT__ 803 |
klauss | 0:4d17cd9c8f9d | 28 | |
klauss | 0:4d17cd9c8f9d | 29 | #define sip_idle 0 |
klauss | 0:4d17cd9c8f9d | 30 | #define sip_waiting_trying 1 << 1 |
klauss | 0:4d17cd9c8f9d | 31 | #define sip_trying 1 << 2 |
klauss | 0:4d17cd9c8f9d | 32 | #define sip_ringing 1 << 3 |
klauss | 0:4d17cd9c8f9d | 33 | #define sip_busy 1 << 4 |
klauss | 0:4d17cd9c8f9d | 34 | #define sip_ok 1 << 5 |
klauss | 0:4d17cd9c8f9d | 35 | #define sip_on_call 1 << 6 |
klauss | 0:4d17cd9c8f9d | 36 | #define sip_denied 1 << 7 |
klauss | 0:4d17cd9c8f9d | 37 | |
klauss | 0:4d17cd9c8f9d | 38 | class Sip{ |
klauss | 0:4d17cd9c8f9d | 39 | |
klauss | 0:4d17cd9c8f9d | 40 | private : |
klauss | 0:4d17cd9c8f9d | 41 | int id; |
klauss | 0:4d17cd9c8f9d | 42 | char server_ip[20]; |
klauss | 0:4d17cd9c8f9d | 43 | int server_port; |
klauss | 0:4d17cd9c8f9d | 44 | char my_ip[20]; |
klauss | 0:4d17cd9c8f9d | 45 | int my_port; |
klauss | 0:4d17cd9c8f9d | 46 | int my_ext; |
klauss | 0:4d17cd9c8f9d | 47 | int my_rtp_port; |
klauss | 0:4d17cd9c8f9d | 48 | char my_display[20]; |
klauss | 0:4d17cd9c8f9d | 49 | int peer_ext; |
klauss | 0:4d17cd9c8f9d | 50 | char fill_random_aux[ 65 ]; |
klauss | 0:4d17cd9c8f9d | 51 | char last_invite_tag[ SIP_MAXFIELDSIZE ]; |
klauss | 0:4d17cd9c8f9d | 52 | char last_invite_callid[ SIP_MAXFIELDSIZE ]; |
klauss | 0:4d17cd9c8f9d | 53 | char SVNREV[ 16 ]; |
klauss | 13:ae278302dffe | 54 | char buffer[ 1024 ]; |
klauss | 0:4d17cd9c8f9d | 55 | UDPSocket sock; |
klauss | 0:4d17cd9c8f9d | 56 | Endpoint sip_server; |
klauss | 0:4d17cd9c8f9d | 57 | void __init_sock__( void ); |
klauss | 0:4d17cd9c8f9d | 58 | void __end_sock__( void ); |
klauss | 0:4d17cd9c8f9d | 59 | public : |
klauss | 0:4d17cd9c8f9d | 60 | uint8_t status; |
klauss | 0:4d17cd9c8f9d | 61 | Sip(); |
klauss | 0:4d17cd9c8f9d | 62 | Sip( int id, uint16_t my_port ); |
klauss | 0:4d17cd9c8f9d | 63 | Sip( int id, uint16_t my_port, int dest_ext ); |
klauss | 0:4d17cd9c8f9d | 64 | Sip( char * server_ip, int server_port, char * my_ip, int my_port, int my_ext, int peer_ext, int id ); |
klauss | 0:4d17cd9c8f9d | 65 | ~Sip(); |
klauss | 0:4d17cd9c8f9d | 66 | void registry( void ); |
klauss | 0:4d17cd9c8f9d | 67 | VZ_call * invite( void ); |
klauss | 0:4d17cd9c8f9d | 68 | |
klauss | 0:4d17cd9c8f9d | 69 | char * make_content_length( char * header, char * body, char * pkg ); |
klauss | 0:4d17cd9c8f9d | 70 | |
klauss | 0:4d17cd9c8f9d | 71 | int get_return_code( char * s ); |
klauss | 0:4d17cd9c8f9d | 72 | int get_cseq( void ); |
klauss | 0:4d17cd9c8f9d | 73 | int get_id( void ); |
klauss | 0:4d17cd9c8f9d | 74 | int get_my_rtp_port( void ); |
klauss | 0:4d17cd9c8f9d | 75 | |
klauss | 0:4d17cd9c8f9d | 76 | char * build_registry_package( char * buffer ); |
klauss | 0:4d17cd9c8f9d | 77 | char * build_unregistry_package( char * buffer ); |
klauss | 0:4d17cd9c8f9d | 78 | char * build_invite_package( char * s, char * callbox_string, int * cseq ); |
klauss | 0:4d17cd9c8f9d | 79 | char * build_bye_package( char * buffer ); |
klauss | 0:4d17cd9c8f9d | 80 | char * build_ack_package( char * buffer, unsigned char * orig ); |
klauss | 0:4d17cd9c8f9d | 81 | char * build_generic_reply_package(char * s, unsigned char * orig, char * tag); |
klauss | 0:4d17cd9c8f9d | 82 | char * build_trying_package( char * buffer, unsigned char * orig ); |
klauss | 0:4d17cd9c8f9d | 83 | char * build_busy_package( char * buffer, unsigned char * orig ); |
klauss | 0:4d17cd9c8f9d | 84 | char * build_reply_package( char * buffer, unsigned char * orig ); |
klauss | 0:4d17cd9c8f9d | 85 | |
klauss | 0:4d17cd9c8f9d | 86 | char * fill_random16h(char * buffer ); |
klauss | 0:4d17cd9c8f9d | 87 | char * fill_random( char * buffer, int size ); |
klauss | 0:4d17cd9c8f9d | 88 | int fill_random_rtp_port( void ); |
klauss | 0:4d17cd9c8f9d | 89 | |
klauss | 0:4d17cd9c8f9d | 90 | char * decode_cseq(unsigned char * package, char * cseq); |
klauss | 0:4d17cd9c8f9d | 91 | char * decode_branch( unsigned char * package, char * branch ); |
klauss | 0:4d17cd9c8f9d | 92 | int decode_gettag( unsigned char * package, char * tag, char * out ); |
klauss | 0:4d17cd9c8f9d | 93 | |
klauss | 0:4d17cd9c8f9d | 94 | void change_sip_server(); |
klauss | 0:4d17cd9c8f9d | 95 | char * get_next_server_ip( char *server_ip ); |
klauss | 0:4d17cd9c8f9d | 96 | int get_next_server_port(); |
klauss | 0:4d17cd9c8f9d | 97 | int get_next_server_ext(); |
klauss | 0:4d17cd9c8f9d | 98 | |
klauss | 0:4d17cd9c8f9d | 99 | void set_server_ext( int new_server_ext ); |
klauss | 0:4d17cd9c8f9d | 100 | void set_server_port( int new_server_port ); |
klauss | 0:4d17cd9c8f9d | 101 | void set_ext( int ext ); |
klauss | 0:4d17cd9c8f9d | 102 | void set_port( int port ); |
klauss | 0:4d17cd9c8f9d | 103 | void set_server_ip( char * new_server_ip ); |
klauss | 0:4d17cd9c8f9d | 104 | |
klauss | 0:4d17cd9c8f9d | 105 | int listen_SIP_server( void ); |
klauss | 0:4d17cd9c8f9d | 106 | void send_bye( void ); |
klauss | 0:4d17cd9c8f9d | 107 | void send_unregistry_pkg( void ); |
klauss | 0:4d17cd9c8f9d | 108 | |
klauss | 0:4d17cd9c8f9d | 109 | uint8_t get_status( void ); |
klauss | 0:4d17cd9c8f9d | 110 | }; |
klauss | 0:4d17cd9c8f9d | 111 | #endif |