Changeset 190:02857b1cd872 in freeDiameter for freeDiameter/dict_base_proto.c
- Timestamp:
- Feb 5, 2010, 5:59:41 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
freeDiameter/dict_base_proto.c
r156 r190 144 144 } 145 145 146 /* Dump the content of an Address AVP */ 146 147 static void Address_dump(union avp_value * avp_value) 147 148 { 148 fd_log_debug("*todo: dump address*"); 149 union { 150 sSA sa; 151 sSS ss; 152 sSA4 sin; 153 sSA6 sin6; 154 } s; 155 uint16_t fam; 156 157 memset(&s, 0, sizeof(s)); 158 159 /* The first two octets represent the address family, http://www.iana.org/assignments/address-family-numbers/ */ 160 if (avp_value->os.len < 2) { 161 fd_log_debug("[invalid length: %d]", avp_value->os.len); 162 return; 163 } 164 165 /* Following octets are the address in network byte order already */ 166 fam = avp_value->os.data[0] << 8 | avp_value->os.data[1]; 167 switch (fam) { 168 case 1: 169 /* IP */ 170 s.sa.sa_family = AF_INET; 171 if (avp_value->os.len != 6) { 172 fd_log_debug("[invalid IP length: %d]", avp_value->os.len); 173 return; 174 } 175 memcpy(&s.sin.sin_addr.s_addr, avp_value->os.data + 2, 4); 176 break; 177 case 2: 178 /* IP6 */ 179 s.sa.sa_family = AF_INET6; 180 if (avp_value->os.len != 18) { 181 fd_log_debug("[invalid IP6 length: %d]", avp_value->os.len); 182 return; 183 } 184 memcpy(&s.sin6.sin6_addr.s6_addr, avp_value->os.data + 2, 16); 185 break; 186 default: 187 fd_log_debug("[unsupported family: 0x%hx]", fam); 188 return; 189 } 190 191 sSA_DUMP_NODE(&s.sa, NI_NUMERICHOST); 149 192 } 150 193
Note: See TracChangeset
for help on using the changeset viewer.