| 160 | } |
| 161 | |
| 162 | int init_log_cee_hostname(void) |
| 163 | { |
| 164 | struct addrinfo hints, *info = NULL; |
| 165 | char hostname[HOST_NAME_MAX+1]; |
| 166 | int rc; |
| 167 | str cname; |
| 168 | |
| 169 | if (log_cee_hostname.s) |
| 170 | return 0; |
| 171 | |
| 172 | gethostname (hostname, HOST_NAME_MAX); |
| 173 | |
| 174 | memset(&hints, 0, sizeof hints); |
| 175 | hints.ai_family = AF_UNSPEC; |
| 176 | hints.ai_socktype = SOCK_STREAM; |
| 177 | hints.ai_flags = AI_CANONNAME; |
| 178 | |
| 179 | rc = getaddrinfo(hostname, 0, &hints, &info); |
| 180 | if (!rc && info) { |
| 181 | init_str(&cname, info->ai_canonname); |
| 182 | if (pkg_str_dup(&log_cee_hostname, &cname) < 0) { |
| 183 | LM_ERR("no more pkg memory\n"); |
| 184 | freeaddrinfo(info); |
| 185 | return -1; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | if (info) |
| 190 | freeaddrinfo(info); |
| 191 | |
| 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | #define append_string(_d,_s,_len) \ |
| 196 | do{\ |
nothing calls this directly
no test coverage detected