Asterisk agi.h error

I’m trying to test agi in asterisk.

agi wants to use c.

However, I included only agi.h header file in a3.c, but a huge error occurred.
It’s happening.

Maybe I installed asterisk incorrectly… If you write a regular extensions.conf,
It works fine so far, but what is the problem?

The command is
gcc -o a3 a3.c -I /usr/src/asterisk-18.23.1/include/asterisk
-I/user/src/asterisk-18.23.1/include

Below is the c source.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <agi.h>

int main(int argc,char* argv)
{
FILE*fp;
fp = fopen(“a.log”,“at”);
fprintf(fp,“valeus = %s\n”,argv[1]);
fclose(fp);

setlinebuf(stdout);
setlinebuf(stderr);
fprintf(stdout,"return values ​​test…%s\n ",argv[1]);

strcat(argv[1],“–Ha ha”);
fprintf(stdout,“return values ​​test…%s\n”,argv[1]);
return 100;
}

The result is

[root@localhost cpro]# gcc -o a3 a3.c -I/usr/src/asterisk-18.23.1/include/asterisk -I/usr/src/asterisk-18.23.1/include
In file included from /usr/src/asterisk-18.23.1/include/asterisk/utils.h:26,
from /usr/src/asterisk-18.23.1/include/asterisk/alertpipe.h:22,
from /usr/src/asterisk-18.23.1/include/asterisk/channel.h:125,
from /usr/src/asterisk-18.23.1/include/asterisk/pbx.h:26,
from /usr/src/asterisk-18.23.1/include/asterisk/features.h:27,
from /usr/include/bits/libc-header-start.h:33,
from /usr/include/stdio.h:28,
from a3.c:1:
/usr/src/asterisk-18.23.1/include/asterisk/network.h:57:2: error: #error “don’t know how to handle network functions here.”
57 | #error “don’t know how to handle network functions here.”
| ^~~~~
/usr/src/asterisk-18.23.1/include/asterisk/network.h:95:20: error: expected ‘;’ before ‘int’
95 | static force_inline int inaddrcmp(const struct sockaddr_in *sin1, const struct sockaddr_in *sin2)
| ^~~~
| ;
/usr/src/asterisk-18.23.1/include/asterisk/network.h: In function ‘inaddrcmp’:
/usr/src/asterisk-18.23.1/include/asterisk/network.h:97:22: error: invalid use of undefined type ‘const struct sockaddr_in’
97 | return ((sin1->sin_addr.s_addr != sin2->sin_addr.s_addr)
| ^~
/usr/src/asterisk-18.23.1/include/asterisk/network.h:97:47: error: invalid use of undefined type ‘const struct sockaddr_in’
97 | return ((sin1->sin_addr.s_addr != sin2->sin_addr.s_addr)
| ^~
/usr/src/asterisk-18.23.1/include/asterisk/network.h:98:25: error: invalid use of undefined type ‘const struct sockaddr_in’
98 | || (sin1->sin_port != sin2->sin_port));
| ^~
/usr/src/asterisk-18.23.1/include/asterisk/network.h:98:43: error: invalid use of undefined type ‘const struct sockaddr_in’
98 | || (sin1->sin_port != sin2->sin_port));
| ^~

etc …

The relevant part of the source:

#ifdef HAVE_ARPA_INET_H
#include <netinet/in.h>
#include <arpa/inet.h>		/* include early to override inet_ntoa */
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <sys/socket.h>
#include <net/if.h>
#include <sys/ioctl.h>
#elif defined(HAVE_WINSOCK_H)
#include <winsock.h>
typedef int socklen_t;
#elif defined(HAVE_WINSOCK2_H)
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#error "don't know how to handle network functions here."
#endif

By the way, if you’re trying to write an AGI client in C, you don’t need to include any Asterisk source to do it.

This is the important part of the answer.