[FFmpeg-devel] [PATCH 1/4] avformat/ip: factorize some IP filtering and resolving functions to a new file

Michael Niedermayer michael at niedermayer.cc
Sat Sep 22 01:12:12 EEST 2018


On Fri, Sep 21, 2018 at 12:11:59AM +0200, Marton Balint wrote:
> These are based on the very similar UDP and RTP protocol functions.
> 
> Signed-off-by: Marton Balint <cus at passwd.hu>
[...]
> new file mode 100644
> index 0000000000..23794a6f05
> --- /dev/null
> +++ b/libavformat/ip.h
> @@ -0,0 +1,70 @@
> +/*
> + * IP common code
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public License
> + * as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public License
> + * along with FFmpeg; if not, write to the Free Software * Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#ifndef AVFORMAT_IP_H
> +#define AVFORMAT_IP_H
> +
> +#include "network.h"
> +
> +/**
> + * Structure for storing IP (UDP) source filters or block lists.
> + */
> +typedef struct IPSourceFilters {
> +    int nb_include_addrs;
> +    int nb_exclude_addrs;
> +    struct sockaddr_storage *include_addrs;
> +    struct sockaddr_storage *exclude_addrs;
> +} IPSourceFilters;
> +

> +/**
> + * Checks the source address against a given IP source filter.
> + * @return 0 if packet should be processed based on the filter.
> + */

missing documentation what it returns if thats not the case



> +int ff_ip_check_source_lists(struct sockaddr_storage *source_addr_ptr, IPSourceFilters *s);
> +
> +/**
> + * Resolves hostname into an addrinfo structure.
> + * @return addrinfo structure which should be freed by the user.
> + */

missing information about error return


> +struct addrinfo *ff_ip_resolve_host(void *log_ctx,
> +                                    const char *hostname, int port,
> +                                    int type, int family, int flags);
> +
> +
> +/**
> + * Parses the address[,address] source list in buf and adds it to the filters
> + * IPSourceFilters structure.
> + * @return 0 on success, < 0 on error.

this should document if the error codes are AVERROR codes or something else


> + */
> +int ff_ip_parse_sources(void *log_ctx, char *buf, IPSourceFilters *filters);
> +
> +/**
> + * Parses the address[,address] source block list in buf and adds it to the
> + * filters IPSourceFilters structure.
> + * @return 0 on success, < 0 on error.
> + */
> +int ff_ip_parse_blocks(void *log_ctx, char *buf, IPSourceFilters *filters);

does it change the buf content ? if so this should be documented


> +
> +/**
> + * Frees the internal fields of an IPSourceFilters structure.
> + */
> +void ff_ip_free_filters(IPSourceFilters *filters);

IPSourceFilters is "allocated" by the user ?
this may cause an issue if its used in libavdevice in the future
just mentioning so this relation is considered

thx


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180922/51d6367a/attachment.sig>


More information about the ffmpeg-devel mailing list