libisdn
|
00001 /* 00002 * X.213 NSAP address handling (for Q.931 Calling/-ed Party Subaddress IE) 00003 * 00004 * 00005 */ 00006 #ifndef _X213_H_ 00007 #define _X213_H_ 00008 00009 #if defined(PLATFORM_WINDOWS) 00010 #include <winsock2.h> 00011 #include <ws2tcpip.h> 00012 #if defined(PLATFORM_WIN64) 00013 #include <inaddr.h> 00014 #include <in6addr.h> 00015 #endif /* PLATFORM_WIN64 */ 00016 #else 00017 #include <arpa/inet.h> 00018 #include <netinet/in.h> /* in_addr, in6_addr */ 00019 #include <sys/socket.h> /* AF_INET, AF_INET6 */ 00020 #endif 00021 00022 typedef enum { 00023 NSAP_IDI_NONE = 0, 00024 NSAP_IDI_X121, 00025 NSAP_IDI_ISO_DCC, 00026 NSAP_IDI_F69, 00027 NSAP_IDI_E163, 00028 NSAP_IDI_E164, 00029 NSAP_IDI_ISO_6523_ICD, 00030 NSAP_IDI_IANA_ICP, 00031 NSAP_IDI_ITU_T_IND, 00032 NSAP_IDI_LOCAL 00033 } nsap_idi_format_t; 00034 00035 typedef enum { 00036 NSAP_DSP_NONE = 0, 00037 NSAP_DSP_DECIMAL, 00038 NSAP_DSP_BINARY, 00039 NSAP_DSP_ISO_IEC_646, 00040 NSAP_DSP_NATIONAL 00041 } nsap_dsp_syntax_t; 00042 00043 enum { 00044 NSAPE_NO_ERROR = 0, 00045 NSAPE_GENERR = -1, 00046 NSAPE_TOO_SHORT = -2, 00047 NSAPE_INVALID_FORMAT = -3, 00048 NSAPE_UNSUPPORTED_FORMAT = -4, 00049 }; 00050 00051 struct nsap_addr_f69 { 00052 char telex[8]; 00053 char value[30]; 00054 }; 00055 00056 struct nsap_addr_iso_dcc { 00057 unsigned short dcc; 00058 const char *name; 00059 const char *code; 00060 char value[35]; 00061 }; 00062 00063 struct nsap_addr_iana_icp { 00064 int family; 00065 union { 00066 struct in_addr ip4; 00067 struct in6_addr ip6; 00068 } icp_addr; 00069 #define icp_a_ip4 icp_addr.ip4 00070 #define icp_a_ip6 icp_addr.ip6 00071 }; 00072 00073 struct nsap_addr_iso_6523_icd { 00074 unsigned int icd; 00075 char value[34]; 00076 }; 00077 00078 struct nsap_addr_x121 { 00079 char dnn[14]; 00080 char value[24]; 00081 }; 00082 00083 struct nsap_addr_e163 { 00084 char number[12]; 00085 char value[26]; 00086 }; 00087 00088 struct nsap_addr_e164 { 00089 char number[15]; 00090 char value[23]; 00091 }; 00092 00093 struct nsap_addr_itu_t_ind { 00094 unsigned int ind; 00095 char value[32]; 00096 }; 00097 00098 struct nsap_addr_local { 00099 char value[38]; 00100 }; 00101 00105 struct nsap_addr { 00106 nsap_idi_format_t idi; 00107 nsap_dsp_syntax_t dsp; 00108 int max_dsp_length; 00109 union { 00110 struct nsap_addr_x121 x121; 00111 struct nsap_addr_iso_dcc iso_dcc; 00112 struct nsap_addr_f69 f69; 00113 struct nsap_addr_e163 e163; 00114 struct nsap_addr_e164 e164; 00115 struct nsap_addr_iso_6523_icd iso_6523_icd; 00116 struct nsap_addr_iana_icp iana_icp; 00117 struct nsap_addr_itu_t_ind itu_t_ind; 00118 struct nsap_addr_local local; 00119 } ns_addr; 00120 #define nsap_a_x121 ns_addr.x121 00121 #define nsap_a_iso_dcc ns_addr.iso_dcc 00122 #define nsap_a_f69 ns_addr.f69 00123 #define nsap_a_e163 ns_addr.e163 00124 #define nsap_a_e164 ns_addr.e164 00125 #define nsap_a_iso_6523_icd ns_addr.iso_6523_icd 00126 #define nsap_a_iana_icp ns_addr.iana_icp 00127 #define nsap_a_itu_t_ind ns_addr.itu_t_ind 00128 #define nsap_a_local ns_addr.local 00129 }; 00130 00131 int nsap_afi_valid(const char afi); 00132 int nsap_decode(struct nsap_addr *addr, char *buf, int size); 00133 int nsap_print(struct nsap_addr *addr, char *buf, int size); 00134 00135 #endif