Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
e4d6ade4
Commit
e4d6ade4
authored
18 years ago
by
Gisle Vanem
Browse files
Options
Downloads
Patches
Plain Diff
Moved functions common to IPv4 and C-ares to hostip.c;
Curl_freeaddrinfo() and Curl_ip2addr().
parent
c82e880f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/hostares.c
+0
-65
0 additions, 65 deletions
lib/hostares.c
lib/hostip.c
+65
-0
65 additions, 0 deletions
lib/hostip.c
lib/hostip4.c
+0
-60
0 additions, 60 deletions
lib/hostip4.c
with
65 additions
and
125 deletions
lib/hostares.c
+
0
−
65
View file @
e4d6ade4
...
...
@@ -292,69 +292,4 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
}
return
NULL
;
/* no struct yet */
}
#if !defined(CURLRES_IPV4)
/*
* The rest of this file is copied from hostip4.c. (needed for the
* combination USE_ARES and ENABLE_IPV6).
*/
/*
* This is a function for freeing name information in a protocol independent
* way.
*/
void
Curl_freeaddrinfo
(
Curl_addrinfo
*
ai
)
{
Curl_addrinfo
*
next
;
/* walk over the list and free all entries */
while
(
ai
)
{
next
=
ai
->
ai_next
;
free
(
ai
);
ai
=
next
;
}
}
struct
namebuf
{
struct
hostent
hostentry
;
char
*
h_addr_list
[
2
];
struct
in_addr
addrentry
;
char
h_name
[
16
];
/* 123.123.123.123 = 15 letters is maximum */
};
/*
* Curl_ip2addr() takes a 32bit ipv4 internet address as input parameter
* together with a pointer to the string version of the address, and it
* returns a Curl_addrinfo chain filled in correctly with information for this
* address/host.
*
* The input parameters ARE NOT checked for validity but they are expected
* to have been checked already when this is called.
*/
Curl_addrinfo
*
Curl_ip2addr
(
in_addr_t
num
,
const
char
*
hostname
,
int
port
)
{
Curl_addrinfo
*
ai
;
struct
hostent
*
h
;
struct
in_addr
*
addrentry
;
struct
namebuf
buffer
;
struct
namebuf
*
buf
=
&
buffer
;
h
=
&
buf
->
hostentry
;
h
->
h_addr_list
=
&
buf
->
h_addr_list
[
0
];
addrentry
=
&
buf
->
addrentry
;
addrentry
->
s_addr
=
num
;
h
->
h_addr_list
[
0
]
=
(
char
*
)
addrentry
;
h
->
h_addr_list
[
1
]
=
NULL
;
h
->
h_addrtype
=
AF_INET
;
h
->
h_length
=
sizeof
(
*
addrentry
);
h
->
h_name
=
&
buf
->
h_name
[
0
];
h
->
h_aliases
=
NULL
;
/* Now store the dotted version of the address */
snprintf
((
char
*
)
h
->
h_name
,
16
,
"%s"
,
hostname
);
ai
=
Curl_he2ai
(
h
,
port
);
return
ai
;
}
#endif
/* !CURLRES_IPV4 */
#endif
/* CURLRES_ARES */
This diff is collapsed.
Click to expand it.
lib/hostip.c
+
65
−
0
View file @
e4d6ade4
...
...
@@ -558,3 +558,68 @@ Curl_addrinfo *Curl_addrinfo_copy(const void *org, int port)
return
Curl_he2ai
(
orig
,
port
);
}
#endif
/* CURLRES_ADDRINFO_COPY */
/***********************************************************************
* Only for plain-ipv4 and c-ares builds
**********************************************************************/
#if defined(CURLRES_IPV4) || defined(CURLRES_ARES)
/*
* This is a function for freeing name information in a protocol independent
* way.
*/
void
Curl_freeaddrinfo
(
Curl_addrinfo
*
ai
)
{
Curl_addrinfo
*
next
;
/* walk over the list and free all entries */
while
(
ai
)
{
next
=
ai
->
ai_next
;
free
(
ai
);
ai
=
next
;
}
}
struct
namebuf
{
struct
hostent
hostentry
;
char
*
h_addr_list
[
2
];
struct
in_addr
addrentry
;
char
h_name
[
16
];
/* 123.123.123.123 = 15 letters is maximum */
};
/*
* Curl_ip2addr() takes a 32bit ipv4 internet address as input parameter
* together with a pointer to the string version of the address, and it
* returns a Curl_addrinfo chain filled in correctly with information for this
* address/host.
*
* The input parameters ARE NOT checked for validity but they are expected
* to have been checked already when this is called.
*/
Curl_addrinfo
*
Curl_ip2addr
(
in_addr_t
num
,
const
char
*
hostname
,
int
port
)
{
Curl_addrinfo
*
ai
;
struct
hostent
*
h
;
struct
in_addr
*
addrentry
;
struct
namebuf
buffer
;
struct
namebuf
*
buf
=
&
buffer
;
h
=
&
buf
->
hostentry
;
h
->
h_addr_list
=
&
buf
->
h_addr_list
[
0
];
addrentry
=
&
buf
->
addrentry
;
addrentry
->
s_addr
=
num
;
h
->
h_addr_list
[
0
]
=
(
char
*
)
addrentry
;
h
->
h_addr_list
[
1
]
=
NULL
;
h
->
h_addrtype
=
AF_INET
;
h
->
h_length
=
sizeof
(
*
addrentry
);
h
->
h_name
=
&
buf
->
h_name
[
0
];
h
->
h_aliases
=
NULL
;
/* Now store the dotted version of the address */
snprintf
((
char
*
)
h
->
h_name
,
16
,
"%s"
,
hostname
);
ai
=
Curl_he2ai
(
h
,
port
);
return
ai
;
}
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lib/hostip4.c
+
0
−
60
View file @
e4d6ade4
...
...
@@ -93,23 +93,6 @@
* Only for plain-ipv4 builds
**********************************************************************/
#ifdef CURLRES_IPV4
/* plain ipv4 code coming up */
/*
* This is a function for freeing name information in a protocol independent
* way.
*/
void
Curl_freeaddrinfo
(
Curl_addrinfo
*
ai
)
{
Curl_addrinfo
*
next
;
/* walk over the list and free all entries */
while
(
ai
)
{
next
=
ai
->
ai_next
;
free
(
ai
);
ai
=
next
;
}
}
/*
* Curl_ipvalid() checks what CURL_IPRESOLVE_* requirements that might've
* been set and returns TRUE if they are OK.
...
...
@@ -123,49 +106,6 @@ bool Curl_ipvalid(struct SessionHandle *data)
return
TRUE
;
/* OK, proceed */
}
struct
namebuf
{
struct
hostent
hostentry
;
char
*
h_addr_list
[
2
];
struct
in_addr
addrentry
;
char
h_name
[
16
];
/* 123.123.123.123 = 15 letters is maximum */
};
/*
* Curl_ip2addr() takes a 32bit ipv4 internet address as input parameter
* together with a pointer to the string version of the address, and it
* returns a Curl_addrinfo chain filled in correctly with information for this
* address/host.
*
* The input parameters ARE NOT checked for validity but they are expected
* to have been checked already when this is called.
*/
Curl_addrinfo
*
Curl_ip2addr
(
in_addr_t
num
,
const
char
*
hostname
,
int
port
)
{
Curl_addrinfo
*
ai
;
struct
hostent
*
h
;
struct
in_addr
*
addrentry
;
struct
namebuf
buffer
;
struct
namebuf
*
buf
=
&
buffer
;
h
=
&
buf
->
hostentry
;
h
->
h_addr_list
=
&
buf
->
h_addr_list
[
0
];
addrentry
=
&
buf
->
addrentry
;
addrentry
->
s_addr
=
num
;
h
->
h_addr_list
[
0
]
=
(
char
*
)
addrentry
;
h
->
h_addr_list
[
1
]
=
NULL
;
h
->
h_addrtype
=
AF_INET
;
h
->
h_length
=
sizeof
(
*
addrentry
);
h
->
h_name
=
&
buf
->
h_name
[
0
];
h
->
h_aliases
=
NULL
;
/* Now store the dotted version of the address */
snprintf
((
char
*
)
h
->
h_name
,
16
,
"%s"
,
hostname
);
ai
=
Curl_he2ai
(
h
,
port
);
return
ai
;
}
#ifdef CURLRES_SYNCH
/* the functions below are for synchronous resolves */
/*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment